Skip to content

Commit

Permalink
Show Input/Output errors in stdout. Fixes #1327 (#1328)
Browse files Browse the repository at this point in the history
  • Loading branch information
brollb committed Nov 15, 2019
1 parent fdfa0fa commit 62e19a4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 26 deletions.
24 changes: 24 additions & 0 deletions src/common/plugin/LocalExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ define([
const outputContainer = (await this.core.loadChildren(node))
.find(cntr => this.isMetaTypeOf(cntr, this.META.Outputs));

const jobLogger = new JobLogger(this.core, this.core.getParent(node));
jobLogger.log(`Passing data reference to the ${outputs.length} subsequent jobs.`);
const dataNodes = await this.core.loadChildren(outputContainer);
const dataInfo = this.core.getAttribute(dataNodes[0], 'data');

Expand All @@ -26,6 +28,7 @@ define([
});

outputs.forEach(output => this.core.setAttribute(output, 'data', dataInfo));
jobLogger.append('Operation complete.');
};

LocalExecutor.prototype._getSaveDir = async function () {
Expand Down Expand Up @@ -71,8 +74,12 @@ define([
.find(pair => pair[0] === name && pair[1] === hash));
});

const jobLogger = new JobLogger(this.core, this.core.getParent(node));
jobLogger.log('About to save output artifacts.');
const saveDir = `${this.projectId}/artifacts/`;
const storage = await this.getStorageClient();
jobLogger.append(`Saving output data to ${storage.name}`);

const createParams = {base: this.META.Data, parent: artifactsDir};
for (let i = dataNodes.length; i--;) {
const artifact = this.core.createNode(createParams);
Expand All @@ -89,6 +96,7 @@ define([
}

this.logger.info(`Saved ${dataNodes.length} artifacts in ${this.projectId}.`);
jobLogger.append(`Saving output data to ${storage.name}`);
};

// Helper methods
Expand All @@ -110,5 +118,21 @@ define([
.filter(name => name.indexOf('_') !== 0)
.filter(name => name !== 'isLocalOperation' && name !== 'getLocalOperationType');

class JobLogger{
constructor(core, node) {
this.core = core;
this.job = node;
}

append(text) {
const stdout = this.core.getAttribute(this.job, 'stdout') + text + '\n';
this.core.setAttribute(this.job, 'stdout', stdout);
}

log(text) {
this.core.setAttribute(this.job, 'stdout', text + '\n');
}
}

return LocalExecutor;
});
13 changes: 11 additions & 2 deletions src/plugins/ExecuteJob/ExecuteJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ define([
const job = this.core.getParent(node);
const name = this.core.getAttribute(job, 'name');
const e = `Failed to retrieve "${input}" (BLOB_FETCH_FAILED)`;
let consoleErr = `[0;31mFailed to execute operation: ${e}[0m`;
let consoleErr = red(`Failed to execute operation: ${e}`);

consoleErr += [
'\n\nA couple things to check out:\n',
Expand Down Expand Up @@ -621,7 +621,7 @@ define([
}
} else { // something bad happened...
const err = `Failed to execute operation "${jobId}": ${status}`;
const consoleErr = `[0;31mFailed to execute operation: ${status}[0m`;
const consoleErr = red(`Failed to execute operation: ${status}`);

this.core.setAttribute(job, 'stdout', consoleErr);
this.logger.error(err);
Expand Down Expand Up @@ -691,6 +691,11 @@ define([
await this[type](node);
this.onOperationComplete(node);
} catch (err) {
const job = this.core.getParent(node);
const stdout = this.core.getAttribute(job, 'stdout') +
'\n' + red(err.toString());

this.core.setAttribute(job, 'stdout', stdout);
this.onOperationFail(node, err);
}
};
Expand Down Expand Up @@ -726,5 +731,9 @@ define([
ERROR.NO_STDOUT_FILE = 'Could not find logs in job results.';
ERROR.NO_TYPES_FILE = 'Metadata about result types not found.';

function red(text) {
return `${text}`;
}

return ExecuteJob;
});
33 changes: 17 additions & 16 deletions src/visualizers/panels/JobEditor/JobEditorPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ define([
'panels/OutputViewer/OutputViewerPanel',
'panels/OperationCodeEditor/OperationCodeEditorPanel',
'deepforge/viz/Execute',
'js/Constants'
'deepforge/Constants',
'js/Constants',
], function (
TilingViz,
OutputViewer,
OperationCodeEditor,
Execute,
CONSTANTS
CONSTANTS,
GME_CONSTANTS,
) {
'use strict';

Expand Down Expand Up @@ -45,30 +47,29 @@ define([
};

JobEditorPanel.prototype.selectedObjectChanged = function (nodeId) {
var node = this._client.getNode(nodeId),
typeId,
type,
typeName,
executionId,
execution;
const node = this._client.getNode(nodeId);

if (typeof nodeId === 'string') {
typeId = node.getMetaTypeId();
type = this._client.getNode(typeId);
typeName = type.getAttribute('name');
const typeId = node.getMetaTypeId();
const type = this._client.getNode(typeId);
const typeName = type.getAttribute('name');

if (typeName !== 'Job') {
this.logger.error(`Invalid node type for JobEditor: ${typeName}`);
return;
}

executionId = node.getParentId();
execution = this._client.getNode(executionId);
const executionId = node.getParentId();
const execution = this._client.getNode(executionId);

// If the current node is in a snapshotted execution, only show the log
// viewer
if (this.readOnly !== execution.getAttribute('snapshot')) {
this.readOnly = execution.getAttribute('snapshot');
const isReadOnly = execution.getAttribute('snapshot') ||
node.getAttribute('name') === CONSTANTS.OP.INPUT ||
node.getAttribute('name') === CONSTANTS.OP.OUTPUT;

if (this.readOnly !== isReadOnly) {
this.readOnly = isReadOnly;
this.logger.info(`readonly set to ${this.readOnly}`);
this.updatePanels();
}
Expand Down Expand Up @@ -104,7 +105,7 @@ define([

JobEditorPanel.prototype.onOperationEvents = function (events) {
var event = events.find(event => {
if (event.etype === CONSTANTS.TERRITORY_EVENT_LOAD) {
if (event.etype === GME_CONSTANTS.TERRITORY_EVENT_LOAD) {
// Check if the eid is an Operation
var typeId = this._client.getNode(event.eid).getMetaTypeId(),
type = this._client.getNode(typeId),
Expand Down
9 changes: 1 addition & 8 deletions src/visualizers/widgets/ExecutionView/SelectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
define([
'widgets/EasyDAG/SelectionManager',
'widgets/EasyDAG/Buttons',
'deepforge/Constants',
'underscore'
], function(
EasyDAGSelectionManager,
Buttons,
CONSTANTS,
_
) {
'use strict';
Expand All @@ -20,12 +18,7 @@ define([
_.extend(SelectionManager.prototype, EasyDAGSelectionManager.prototype);

SelectionManager.prototype.createActionButtons = function(width/*, height*/) {
var jobName = this.selectedItem.desc.name;

// Check if it is an Input or Output job
if (!this.selectedItem.isConnection && jobName !== CONSTANTS.OP.INPUT &&
jobName !== CONSTANTS.OP.OUTPUT) {

if (!this.selectedItem.isConnection) {
new Buttons.Enter({
context: this._widget,
$pEl: this.$selection,
Expand Down

0 comments on commit 62e19a4

Please sign in to comment.