Skip to content

Commit

Permalink
Merge pull request #1091 from deepforge-dev/v2.0.0
Browse files Browse the repository at this point in the history
V2.0.0
  • Loading branch information
brollb committed Mar 30, 2018
2 parents 6474843 + 0822577 commit c516532
Show file tree
Hide file tree
Showing 215 changed files with 17,914 additions and 16,086 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
language: node_js
services: mongodb
addons:
chrome: beta
sudo: false
script: npm run test-unit
before_install: if [[ `npm -v` != 5* ]]; then npm i -g npm@5; fi
node_js:
- "6.2.1"
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ webgme.addToRequireJsPaths(gmeConfig);
gracefulFs.gracefulify(fs);

// Clear seed hash info
['nn', 'pipeline'].map(lib => path.join(__dirname, 'src', 'seeds', lib, 'hash.txt'))
['pipeline'].map(lib => path.join(__dirname, 'src', 'seeds', lib, 'hash.txt'))
.forEach(file => rm_rf.sync(file));

myServer = new webgme.standaloneServer(gmeConfig);
Expand Down
3 changes: 0 additions & 3 deletions bin/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"torch": {
"dir": "~/.deepforge/torch"
},
"blob": {
"dir": "~/.deepforge/blob"
},
Expand Down
185 changes: 33 additions & 152 deletions bin/deepforge
Original file line number Diff line number Diff line change
Expand Up @@ -184,69 +184,6 @@ var startMongo = function(args, port, silent) {
});
};

var hasTorch = function() {
var result = childProcess.spawnSync('th', ['--help']);
return !result.error;
};

var installTorchExtras = function() {
// Check if rnn is installed
var result = childProcess.spawnSync('luarocks', ['list', '--porcelain']),
pkgs = result.stdout.toString().split('\n')
.map(line => line.match(/^[a-zA-Z0-9]+/g))
.map(m => m && m[0]);

if (pkgs.indexOf('rnn') === -1) {
return spawn('luarocks', ['install', 'rnn']);
} else {
return Q();
}
};

var installTorch = function() {
var tgtDir = p(config.torch.dir),
args;

if (!hasTorch()) {
// Try to install torch
console.log(`Torch7 not found. Installing to ${tgtDir}...`);
args = `clone https://github.com/torch/distro.git ${tgtDir} --recursive`.split(' ');

return spawn('git', args)
.catch(result => {
var error = result.error || result.stderr ||
`Torch install failed with exit code ${result.code}`;

if (result.stderr.includes('unable to access')) {
error = `Could not access the torch repository. Are you ` +
`connected to the internet?\n`;
} else if (result.code === 128) {
error = `${tgtDir} is not empty. ` +
'Please empty it or change the torch directory:\n' +
'\n deepforge config torch.dir NEW/TORCH/PATH\n';

}

console.error(error);
process.exit(result.code);
})
.then((code, stderr) => {
process.chdir(tgtDir);
return spawn('bash', ['install-deps'])
.then(() => spawn('bash', ['install.sh'], true))
.then(() => {
storeConfig('torch.dir', tgtDir);
console.log('Installed torch. Please close and ' +
're-open your terminal to use DeepForge w/ ' +
'torch support!');
process.exit(0);
});
});
} else {
return Q();
}
};

var spawn = function(cmd, args, opts) {
var deferred = Q.defer(),
job,
Expand Down Expand Up @@ -319,31 +256,22 @@ program.command('start')
}

if (args.worker) {
if (hasTorch()) {
current
.then(() => installTorchExtras())
.then(() => {
main = path.join(__dirname, 'start-worker.js');
if (args.worker !== true) {
spawn('node', [main, args.worker]);
} else {
spawn('node', [main]);
}
});
} else {
installTorch();
}
current
.then(() => {
main = path.join(__dirname, 'start-worker.js');
if (args.worker !== true) {
spawn('node', [main, args.worker]);
} else {
spawn('node', [main]);
}
});
}

