fiftyone.pipeline.core 4.3.3 → 4.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/flowData.js +7 -4
- package/package.json +1 -1
- package/pipeline.js +11 -2
- package/tests/logs-errors-and-stops.test.js +15 -3
package/flowData.js
CHANGED
|
@@ -140,13 +140,16 @@ class FlowData {
|
|
|
140
140
|
errorKey = 'other';
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
this.errors[errorKey] = error;
|
|
144
|
+
|
|
145
|
+
let logMessage = "Error occurred during processing";
|
|
146
|
+
|
|
147
|
+
if (errorKey !== undefined) {
|
|
148
|
+
logMessage = logMessage + " of " + errorKey + ". '" + error + "'";
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
this.pipeline.log('error',
|
|
151
|
+
this.pipeline.log('error', logMessage);
|
|
148
152
|
|
|
149
|
-
this.errors[errorKey].push(error);
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
/**
|
package/package.json
CHANGED
package/pipeline.js
CHANGED
|
@@ -38,13 +38,18 @@ class Pipeline {
|
|
|
38
38
|
*
|
|
39
39
|
* @param {FlowElement[]} flowElements list of FlowElements to
|
|
40
40
|
* add to the Pipeline
|
|
41
|
+
* @param {Boolean} suppressProcessExceptions If true then pipeline
|
|
42
|
+
* will suppress exceptions added to FlowData.
|
|
41
43
|
*/
|
|
42
|
-
constructor (flowElements = []) {
|
|
44
|
+
constructor (flowElements = [], suppressProcessExceptions = false) {
|
|
43
45
|
const pipeline = this;
|
|
44
46
|
|
|
45
47
|
// The chain of flowElements to run, including arrays of parallel elements
|
|
46
48
|
this.flowElementsChain = flowElements;
|
|
47
49
|
|
|
50
|
+
// If true then pipeline will suppress exceptions added to FlowData.
|
|
51
|
+
this.suppressProcessExceptions = suppressProcessExceptions;
|
|
52
|
+
|
|
48
53
|
// A logger for emitting messages
|
|
49
54
|
this.eventEmitter = new EventEmitter();
|
|
50
55
|
|
|
@@ -126,7 +131,11 @@ class Pipeline {
|
|
|
126
131
|
resolve(flowData);
|
|
127
132
|
})
|
|
128
133
|
.catch(setError);
|
|
129
|
-
|
|
134
|
+
|
|
135
|
+
if (flowData.errors !== undefined && Object.entries(flowData.errors).length !== 0 && !pipeline.suppressProcessExceptions) {
|
|
136
|
+
throw Object.values(flowData.errors)[0];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
130
139
|
};
|
|
131
140
|
};
|
|
132
141
|
|
|
@@ -35,8 +35,9 @@ const syncPipeline = new PipelineBuilder()
|
|
|
35
35
|
|
|
36
36
|
const syncFlowData = syncPipeline.createFlowData();
|
|
37
37
|
test('error data is populated', done => {
|
|
38
|
+
syncPipeline.suppressProcessExceptions = true;
|
|
38
39
|
syncFlowData.process().then(function () {
|
|
39
|
-
expect(syncFlowData.errors.error
|
|
40
|
+
expect(syncFlowData.errors.error).toBe('Something went wrong');
|
|
40
41
|
|
|
41
42
|
done();
|
|
42
43
|
});
|
|
@@ -45,17 +46,28 @@ test('error data is populated', done => {
|
|
|
45
46
|
let log;
|
|
46
47
|
|
|
47
48
|
syncPipeline.on('error', function (error) {
|
|
48
|
-
log
|
|
49
|
+
console.log(error);
|
|
50
|
+
log = error;
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
test('logging', done => {
|
|
54
|
+
syncPipeline.suppressProcessExceptions = true;
|
|
52
55
|
syncFlowData.process().then(function () {
|
|
53
|
-
expect(log).toBe('Something went wrong');
|
|
56
|
+
expect(log).toBe("Error occurred during processing of error. 'Something went wrong'");
|
|
54
57
|
|
|
55
58
|
done();
|
|
56
59
|
});
|
|
57
60
|
});
|
|
58
61
|
|
|
62
|
+
test("Don't Suppress Exception", done => {
|
|
63
|
+
syncFlowData.process().then(function () {
|
|
64
|
+
done();
|
|
65
|
+
}).catch((e) => {
|
|
66
|
+
// When an error occurs, check that the expected values are populated.
|
|
67
|
+
expect(e.indexOf('Something went wrong') !== -1).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
59
71
|
test('stop flag works', done => {
|
|
60
72
|
syncFlowData.process().then(function () {
|
|
61
73
|
try {
|