Multiple Schemas at Task Server
This commit is contained in:
1 parent
e683d86c0f
commit
b4a49d1d76
7 files changed
+37
-23
No files matched your search
@@ -168,8 +168,20 @@ function newSuperalgosFunctionLibraryTaskFunctions() {
|
||||
|
||||
let networkDefinition = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(networkNode.payload.parentNode, false, true, true, false, false, networkLightingPath)
|
||||
|
||||
/*
|
||||
We will also send all the project schemas we have to the Task Server.
|
||||
*/
|
||||
let projectSchemas = []
|
||||
for (let k = 0; k < PROJECTS_SCHEMA.length; k++) {
|
||||
let projectDefinition = PROJECTS_SCHEMA[k]
|
||||
let project = {
|
||||
name: projectDefinition.name,
|
||||
schema: SCHEMAS_BY_PROJECT.get(projectDefinition.name).array.appSchema
|
||||
}
|
||||
projectSchemas.push(project)
|
||||
}
|
||||
let event = {
|
||||
appSchema: JSON.stringify(SCHEMAS_BY_PROJECT.get('Superalgos').array.appSchema),
|
||||
projectSchemas: JSON.stringify(projectSchemas),
|
||||
taskId: node.id,
|
||||
taskName: node.name,
|
||||
taskDefinition: JSON.stringify(taskDefinition),
|
||||
|
||||
@@ -151,7 +151,7 @@ exports.newGlobals = function newGlobals() {
|
||||
return resultArray
|
||||
|
||||
function scanNodeBranch(startingNode) {
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.type)
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (startingNode.type === nodeType) {
|
||||
@@ -418,11 +418,11 @@ exports.newGlobals = function newGlobals() {
|
||||
}
|
||||
return percentage
|
||||
}
|
||||
|
||||
|
||||
global.GET_EQUAL_DATES = function (date1, date2) {
|
||||
let day1Days = Math.trunc(date1.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
let day2Days = Math.trunc(date2.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
|
||||
|
||||
if (day1Days === day2Days) {
|
||||
return true
|
||||
} else {
|
||||
@@ -444,7 +444,7 @@ exports.newGlobals = function newGlobals() {
|
||||
errorMessage: errorMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Error', event)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ exports.newSnapshots = function newSnapshots(bot, logger) {
|
||||
}
|
||||
|
||||
/* Now we go down through all this node children */
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.type)
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
|
||||
@@ -112,7 +112,7 @@ exports.newTradingEngine = function newTradingEngine(bot, logger) {
|
||||
destinationNode.value = originNode.value
|
||||
|
||||
/* Now we go down through all the children of the origin node, assuming the destination node has the same children structure*/
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(originNode.type)
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(originNode.project + '-' + originNode.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
@@ -151,7 +151,7 @@ exports.newTradingEngine = function newTradingEngine(bot, logger) {
|
||||
nodesMap.set(node.id, node)
|
||||
|
||||
/* Now we go down through all this node children */
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.type)
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
@@ -194,7 +194,7 @@ exports.newTradingEngine = function newTradingEngine(bot, logger) {
|
||||
}
|
||||
|
||||
/* Now we go down through all this node children */
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.type)
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
|
||||
@@ -201,7 +201,7 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM
|
||||
}
|
||||
|
||||
/* Now we go down through all this node children */
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.type)
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
|
||||
@@ -101,7 +101,7 @@ exports.newMarkovDecisionProcess = function newMarkovDecisionProcess(bot, logger
|
||||
destinationNode.value = originNode.value
|
||||
|
||||
/* Now we go down through all the children of the origin node, assuming the destination node has the same children structure*/
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(originNode.type)
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(originNode.project + '-' + originNode.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
@@ -140,7 +140,7 @@ exports.newMarkovDecisionProcess = function newMarkovDecisionProcess(bot, logger
|
||||
nodesMap.set(node.id, node)
|
||||
|
||||
/* Now we go down through all this node children */
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.type)
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
@@ -183,7 +183,7 @@ exports.newMarkovDecisionProcess = function newMarkovDecisionProcess(bot, logger
|
||||
}
|
||||
|
||||
/* Now we go down through all this node children */
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.type)
|
||||
let nodeDefinition = global.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
|
||||
+12
-10
@@ -28,8 +28,7 @@ function preLoader() {
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent('Task Manager - ' + taskId, 'Nodejs Process Ready for Task')
|
||||
function eventReceived(message) {
|
||||
try {
|
||||
global.APP_SCHEMA_ARRAY = JSON.parse(message.event.appSchema)
|
||||
setUpAppSchema()
|
||||
setUpAppSchema(JSON.parse(message.event.projectSchemas))
|
||||
global.TASK_NODE = JSON.parse(message.event.taskDefinition)
|
||||
global.TASK_NETWORK = JSON.parse(message.event.networkDefinition)
|
||||
bootLoader()
|
||||
@@ -42,7 +41,7 @@ function preLoader() {
|
||||
console.log('[ERROR] Task Server -> Task -> preLoader -> global.TASK_NODE = ' + JSON.stringify(global.TASK_NODE).substring(0, 1000))
|
||||
}
|
||||
}
|
||||
else {
|
||||
else {
|
||||
/*
|
||||
This process was started not by the Task Manager, but independently
|
||||
(most likely for debugging purposes). In this case we listen to an event
|
||||
@@ -52,8 +51,7 @@ function preLoader() {
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent('Task Server', 'Debug Task Started', undefined, 'Task Server', undefined, startDebugging)
|
||||
function startDebugging(message) {
|
||||
try {
|
||||
global.APP_SCHEMA_ARRAY = JSON.parse(message.event.appSchema)
|
||||
setUpAppSchema()
|
||||
setUpAppSchema(JSON.parse(message.event.projectSchemas))
|
||||
global.TASK_NODE = JSON.parse(message.event.taskDefinition)
|
||||
global.TASK_NETWORK = JSON.parse(message.event.networkDefinition)
|
||||
bootLoader()
|
||||
@@ -68,13 +66,17 @@ function preLoader() {
|
||||
}
|
||||
}
|
||||
|
||||
function setUpAppSchema() {
|
||||
function setUpAppSchema(projectSchemas) {
|
||||
/* Setup the APP_SCHEMA_MAP based on the APP_SCHEMA_ARRAY */
|
||||
global.APP_SCHEMA_MAP = new Map()
|
||||
for (let i = 0; i < global.APP_SCHEMA_ARRAY.length; i++) {
|
||||
let nodeDefinition = global.APP_SCHEMA_ARRAY[i]
|
||||
let key = nodeDefinition.type
|
||||
global.APP_SCHEMA_MAP.set(key, nodeDefinition)
|
||||
for (let i = 0; i < projectSchemas.length; i++) {
|
||||
let project = projectSchemas[i]
|
||||
|
||||
for (let j = 0; j < project.schema.length; j++) {
|
||||
let nodeDefinition = project.schema[j]
|
||||
let key = project + '-' + nodeDefinition.type
|
||||
global.APP_SCHEMA_MAP.set(key, nodeDefinition)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user