if (!args.server && !args.worker && !args.mongo) {
// Starting everything
current = current.then(() => checkMongo(args));
if (hasTorch()) {
current.then(() => installTorchExtras())
.then(() => spawn('node', [main]));
} else {
installTorch();
}
current = current
.then(() => checkMongo(args))
.then(() => spawn('node', [main]));
}

});
Expand All @@ -353,97 +281,50 @@ program
.command('update')
.description('upgrade deepforge to latest version')
.option('-g, --git', 'update tracking the git repo')
.option('-t, --torch', 'update torch installation')
.option('-s, --server', 'update deepforge')
.action(args => {
var pkg = 'deepforge',
latestVersion;

// Install the project
if (!args.torch || args.server) {

if (args.git) {
pkg = pkgJson.repository.url;
} else {
// Check the version
try {
latestVersion = execSync('npm show deepforge version')
.toString().replace(/\s+$/, '');

if (latestVersion === version) {
console.log('Already up-to-date');
return;
}
} catch (e) {
console.log('Could not retrieve the latest deepforge version');
}
}

spawn('npm', ['install', '-g', pkg])
.then(() => {
console.log('Upgrade successful!');
})
.catch(code => console.log('Upgrade failed w/ error code: ' + code));
}
if (args.git) {
pkg = pkgJson.repository.url;
} else {
// Check the version
try {
latestVersion = execSync('npm show deepforge version')
.toString().replace(/\s+$/, '');

if (args.torch || !args.server) {
// Update torch
if (hasTorch()) {
// Upgrade torch
console.log('Upgrading torch...');
console.log(`Checking for torch in ${config.torch.dir}`);
// Verify that torch is installed in the config's location
if (!exists.sync(path.join(config.torch.dir, 'update.sh'))) {
// config is incorrect!
console.log('Could not find torch installation. Please update the deepforge config with:');
console.log('');
console.log(' deepforge config torch.dir ~/path/to/torch/install');
console.log('');
if (latestVersion === version) {
console.log('Already up-to-date');
return;
}

spawn('bash', ['./update.sh'], {cwd: p(config.torch.dir)})
.catch(err => console.log('Upgrade failed w/ error code: ' + err.code))
.then(() => {
console.log('About to update rnn package...');
// Update rnn
return spawn('luarocks', ['install', 'rnn']);
})
.then(() => {
console.log('Upgrade successful!');
})
.catch(code => console.log('Upgrade failed w/ error code: ' + code));
} else {
installTorch();
} catch (e) {
console.log('Could not retrieve the latest deepforge version');
}
}

spawn('npm', ['install', '-g', pkg])
.then(() => {
console.log('Upgrade successful!');
})
.catch(code => console.log('Upgrade failed w/ error code: ' + code));
});

// uninstall command
program
.command('uninstall')
.description('uninstall deepforge from the system')
.option('-t, --torch', 'uninstall torch')
.option('-c, --clean', 'uninstall deepforge, torch and all associated data/config')
.option('-c, --clean', 'uninstall deepforge and all associated data/config')
.action(opts => {
if (opts.torch || opts.clean) {
if (opts.torch) {
console.log(`uninstalling torch at ${p(config.torch.dir)}`);
}
rm_rf.sync(p(config.torch.dir));
}

if (opts.clean) { // remove the .deepforge directory
console.log('removing config and data files...');
rm_rf.sync(p(config.mongo.dir));
rm_rf.sync(p(configDir));
}

if (!opts.torch || opts.clean) { // uninstall deepforge
spawn('npm', ['uninstall', '-g', 'deepforge'])
.then(() => console.log('deepforge has been uninstalled!'))
.catch(() => console.log('uninstall failed'));
}
spawn('npm', ['uninstall', '-g', 'deepforge'])
.then(() => console.log('deepforge has been uninstalled!'))
.catch(() => console.log('uninstall failed'));
});

// config
Expand Down
4 changes: 2 additions & 2 deletions bin/start-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var spawn = require('child_process').spawn,
stdout = '',
execJob,
path = require('path'),
env = {cwd: path.join(__dirname, '..')},
env = {cwd: path.join(__dirname, '..'), NODE_ENV: process.env.NODE_ENV},
workerJob = null,
gmeConfig = require(__dirname + '/../config');

Expand All @@ -12,7 +12,7 @@ if (gmeConfig.blob.type === 'FS') {
process.env.DEEPFORGE_WORKER_CACHE = path.resolve(gmeConfig.blob.fsDir + '/wg-content');
}

process.env.NODE_ENV = 'local';
// process.env.NODE_ENV = 'local';
execJob = spawn('node', [
path.join(__dirname, '..', 'app.js')
], env);
Expand Down
9 changes: 0 additions & 9 deletions bin/start-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ try {
childProcess.spawnSync('ln', ['-s', `${__dirname}/../node_modules`, modules]);
}

// Check torch support
var result = childProcess.spawnSync('th', ['--help']);
if (result.error) {
console.error('Checking Torch7 dependency failed. Do you have Torch7 installed ' +
'and in your PATH?\n\nFor Torch7 installation instructions, check out ' +
'http://torch.ch/docs/getting-started.html');
process.exit(1);
}

var cleanUp = function() {
console.log('removing worker directory ', workerPath);
rm_rf.sync(workerPath);
Expand Down
9 changes: 9 additions & 0 deletions chimp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
webdriverio: {
desiredCapabilities: {
chromeOptions: {
args: ["--headless", "--disable-extensions"]
}
}
}
};
5 changes: 3 additions & 2 deletions config/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
var config = require('./config.default'),
path = require('path');

config.server.port = 9001;
config.mongo.uri = 'mongodb://127.0.0.1:27017/webgme_tests';
config.server.port = 8080;
config.mongo.uri = process.env.MONGO_URI || 'mongodb://127.0.0.1:27017';
config.mongo.uri = config.mongo.uri.replace(/\/[a-zA-Z_\-]*$/, '') + '/deepforge_tests';
config.blob.fsDir = path.join(__dirname, '..', 'test-tmp', 'blob');

module.exports = config;
31 changes: 25 additions & 6 deletions config/config.webgme.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ config.visualization.layout.basePaths.push(__dirname + '/../src/layouts');
config.visualization.layout.basePaths.push(__dirname + '/../node_modules/webgme-chflayout/src/layouts');
config.visualization.decoratorPaths.push(__dirname + '/../src/decorators');
config.visualization.decoratorPaths.push(__dirname + '/../node_modules/webgme-easydag/src/decorators');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/nn');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/devTests');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/devUtilTests');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/pipeline');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/devPipelineTests');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/project');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/cifar10');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/xor');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/devProject');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/minimal');
config.seedProjects.basePaths.push(__dirname + '/../src/seeds/tests');



