From f8f5c7ce7dd512f86701ede669264e9f57d36c82 Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Sun, 3 Mar 2019 08:45:01 -0800 Subject: [PATCH 1/3] Added enableJobCaching option. Closes #1203 --- config/components.json | 3 +++ src/plugins/GenerateJob/GenerateJob.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/config/components.json b/config/components.json index 78a39c927..888bff9ac 100644 --- a/config/components.json +++ b/config/components.json @@ -1,4 +1,7 @@ { + "GenerateJob": { + "enableJobCaching": false + }, "AutoViz": { "preloadIds": [ "ArchEditor", diff --git a/src/plugins/GenerateJob/GenerateJob.js b/src/plugins/GenerateJob/GenerateJob.js index dfc6e0d0c..85b951f26 100644 --- a/src/plugins/GenerateJob/GenerateJob.js +++ b/src/plugins/GenerateJob/GenerateJob.js @@ -10,6 +10,7 @@ define([ 'deepforge/OperationCode', 'deepforge/plugin/PtrCodeGen', 'text!./metadata.json', + 'js/Utils/ComponentSettings', 'plugin/PluginBase' ], function ( Templates, @@ -20,12 +21,14 @@ define([ OperationCode, PtrCodeGen, pluginMetadata, + ComponentSettings, PluginBase ) { 'use strict'; pluginMetadata = JSON.parse(pluginMetadata); const DATA_DIR = 'artifacts/'; + const DEFAULT_SETTINGS = {enableJobCaching: false}; var OUTPUT_INTERVAL = 1500, STDOUT_FILE = 'job_stdout.txt'; @@ -40,6 +43,12 @@ define([ // Call base class' constructor. PluginBase.call(this); this.pluginMetadata = pluginMetadata; + + this.settings = _.extend({}, DEFAULT_SETTINGS), + ComponentSettings.resolveWithWebGMEGlobal( + this.settings, + this.getComponentId() + ); }; /** @@ -53,6 +62,10 @@ define([ GenerateJob.prototype = Object.create(PluginBase.prototype); GenerateJob.prototype.constructor = GenerateJob; + GenerateJob.prototype.getComponentId = function () { + return 'GenerateJob'; + }; + /** * Main function for the plugin to execute. This will perform the execution. * Notes: @@ -110,6 +123,7 @@ define([ GenerateJob.prototype.createRunScript = function (inputs, files={}) { let runsh = [ '# Bash script to download data files and run job', + !this.settings.enableJobCaching ? `# Created at ${Date.now()}` : '', 'if [ -z "$DEEPFORGE_URL" ]; then', ' echo "Please set DEEPFORGE_URL and re-run:"', ' echo ""', From 2a12e4676b74cc23c199760be0c086d69b42210b Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Sun, 3 Mar 2019 09:10:18 -0800 Subject: [PATCH 2/3] WIP #1203 fixed issues when running plugin on server --- src/plugins/GenerateJob/GenerateJob.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/plugins/GenerateJob/GenerateJob.js b/src/plugins/GenerateJob/GenerateJob.js index 85b951f26..07c76bcd8 100644 --- a/src/plugins/GenerateJob/GenerateJob.js +++ b/src/plugins/GenerateJob/GenerateJob.js @@ -10,8 +10,8 @@ define([ 'deepforge/OperationCode', 'deepforge/plugin/PtrCodeGen', 'text!./metadata.json', - 'js/Utils/ComponentSettings', - 'plugin/PluginBase' + 'plugin/PluginBase', + 'module' ], function ( Templates, Q, @@ -21,8 +21,8 @@ define([ OperationCode, PtrCodeGen, pluginMetadata, - ComponentSettings, - PluginBase + PluginBase, + module ) { 'use strict'; @@ -44,11 +44,19 @@ define([ PluginBase.call(this); this.pluginMetadata = pluginMetadata; - this.settings = _.extend({}, DEFAULT_SETTINGS), - ComponentSettings.resolveWithWebGMEGlobal( - this.settings, - this.getComponentId() - ); + this.settings = _.extend({}, DEFAULT_SETTINGS); + if (typeof WebGMEGlobal === 'undefined') { // Running in NodeJS + const path = require('path'); + const dirname = path.dirname(module.uri); + const deploymentSettings = JSON.parse(requirejs('text!' + dirname + '/../../../config/components.json')); + _.extend(this.settings, deploymentSettings); + } else { // Running in the browser + const ComponentSettings = requirejs('js/Utils/ComponentSettings'); + ComponentSettings.resolveWithWebGMEGlobal( + this.settings, + this.getComponentId() + ); + } }; /** From 172baacf344193c964eac0f5125deaa4f6d98bbc Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Sun, 3 Mar 2019 09:14:35 -0800 Subject: [PATCH 3/3] WIP fixed eslint issues --- src/plugins/GenerateJob/GenerateJob.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/GenerateJob/GenerateJob.js b/src/plugins/GenerateJob/GenerateJob.js index 07c76bcd8..c5d7e8853 100644 --- a/src/plugins/GenerateJob/GenerateJob.js +++ b/src/plugins/GenerateJob/GenerateJob.js @@ -1,4 +1,4 @@ -/*globals define*/ +/*globals define, requirejs*/ /*jshint node:true, browser:true*/ define([