-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
WIP #519 Added saving image file on worker WIP #519 Added wrapper for the intermediate data results WIP #519 filename->name and silenced blobClient logs WIP #519 Removed old debug log WIP #519 Added Image metadata creation WIP #519 Added ImageViewer WIP #519 Added zoom fn-ality WIP #519 Added 'Image' node WIP #519 Updated pipeline libraries WIP #519 Added 'image' to deepforge autocomplete WIP #519 Added no-image image WIP #519 Fixed image updating WIP #519 Added better origin url detection WIP #519 Fixed code climate issues WIP #519 fixed code climate issues
- Loading branch information
Showing
17 changed files
with
524 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// A wrapper for the torch script which: | ||
// - merges stdout, stderr | ||
// - receives some commands and uploads intermediate data | ||
var spawn = require('child_process').spawn, | ||
fs = require('fs'), | ||
log = console.error, | ||
logger = {}; | ||
|
||
// Create the stderr only logger | ||
['error', 'warn', 'info', 'log', 'debug'].forEach(method => logger[method] = log); | ||
|
||
// Get the BlobClient... | ||
var COMMAND_PREFIX = '<%= START_CMD %>', | ||
IMAGE = '<%= IMAGE %>', | ||
requirejs = require('webgme').requirejs; | ||
|
||
requirejs([ | ||
'blob/BlobClient' | ||
], function( | ||
BlobClient | ||
) { | ||
var url = process.env.ORIGIN_URL || 'http://127.0.0.1:8888', | ||
protocol = url.split('://').shift(), | ||
address, | ||
port = (url.split(':') || ['80']).pop(); | ||
|
||
address = url.replace(protocol + '://', '') | ||
.replace(':' + port, ''); | ||
|
||
var blobClient = new BlobClient({ | ||
server: address, | ||
httpsecure: protocol === 'https', | ||
serverPort: port, | ||
logger: logger | ||
}); | ||
|
||
var uploadImage = function(line) { | ||
var args = line.split(/\s+/), | ||
name = args.slice(2).join(' ').replace(/\s+$/, ''), | ||
filename = 'metadata/' + name + '.png'; | ||
|
||
// Upload the image from metadata/ | ||
fs.readFile(filename, (err, content) => { | ||
if (err) { | ||
console.error(`Could not read ${filename}: ${err}`); | ||
return; | ||
} | ||
|
||
// Add hash to the image command | ||
blobClient.putFile(filename, content) | ||
.then(hash => { | ||
args.splice(2, 0, hash); | ||
console.log(args.join(' ')); | ||
}) | ||
.fail(err => console.error(`${filename} upload failed: ${err}`)); | ||
}); | ||
}; | ||
|
||
var onStdout = function(data) { | ||
var lines = data.toString().split('\n'), | ||
result = [], | ||
cmdStart; | ||
|
||
// Check for commands... | ||
for (var i = 0; i < lines.length; i++) { | ||
cmdStart = lines[i].indexOf(COMMAND_PREFIX); | ||
if (cmdStart !== -1 && lines[i].indexOf(IMAGE) !== -1) { | ||
uploadImage(lines[i]); | ||
} else { | ||
result.push(lines[i]); | ||
} | ||
} | ||
|
||
process.stdout.write(result.join('\n')); | ||
}; | ||
|
||
// Run 'th init.lua' and merge the stdout, stderr | ||
var job = spawn('th', ['init.lua']); | ||
job.stdout.on('data', onStdout); | ||
job.stderr.on('data', data => process.stdout.write(data)); | ||
}); |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.