Expand All @@ -32,9 +32,21 @@ config.visualization.panelPaths.push(__dirname + '/../node_modules/webgme-easyda
config.visualization.panelPaths.push(__dirname + '/../src/visualizers/panels');


config.rest.components['execution/logs'] = __dirname + '/../src/routers/JobLogsAPI/JobLogsAPI.js';
config.rest.components['job/origins'] = __dirname + '/../src/routers/JobOriginAPI/JobOriginAPI.js';
config.rest.components['execution/pulse'] = __dirname + '/../src/routers/ExecPulse/ExecPulse.js';
config.rest.components['JobLogsAPI'] = {
src: __dirname + '/../src/routers/JobLogsAPI/JobLogsAPI.js',
mount: 'execution/logs',
options: {}
};
config.rest.components['JobOriginAPI'] = {
src: __dirname + '/../src/routers/JobOriginAPI/JobOriginAPI.js',
mount: 'job/origins',
options: {}
};
config.rest.components['ExecPulse'] = {
src: __dirname + '/../src/routers/ExecPulse/ExecPulse.js',
mount: 'execution/pulse',
options: {}
};

// Visualizer descriptors
config.visualization.visualizerDescriptors.push(__dirname + '/../src/visualizers/Visualizers.json');
Expand All @@ -56,7 +68,14 @@ config.requirejsPaths = {
'panels/BreadcrumbHeader': './node_modules/webgme-breadcrumbheader/src/visualizers/panels/BreadcrumbHeader',
'widgets/BreadcrumbHeader': './node_modules/webgme-breadcrumbheader/',
'panels/FloatingActionButton': './node_modules/webgme-fab/src/visualizers/panels/FloatingActionButton',
'widgets/FloatingActionButton': './node_modules/webgme-fab/src/visualizers/widgets/FloatingActionButton'
'widgets/FloatingActionButton': './node_modules/webgme-fab/src/visualizers/widgets/FloatingActionButton',
'webgme-simple-nodes': './node_modules/webgme-simple-nodes/src/common',
'webgme-chflayout': './node_modules/webgme-chflayout/src/common',
'webgme-fab': './node_modules/webgme-fab/src/common',
'webgme-breadcrumbheader': './node_modules/webgme-breadcrumbheader/src/common',
'webgme-autoviz': './node_modules/webgme-autoviz/src/common',
'webgme-easydag': './node_modules/webgme-easydag/src/common',
'deepforge': './src/common'
};

config.visualization.layout.default = 'SidebarLayout';
Expand Down
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ var env = process.env.NODE_ENV || 'default',
validateConfig = require('webgme/config/validator');

validateConfig(configFilename);
module.exports = config;
module.exports = config;

0 comments on commit c516532

Please sign in to comment.