Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enableJobCaching option. Closes #1203 #1204

Merged
merged 3 commits into from
Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/components.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"GenerateJob": {
"enableJobCaching": false
},
"AutoViz": {
"preloadIds": [
"ArchEditor",
Expand Down
28 changes: 25 additions & 3 deletions src/plugins/GenerateJob/GenerateJob.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*globals define*/
/*globals define, requirejs*/
/*jshint node:true, browser:true*/

define([
Expand All @@ -10,7 +10,8 @@ define([
'deepforge/OperationCode',
'deepforge/plugin/PtrCodeGen',
'text!./metadata.json',
'plugin/PluginBase'
'plugin/PluginBase',
'module'
], function (
Templates,
Q,
Expand All @@ -20,12 +21,14 @@ define([
OperationCode,
PtrCodeGen,
pluginMetadata,
PluginBase
PluginBase,
module
) {
'use strict';

pluginMetadata = JSON.parse(pluginMetadata);
const DATA_DIR = 'artifacts/';
const DEFAULT_SETTINGS = {enableJobCaching: false};
var OUTPUT_INTERVAL = 1500,
STDOUT_FILE = 'job_stdout.txt';

Expand All @@ -40,6 +43,20 @@ define([
// Call base class' constructor.
PluginBase.call(this);
this.pluginMetadata = pluginMetadata;

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()
);
}
};

/**
Expand All @@ -53,6 +70,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:
Expand Down Expand Up @@ -110,6 +131,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 ""',
Expand Down