Adding execution parameters
This commit is contained in:
1 parent
3bc2031d90
commit
53cd6d609e
9 files changed
+97
-34
No files matched your search
@@ -88,6 +88,11 @@ const createClone = async (clone) => {
|
||||
'value': clone.resumeExecution.toString()
|
||||
})
|
||||
|
||||
env.push({
|
||||
'name': 'EXECUTION_PARAMETERS',
|
||||
'value': buildExecutionParameters(clone)
|
||||
})
|
||||
|
||||
if (clone.mode === BACKTEST) {
|
||||
env.push({
|
||||
'name': 'BEGIN_DATE_TIME',
|
||||
@@ -151,4 +156,36 @@ const createClone = async (clone) => {
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
}
|
||||
|
||||
function buildExecutionParameters(clone){
|
||||
let executionParameters = {}
|
||||
executionParameters.timePeriod = clone.timePeriod
|
||||
executionParameters.dataSet = datasetNames().get(clone.timePeriod)
|
||||
return executionParameters
|
||||
}
|
||||
|
||||
function datasetNames(){
|
||||
let dataSetMap = new Map()
|
||||
dataSetMap.set("24-hs","Multi-Period-Market")
|
||||
dataSetMap.set("12-hs","Multi-Period-Market")
|
||||
dataSetMap.set("08-hs","Multi-Period-Market")
|
||||
dataSetMap.set("06-hs","Multi-Period-Market")
|
||||
dataSetMap.set("04-hs","Multi-Period-Market")
|
||||
dataSetMap.set("03-hs","Multi-Period-Market")
|
||||
dataSetMap.set("02-hs","Multi-Period-Market")
|
||||
dataSetMap.set("01-hs","Multi-Period-Market")
|
||||
dataSetMap.set("45-min","Multi-Period-Daily")
|
||||
dataSetMap.set("40-min","Multi-Period-Daily")
|
||||
dataSetMap.set("30-min","Multi-Period-Daily")
|
||||
dataSetMap.set("20-min","Multi-Period-Daily")
|
||||
dataSetMap.set("15-min","Multi-Period-Daily")
|
||||
dataSetMap.set("10-min","Multi-Period-Daily")
|
||||
dataSetMap.set("05-min","Multi-Period-Daily")
|
||||
dataSetMap.set("04-min","Multi-Period-Daily")
|
||||
dataSetMap.set("03-min","Multi-Period-Daily")
|
||||
dataSetMap.set("02-min","Multi-Period-Daily")
|
||||
dataSetMap.set("01-min","Multi-Period-Daily")
|
||||
return dataSetMap
|
||||
}
|
||||
|
||||
export default createClone
|
||||
@@ -20,13 +20,18 @@ const getClonePodLogs = async (cloneName) => {
|
||||
'tailLines': '20'
|
||||
}
|
||||
}
|
||||
const logs = await client.api.v1.namespaces('default')
|
||||
.pods(pod.body.items[0].metadata.name).log.get(queryLogs)
|
||||
let logsArray = logs.body.split('\n')
|
||||
if(pod.body.items[0] !== undefined){
|
||||
const logs = await client.api.v1.namespaces('default')
|
||||
.pods(pod.body.items[0].metadata.name).log.get(queryLogs)
|
||||
let logsArray = logs.body.split('\n')
|
||||
|
||||
logger.debug('getClonePodLogs on kubernates successful.')
|
||||
logger.debug('getClonePodLogs on kubernates successful.')
|
||||
|
||||
return JSON.stringify(logsArray, null, 2)
|
||||
return JSON.stringify(logsArray, null, 2)
|
||||
} else {
|
||||
logger.warn('getClonePodStatus pod not found %s: ', cloneName)
|
||||
return "Logs not available."
|
||||
}
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Client, config } from 'kubernetes-client'
|
||||
const getClonePodStatus = async (cloneName) => {
|
||||
try {
|
||||
logger.debug('getClonePodStatus on kubernates started. ')
|
||||
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
|
||||
const client = new Client({ config: config.fromKubeconfig(), version: '1.9' })
|
||||
|
||||
let query = {
|
||||
'qs': {
|
||||
@@ -15,14 +15,20 @@ const getClonePodStatus = async (cloneName) => {
|
||||
|
||||
const pod = await client.api.v1.namespaces('default').pods.get(query)
|
||||
|
||||
let clonePodStatus = pod.body.items[0].status.containerStatuses[0].state
|
||||
if (pod.body.items[0] !== undefined) {
|
||||
let clonePodStatus = pod.body.items[0].status.containerStatuses[0].state
|
||||
|
||||
if (clonePodStatus.hasOwnProperty('terminated')
|
||||
&& clonePodStatus.terminated.hasOwnProperty('containerID')) {
|
||||
delete clonePodStatus.terminated.containerID
|
||||
if (clonePodStatus.hasOwnProperty('terminated')
|
||||
&& clonePodStatus.terminated.hasOwnProperty('containerID')) {
|
||||
delete clonePodStatus.terminated.containerID
|
||||
}
|
||||
logger.debug('getClonePodStatus %s on kubernates successful', cloneName)
|
||||
|
||||
return JSON.stringify(clonePodStatus, null, 2)
|
||||
} else {
|
||||
logger.warn('getClonePodStatus pod not found %s: ', cloneName)
|
||||
return " Clone not found on the server. "
|
||||
}
|
||||
logger.debug('getClonePodStatus %s on kubernates successful', cloneName)
|
||||
return JSON.stringify(clonePodStatus, null, 2)
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ const removeClone = async (clone) => {
|
||||
|
||||
logger.debug('removeClone %s on kubernates succesful', clone.id)
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
logger.warn('removeClone %s on kubernates failed, the job was not found on the server.', clone.id)
|
||||
}
|
||||
}
|
||||
export default removeClone
|
||||
@@ -21,7 +21,7 @@ const args = {
|
||||
clone: { type: CloneInputType }
|
||||
}
|
||||
|
||||
const resolve = async(parent, { clone }, context) => {
|
||||
const resolve = async (parent, { clone }, context) => {
|
||||
logger.debug('addClone -> Entering Fuction.')
|
||||
|
||||
if (!context.userId) {
|
||||
@@ -36,7 +36,7 @@ const resolve = async(parent, { clone }, context) => {
|
||||
throw new WrongArgumentsError('The bot type selected is not valid.')
|
||||
}
|
||||
|
||||
if ( (clone.mode === LIVE || clone.mode === COMPETITION) && !isDefined(clone.keyId)) {
|
||||
if ((clone.mode === LIVE || clone.mode === COMPETITION) && !isDefined(clone.keyId)) {
|
||||
throw new WrongArgumentsError('The key was not provided to run the clone.')
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ const resolve = async(parent, { clone }, context) => {
|
||||
} else {
|
||||
throw new AutorizationError()
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
await createKubernetesClone(clone)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ const Type = new GraphQLInputObjectType({
|
||||
interval: { type: GraphQLInt },
|
||||
processName: { type: new GraphQLNonNull(GraphQLString) },
|
||||
botType: { type: new GraphQLNonNull(GraphQLString) },
|
||||
keyId: { type: GraphQLString }
|
||||
keyId: { type: GraphQLString },
|
||||
timePeriod: { type: GraphQLString }
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user