Merge pull request #2213 from Luis-Fernando-Molina/develop

Contribution: Platform New Feature: Demo Mode
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-10-25 09:00:10 -04:00
commit 3ea96fec6f
12 files changed
+122 -22

No files matched your search

+1
View File
@@ -8,6 +8,7 @@ if (process.env.PACKAGED_PATH) {
exports.newEnvironment = function () {
let thisObject = {
DEMO_MODE: false,
BASE_PATH: basePath,
WEB_SERVER_URL: 'localhost',
PLATFORM_WEB_SOCKETS_INTERFACE_PORT: 18041,
-3
View File
@@ -1,8 +1,5 @@
exports.newEventServer = function newEventServer() {
const MODULE = "Events Server"
const LOG_INFO = false
let thisObject = {
initialize: initialize,
finalize: finalize,
+5 -1
View File
@@ -44,7 +44,11 @@ exports.newHttpInterface = function newHttpInterface() {
let endpointOrFile = requestPath[1]
switch (endpointOrFile) {
case 'Environment':
{
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.env), httpResponse)
}
break
case 'WEB3':
{
SA.projects.foundations.utilities.httpRequests.getRequestBody(httpRequest, httpResponse, processRequest)
+34 -5
View File
@@ -9,7 +9,7 @@
const WEB_SOCKET = SA.nodeModules.ws
let socketServer
let port = global.env.PLATFORM_WEB_SOCKETS_INTERFACE_PORT
let port = global.env.PLATFORM_WEB_SOCKETS_INTERFACE_PORT
return thisObject
@@ -36,13 +36,42 @@
socket.on('message', onMenssage)
function onMenssage(message){
function onMenssage(message) {
try {
if (LOG_INFO === true) {
console.log('Message Received: ' + message.substring(0, 1000))
if (global.env.DEMO_MODE === true) {
/*
In DEMO MODE we will accept Task / Sessioins Running or Stopping if you are requesting this from localhost only.
*/
if (socket._socket.remoteAddress !== "::1") {
if (
message.toString().indexOf('"eventType":"Run Task"') >= 0
||
message.toString().indexOf('"eventType":"Stop Task"') >= 0
||
message.toString().indexOf('"eventType":"Run Trading Session"') >= 0
||
message.toString().indexOf('"eventType":"Stop Trading Session"') >= 0
||
message.toString().indexOf('"eventType":"Resume Trading Session"') >= 0
||
message.toString().indexOf('"eventType":"Run Learning Session"') >= 0
||
message.toString().indexOf('"eventType":"Stop Learning Session"') >= 0
||
message.toString().indexOf('"eventType":"Resume Learning Session"') >= 0
) {
console.log('Trying to execute a Task while in DEMO MODE. Some hacking has taken place!')
console.log('Hacker IP Address is: ' + socket._socket.remoteAddress)
return
}
}
}
if (LOG_INFO === true) {
console.log('Message Received: ' + message.toString().substring(0, 10000))
}
let messageArray = message.toString().split('|*|')
let origin = messageArray[0]
+12 -3
View File
@@ -4,7 +4,7 @@ function newAppPostLoader() {
const MODULE_NAME = 'Post Loader'
const ERROR_LOG = true
const logger = newWebDebugLog()
let thisObject = {
start: start
@@ -14,9 +14,18 @@ function newAppPostLoader() {
function start() {
try {
// autoSaveWhenClosingTheBrowser()
setupProjectsSchema()
setupEnvironment()
function setupEnvironment() {
httpRequest(undefined, 'Environment', onResponse)
function onResponse(err, file) {
UI.environment = JSON.parse(file)
setupProjectsSchema()
}
}
function setupProjectsSchema() {
httpRequest(undefined, 'ProjectsSchema', onResponse)
+2 -1
View File
@@ -5,7 +5,8 @@ let PROJECTS_SCHEMA
let SCHEMAS_BY_PROJECT = new Map()
/* New Root object*/
let UI = {
projects: {}
projects: {},
environment: {}
}
/* User Interface Colors */
@@ -42,6 +42,15 @@ function newAlgorithmicTradingFunctionLibraryTradingSessionFunctions() {
}
function runSession(node, resume, callBackFunction) {
if (UI.environment.DEMO_MODE === true) {
if (window.location.hostname !== 'localhost') {
node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not RUN Sessions.', 5)
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
let validationsResult = validations(node)
if (validationsResult === undefined) {
/* If something fails at validations we just quit. */
@@ -164,7 +173,7 @@ function newAlgorithmicTradingFunctionLibraryTradingSessionFunctions() {
let defaultExchange = UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(validationsResult.exchange.payload, 'codeName')
let defaultMarket =
UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(validationsResult.market.baseAsset.payload.referenceParent.payload, 'codeName')
+ '-' +
+ '-' +
UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(validationsResult.market.quotedAsset.payload.referenceParent.payload, 'codeName')
let dependencyFilter = UI.projects.foundations.functionLibraries.dependenciesFilter.createDependencyFilter(
@@ -195,6 +204,15 @@ function newAlgorithmicTradingFunctionLibraryTradingSessionFunctions() {
}
function stopSession(node, callBackFunction) {
if (UI.environment.DEMO_MODE === true) {
if (window.location.hostname !== 'localhost') {
node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not STOP Sessions.', 5)
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
let validationsResult = validations(node)
if (validationsResult === undefined) {
/* If something fails at validations we just quit. */
@@ -90,6 +90,14 @@ function newFoundationsFunctionLibraryTaskFunctions() {
function runTask(node, isDebugging, callBackFunction) {
if (UI.environment.DEMO_MODE === true) {
if (window.location.hostname !== 'localhost') {
node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not RUN Tasks.', 5)
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
let lanNetworkNode = validations(node)
if (lanNetworkNode === undefined) {
/* This means that the validations failed. */
@@ -218,6 +226,15 @@ function newFoundationsFunctionLibraryTaskFunctions() {
}
function stopTask(node, callBackFunction) {
if (UI.environment.DEMO_MODE === true) {
if (window.location.hostname !== 'localhost') {
node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not STOP Tasks.', 5)
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
let lanNetworkNode = validations(node)
if (lanNetworkNode === undefined) {
/* This means that the validations failed. */
@@ -1064,7 +1064,7 @@
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": true,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
@@ -11847,7 +11847,7 @@
"type": "Tokens Awarded",
"name": "New Tokens Awarded",
"project": "Governance",
"id": "b66c668c-8411-4401-8aa7-10d8b2c4c233",
"id": "90876ef0-3d01-4a3f-afc8-52914972a040",
"savedPayload": {
"position": {
"x": 33628.04190627182,
@@ -42,6 +42,15 @@ function newMachineLearningFunctionLibraryLearningSessionFunctions() {
}
function runSession(node, resume, callBackFunction) {
if (UI.environment.DEMO_MODE === true) {
if (window.location.hostname !== 'localhost') {
node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not execute Sessions.', 5)
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
let validationsResult = validations(node)
if (validationsResult === undefined) {
/* If something fails at validations we just quit. */
@@ -74,13 +83,13 @@ function newMachineLearningFunctionLibraryLearningSessionFunctions() {
'Layers API->Core API->' +
'Sequential Model->Functional Model->' +
'Data Reporting->' +
'Input Layer->Sequential layer->Output Layer->'+
'Input Layer->Sequential layer->Output Layer->' +
'Input Features->Data Feature->Feature Formula->Input Shape->Batch Input Shape->Feature Preprocessing->MinMax Scaler->Standard Scaler->Collection Condition->' +
'Output Labels->Data Label->Label Formula->' +
'Advanced Activation Layers->Basic Layers->Convolutional Layers->' +
'Conv 1D Layer->Conv 2D Layer->Conv 2D Transpose Layer->Conv 3D Layer->Cropping 2D Layer->Depthwise Convo 2D Layer->Separable Convo 2D Layer->Up Sampling 2D Layer->' +
'Activation Layer->Dense Layer->Dropout Layer->Embedding Layer->Flatten Layer->Permutable Layer->Rrepeat Vector Layer->Reshape Layer->Spatial Dropout 1D Layer->' +
'Elu Layer->Leaky Relu Layer->Prelu Layer->Relu Layer->Softmax Layer->Thresholded Relu Layer->'+
'Elu Layer->Leaky Relu Layer->Prelu Layer->Relu Layer->Softmax Layer->Thresholded Relu Layer->' +
'Dimensionality Units->Activation Function->Dtype->Trainable->Weights->Tensor->Kernel->Bias->' +
'Kernel Initializer->Kernel Constraint->Kernel Regularizer->' +
'Bias Initializer->Bias Constraint->Bias Regularizer->'
@@ -121,8 +130,8 @@ function newMachineLearningFunctionLibraryLearningSessionFunctions() {
'Serial Number->Identifier->Begin->End->Begin Rate->End Rate->Strategy Name->Status->Exit Type->' +
'Balance->Begin Balance->End Balance->' +
'Index->Situation Name->Formula->Periods->' +
'Features->Feature->Begin->End->Feature Value->'+
'Labels->Label->Begin->End->Label Value->'+
'Features->Feature->Begin->End->Feature Value->' +
'Labels->Label->Begin->End->Label Value->' +
'Predictions->Prediction->Begin->End->Prediction Value->'
let learningEngine = UI.projects.visualScripting.functionLibraries.protocolNode.getProtocolNode(node.learningEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath)
@@ -169,6 +178,15 @@ function newMachineLearningFunctionLibraryLearningSessionFunctions() {
}
function stopSession(node, callBackFunction) {
if (UI.environment.DEMO_MODE === true) {
if (window.location.hostname !== 'localhost') {
node.payload.uiObject.setWarningMessage('Superalgos is running is DEMO MODE. This means that you can not STOP Sessions.', 5)
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
let validationsResult = validations(node)
if (validationsResult === undefined) {
/* If something fails at validations we just quit. */
+8 -2
View File
@@ -26,13 +26,14 @@ if (
console.log('')
console.log('TELEGRAM COMMUNITY: https://t.me/superalgoscommunity')
console.log('')
console.log('USAGE: node platform [help] [noBrowser] [minMemo]')
console.log('USAGE: node platform [help] [noBrowser] [minMemo] [demoMode]')
console.log('')
console.log('OPTIONS:')
console.log('')
console.log(' help: Optional. Use it to see this helping information.')
console.log(' noBrowser: Optional. Use it to launch Superalgos Platform Client only. The Superalgos Platform UI will not be loaded.')
console.log(' minMemo: Optional. Use it when your hardware has less than 8 Gb or memory.')
console.log(' demoMode: Optional. Use it to launch Superalgos in Demo Mode. Users will be able to use the UI but not run Tasks.')
console.log('')
console.log('If you are having an error while trying to run the Superalgos Platform Client, consider this:')
@@ -68,7 +69,6 @@ console.log('OPTIONS ACCEPTED:')
console.log('')
let optionsAccepted = 0
if (process.argv.includes("minMemo")) {
optionsAccepted++
console.log('minMemo ..................................................... Running with Minimun Required Memory.')
@@ -79,9 +79,15 @@ if (process.argv.includes("noBrowser")) {
console.log('noBrowser ................................................... Running without User Interface.')
}
if (process.argv.includes("demoMode")) {
optionsAccepted++
console.log('demoMode .................................................... Running without User Interface.')
}
if (optionsAccepted === 0) {
console.log('none ........................................................ Running without any command line options.')
}
console.log('')
console.log('')