fiftyone.pipeline.core 4.3.3 → 4.3.7

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.
@@ -48,7 +48,7 @@ const testExample = function ({ file, portNumber }) {
48
48
 
49
49
  code += serverClose;
50
50
 
51
- jest.fn(eval(code));
51
+ () => jest.fn(eval(code));
52
52
  };
53
53
 
54
54
  test('pipeline functionality example', () => {
package/flowData.js CHANGED
@@ -140,13 +140,16 @@ class FlowData {
140
140
  errorKey = 'other';
141
141
  }
142
142
 
143
- if (!this.errors[errorKey]) {
144
- this.errors[errorKey] = [];
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', { message: error, source: errorKey });
151
+ this.pipeline.log('error', logMessage);
148
152
 
149
- this.errors[errorKey].push(error);
150
153
  }
151
154
 
152
155
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fiftyone.pipeline.core",
3
- "version": "4.3.3",
3
+ "version": "4.3.7",
4
4
  "description": "Core library for the 51Degrees Pipeline API",
5
5
  "directories": {
6
6
  "test": "tests"
@@ -24,8 +24,8 @@
24
24
  "eslint-plugin-node": "^11.1.0",
25
25
  "eslint-plugin-promise": "^4.2.1",
26
26
  "eslint-plugin-standard": "^4.0.1",
27
- "jest": "^24.9.0",
28
- "jest-each": "^26.6.2",
27
+ "jest": "^27.0.6",
28
+ "jest-each": "^27.0.6",
29
29
  "node-mocks-http": "^1.10.1"
30
30
  },
31
31
  "contributors": [
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
 
@@ -141,7 +141,9 @@ const AspectPropertyValue = require('./aspectPropertyValue');
141
141
  headerValue += value;
142
142
  }
143
143
  });
144
- result[header.name] = headerValue;
144
+ if (headerValue !== '') {
145
+ result[header.name] = headerValue;
146
+ }
145
147
  }
146
148
  return result;
147
149
  }
@@ -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[0]).toBe('Something went wrong');
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 = error.message;
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 {
@@ -57,6 +57,9 @@ const pipeline = new PipelineBuilder()
57
57
  *
58
58
  */
59
59
  each([
60
+ ["Ignore all unknown values.",
61
+ { "SetHeaderBrowserAccept-CH": unknownValue, "SetHeaderPlatformAccept-CH": unknownValue, "SetHeaderHardwareAccept-CH": unknownValue},
62
+ { "Accept-CH": "nil"}],
60
63
  ["Ignore unknown values.",
61
64
  { "SetHeaderBrowserAccept-CH": unknownValue, "SetHeaderPlatformAccept-CH": unknownValue, "SetHeaderHardwareAccept-CH": testValue},
62
65
  { "Accept-CH": "test"}],
@@ -74,7 +77,7 @@ each([
74
77
  { "Accept-CH": browserValue.value}],
75
78
  ["Undefined value.",
76
79
  { "SetHeaderBrowserAccept-CH": undefined},
77
- { "Accept-CH": ""}],
80
+ { "Accept-CH": "nil"}],
78
81
  ["Set multiple headers.",
79
82
  { "SetHeaderBrowserAccept-CH": browserValue, "SetHeaderHardwareSomeOtherHeader": platformValue},
80
83
  { "Accept-CH": browserValue.value, "SomeOtherHeader": platformValue.value}],
@@ -90,7 +93,12 @@ each([
90
93
  Helpers.setResponseHeaders(response, result);
91
94
  // Check the correct headers were added to the response.
92
95
  for (const [key, value] of Object.entries(expectedHeaders)) {
93
- expect(response.getHeader(key)).toBe(value);
96
+ if (value === "nil") {
97
+ expect(response.getHeader("Accept-CH")).toBe(undefined)
98
+ }
99
+ else {
100
+ expect(response.getHeader(key)).toBe(value);
101
+ }
94
102
  }
95
103
 
96
104
  });