@datagrok/compute 1.45.3 → 1.46.0
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/.turbo/turbo-build.log +10 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE.md +16 -0
- package/dist/package-test.js +179 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +170 -1
- package/dist/package.js.map +1 -1
- package/package.json +21 -51
- package/src/package-api.ts +6 -6
- package/src/package.ts +0 -4
- package/src/tests/rich-function-view-direct-tests.ts +24 -33
- package/src/tests/rich-function-view-tests.ts +24 -33
- package/src/tests/utils.ts +33 -0
- package/test-console-output-1.log +230 -0
- package/test-record-1.mp4 +0 -0
- package/tsconfig.json +4 -70
- package/webpack.config.js +3 -69
- package/.eslintrc.json +0 -47
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/compute",
|
|
3
3
|
"friendlyName": "Compute",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.46.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Andrey Sharapov",
|
|
7
7
|
"email": "andrey.sharapov@softwarecountry.com"
|
|
@@ -13,52 +13,23 @@
|
|
|
13
13
|
"directory": "packages/Compute"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"datagrok-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
16
|
+
"cash-dom": "8.1.5",
|
|
17
|
+
"dayjs": "1.11.23",
|
|
18
|
+
"exceljs": "4.4.0",
|
|
19
|
+
"rxjs": "6.6.7",
|
|
20
|
+
"@datagrok-libraries/compute-api": "^0.8.0",
|
|
21
|
+
"@datagrok-libraries/test": "^1.6.0",
|
|
22
|
+
"datagrok-api": "^1.28.1",
|
|
23
|
+
"@datagrok-libraries/compute-utils": "^1.48.0",
|
|
24
|
+
"@datagrok-libraries/utils": "^4.8.0"
|
|
25
|
+
},
|
|
26
|
+
"overrides": {
|
|
27
|
+
"uuid": "^11.1.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/lodash.clonedeepwith": "^4.5.9",
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"css-loader": "^7.1.2",
|
|
34
|
-
"datagrok-tools": "^5.0.0",
|
|
35
|
-
"eslint": "^8.0.1",
|
|
36
|
-
"eslint-config-google": "^0.14.0",
|
|
37
|
-
"style-loader": "^4.0.0",
|
|
38
|
-
"webpack": "^5.95.0",
|
|
39
|
-
"webpack-bundle-analyzer": "^4.10.2",
|
|
40
|
-
"webpack-cli": "^5.1.4"
|
|
41
|
-
},
|
|
42
|
-
"scripts": {
|
|
43
|
-
"link-api": "npm link datagrok-api",
|
|
44
|
-
"link-utils": "npm link @datagrok-libraries/utils",
|
|
45
|
-
"link-all": "npm link datagrok-api @datagrok-libraries/compute-utils",
|
|
46
|
-
"debug-compute": "webpack & grok publish localhost --release",
|
|
47
|
-
"release-compute": "webpack && grok publish localhost --release",
|
|
48
|
-
"build-compute": "webpack",
|
|
49
|
-
"build": "grok api && grok check --soft && webpack",
|
|
50
|
-
"lint": "eslint . --ext .ts,.tsx",
|
|
51
|
-
"lint-fix": "eslint . --ext .ts,.tsx --fix",
|
|
52
|
-
"build-compute-local": "npm --prefix ./../../js-api run build && npm --prefix ./../../libraries/utils run build && npm run build",
|
|
53
|
-
"debug-compute-dev": "webpack && grok publish dev",
|
|
54
|
-
"release-compute-dev": "grok publish dev --release",
|
|
55
|
-
"debug-compute-local": "grok publish local",
|
|
56
|
-
"release-compute-local": "grok publish local --release",
|
|
57
|
-
"debug-compute-localhost": "grok publish localhost",
|
|
58
|
-
"release-compute-localhost": "grok publish localhost --release",
|
|
59
|
-
"debug-compute-compose": "grok publish compose",
|
|
60
|
-
"release-compute-compose": "grok publish compose --release",
|
|
61
|
-
"build-all": "npm --prefix ./../../js-api run build && npm --prefix ./../../libraries/compute-utils run build && npm run build"
|
|
31
|
+
"@types/wu": "^2.1.44",
|
|
32
|
+
"webpack-bundle-analyzer": "^4.10.2"
|
|
62
33
|
},
|
|
63
34
|
"canEdit": [
|
|
64
35
|
"Administrators"
|
|
@@ -67,11 +38,10 @@
|
|
|
67
38
|
"All users"
|
|
68
39
|
],
|
|
69
40
|
"category": "Compute",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
"uuid": "^11.1.1"
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "grok build",
|
|
43
|
+
"typecheck": "grok tsc --noEmit -p tsconfig.json",
|
|
44
|
+
"lint": "eslint --ext .ts,.tsx src",
|
|
45
|
+
"test": "grok test"
|
|
76
46
|
}
|
|
77
|
-
}
|
|
47
|
+
}
|
package/src/package-api.ts
CHANGED
|
@@ -13,15 +13,15 @@ export namespace scripts {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
* Identify the beats in an ECG signal and compute the IBIs
|
|
17
|
+
*/
|
|
18
18
|
export async function intervalsFromECG(samplingFrequency: number , bpmMax: number , delta: number , k: number ): Promise<any> {
|
|
19
19
|
return await grok.functions.call('Compute:IntervalsFromECG', { samplingFrequency, bpmMax, delta, k });
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
* Predict the minimum filter size required for the separation of effluent from bioreactors, given the constraints of batch size and total batch time based on a training dataset of time vs filtrate volume for a given filter type, filter area and pressure
|
|
24
|
+
*/
|
|
25
25
|
export async function vmax(test_data: DG.DataFrame , test_area: number , vbatch: number , tbatch: number , sf: number ): Promise<{processedData: DG.DataFrame, vmax: number, q0: number, slope_est: number, slope_err: number, icept_est: number, icept_err: number, rsq: number, f_stat: number, df: number, sigma: number, resid_ss: number, expl_ss: number, ss_tot: number, amin: number}> {
|
|
26
26
|
return await grok.functions.call('Compute:Vmax', { test_data, test_area, vbatch, tbatch, sf });
|
|
27
27
|
}
|
|
@@ -37,8 +37,8 @@ export namespace funcs {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
* Creates an outliers selection viewer
|
|
41
|
+
*/
|
|
42
42
|
export async function outliersSelection(): Promise<any> {
|
|
43
43
|
return await grok.functions.call('Compute:OutliersSelection', {});
|
|
44
44
|
}
|
package/src/package.ts
CHANGED
|
@@ -20,9 +20,6 @@ import {
|
|
|
20
20
|
mergeValidationResults as mergeValidationResultsInst,
|
|
21
21
|
} from '@datagrok-libraries/compute-utils';
|
|
22
22
|
import {ModelHandler} from '@datagrok-libraries/compute-utils/model-catalog';
|
|
23
|
-
import {
|
|
24
|
-
testPipeline as testPipelineInst,
|
|
25
|
-
} from '@datagrok-libraries/compute-utils';
|
|
26
23
|
import {
|
|
27
24
|
deepCopy as deepCopyInst,
|
|
28
25
|
} from '@datagrok-libraries/compute-utils';
|
|
@@ -63,7 +60,6 @@ class InputMock implements FuncCallInput {
|
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
// for compute-api pakage
|
|
66
|
-
export const testPipeline = testPipelineInst;
|
|
67
63
|
export const deepCopy = deepCopyInst;
|
|
68
64
|
export const CompView = ComputationViewInst;
|
|
69
65
|
export const RFV = RichFunctionViewInst;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
|
-
import {category, test, before
|
|
2
|
+
import {category, test, before} from '@datagrok-libraries/test/src/test';
|
|
3
3
|
import {RichFunctionView} from '@datagrok-libraries/compute-utils';
|
|
4
4
|
import {take, filter} from 'rxjs/operators';
|
|
5
5
|
import {applyTransformations} from '@datagrok-libraries/utils/src/json-serialization';
|
|
6
|
-
import {getFuncCallIO} from './utils';
|
|
6
|
+
import {getFuncCallIO, inputsRendered, inputsApplied, eventually} from './utils';
|
|
7
7
|
import {expectDeepEqual} from '@datagrok-libraries/utils/src/expect';
|
|
8
8
|
import {InputVariants} from '@datagrok-libraries/compute-utils/old-views/src/rich-function-view';
|
|
9
9
|
import fc1 from './snapshots/fc1.json';
|
|
@@ -58,13 +58,13 @@ category('Compute: RichFunctionView Inputs', async () => {
|
|
|
58
58
|
inputsMap[prop.name] = input;
|
|
59
59
|
});
|
|
60
60
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
61
|
-
await
|
|
61
|
+
await inputsRendered(view, inputsMap);
|
|
62
62
|
for (const [name, input] of Object.entries(inputsMap)) {
|
|
63
63
|
input.value = inputValues[name];
|
|
64
64
|
const element = (input as any).input;
|
|
65
65
|
element.dispatchEvent(new Event('input', {bubbles: true}));
|
|
66
66
|
}
|
|
67
|
-
await
|
|
67
|
+
await inputsApplied(view, inputValues);
|
|
68
68
|
await view.doRun();
|
|
69
69
|
const expected = {
|
|
70
70
|
'inputs': [
|
|
@@ -95,7 +95,7 @@ category('Compute: RichFunctionView Inputs', async () => {
|
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
98
|
-
await
|
|
98
|
+
await inputsRendered(view, inputsMap);
|
|
99
99
|
await view.doRun();
|
|
100
100
|
view.funcCall.setParamValue('a', 2);
|
|
101
101
|
view.funcCall.setParamValue('b', 3.2);
|
|
@@ -131,15 +131,14 @@ category('Compute: RichFunctionView Inputs', async () => {
|
|
|
131
131
|
inputsMap[prop.name] = input;
|
|
132
132
|
});
|
|
133
133
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
134
|
-
await
|
|
134
|
+
await inputsRendered(view, inputsMap);
|
|
135
135
|
await view.doRun();
|
|
136
|
-
await delay(100);
|
|
137
136
|
for (const [name, input] of Object.entries(inputsMap)) {
|
|
138
137
|
input.value = inputValues[name];
|
|
139
138
|
const element = (input as any).input;
|
|
140
139
|
element.dispatchEvent(new Event('input', {bubbles: true}));
|
|
141
140
|
}
|
|
142
|
-
await
|
|
141
|
+
await inputsApplied(view, inputValues);
|
|
143
142
|
await view.doRun();
|
|
144
143
|
const expected = {
|
|
145
144
|
'inputs': [
|
|
@@ -161,7 +160,6 @@ category('Compute: RichFunctionView Inputs', async () => {
|
|
|
161
160
|
const view = new RichFunctionView('Compute:simpleInputsDefaultValues', {historyEnabled: false, isTabbed: false});
|
|
162
161
|
|
|
163
162
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
164
|
-
await delay(100);
|
|
165
163
|
const expected = {
|
|
166
164
|
'inputs': [
|
|
167
165
|
['a', 1],
|
|
@@ -169,7 +167,7 @@ category('Compute: RichFunctionView Inputs', async () => {
|
|
|
169
167
|
['c', 'test'],
|
|
170
168
|
],
|
|
171
169
|
};
|
|
172
|
-
expectDeepEqual(getFuncCallIO(view.funcCall).inputs, expected.inputs);
|
|
170
|
+
await eventually(() => expectDeepEqual(getFuncCallIO(view.funcCall).inputs, expected.inputs));
|
|
173
171
|
});
|
|
174
172
|
|
|
175
173
|
test('Complex inputs setParamValue', async () => {
|
|
@@ -205,10 +203,10 @@ category('Compute: RichFunctionView Inputs', async () => {
|
|
|
205
203
|
inputsMap[prop.name] = input;
|
|
206
204
|
});
|
|
207
205
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
208
|
-
await
|
|
206
|
+
await inputsRendered(view, inputsMap);
|
|
209
207
|
inputsMap['data'].value = inputValues['data'];
|
|
210
208
|
view.funcCall.setParamValue('df', inputValues['df']);
|
|
211
|
-
await
|
|
209
|
+
await inputsApplied(view, inputValues);
|
|
212
210
|
await view.doRun();
|
|
213
211
|
expectDeepEqual(getFuncCallIO(view.funcCall), applyTransformations(fc1), {prefix: 'funcCall'});
|
|
214
212
|
expectDeepEqual(getFuncCallIO(view.lastCall!), applyTransformations(fc1), {prefix: 'lastCall'});
|
|
@@ -258,10 +256,10 @@ category('Compute: RichFunctionView Inputs', async () => {
|
|
|
258
256
|
inputsMap[prop.name] = input;
|
|
259
257
|
});
|
|
260
258
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
261
|
-
await
|
|
259
|
+
await inputsRendered(view, inputsMap);
|
|
262
260
|
inputsMap['data'].value = inputValuesPre['data'];
|
|
263
261
|
view.funcCall.setParamValue('df', inputValuesPre['df']);
|
|
264
|
-
await
|
|
262
|
+
await inputsApplied(view, inputValuesPre);
|
|
265
263
|
await view.doRun();
|
|
266
264
|
const inputValues: Record<string, any> = {
|
|
267
265
|
df: DG.DataFrame.fromColumns([
|
|
@@ -271,7 +269,7 @@ category('Compute: RichFunctionView Inputs', async () => {
|
|
|
271
269
|
};
|
|
272
270
|
inputsMap['data'].value = inputValues['data'];
|
|
273
271
|
view.funcCall.setParamValue('df', inputValues['df']);
|
|
274
|
-
await
|
|
272
|
+
await inputsApplied(view, inputValues);
|
|
275
273
|
await view.doRun();
|
|
276
274
|
expectDeepEqual(getFuncCallIO(view.funcCall), applyTransformations(fc1), {prefix: 'funcCall'});
|
|
277
275
|
expectDeepEqual(getFuncCallIO(view.lastCall!), applyTransformations(fc1), {prefix: 'lastCall'});
|
|
@@ -286,10 +284,8 @@ category('Compute: RichFunctionView Validation', async () => {
|
|
|
286
284
|
test('Validate on start', async () => {
|
|
287
285
|
const view = new RichFunctionView('Compute:validationTest', {historyEnabled: false, isTabbed: false});
|
|
288
286
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
289
|
-
await
|
|
290
|
-
|
|
291
|
-
expectDeepEqual(
|
|
292
|
-
results,
|
|
287
|
+
await eventually(() => expectDeepEqual(
|
|
288
|
+
view.getValidationState(),
|
|
293
289
|
{
|
|
294
290
|
'a': {
|
|
295
291
|
'errors': [
|
|
@@ -321,7 +317,7 @@ category('Compute: RichFunctionView Validation', async () => {
|
|
|
321
317
|
'context': {},
|
|
322
318
|
},
|
|
323
319
|
},
|
|
324
|
-
);
|
|
320
|
+
));
|
|
325
321
|
});
|
|
326
322
|
|
|
327
323
|
test('Validate on input', async () => {
|
|
@@ -336,17 +332,14 @@ category('Compute: RichFunctionView Validation', async () => {
|
|
|
336
332
|
inputsMap[prop.name] = input;
|
|
337
333
|
});
|
|
338
334
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
339
|
-
await
|
|
335
|
+
await inputsRendered(view, inputsMap);
|
|
340
336
|
for (const [name, input] of Object.entries(inputsMap)) {
|
|
341
337
|
input.value = inputValues[name];
|
|
342
338
|
const element = (input as any).input;
|
|
343
339
|
element.dispatchEvent(new Event('input', {bubbles: true}));
|
|
344
340
|
}
|
|
345
|
-
await
|
|
346
|
-
|
|
347
|
-
const results = view.getValidationState();
|
|
348
|
-
expectDeepEqual(
|
|
349
|
-
results,
|
|
341
|
+
await eventually(() => expectDeepEqual(
|
|
342
|
+
view.getValidationState(),
|
|
350
343
|
{
|
|
351
344
|
'b': {
|
|
352
345
|
'errors': [
|
|
@@ -354,7 +347,7 @@ category('Compute: RichFunctionView Validation', async () => {
|
|
|
354
347
|
],
|
|
355
348
|
},
|
|
356
349
|
},
|
|
357
|
-
);
|
|
350
|
+
));
|
|
358
351
|
});
|
|
359
352
|
|
|
360
353
|
test('Revalidation sequence', async () => {
|
|
@@ -369,16 +362,14 @@ category('Compute: RichFunctionView Validation', async () => {
|
|
|
369
362
|
inputsMap[prop.name] = input;
|
|
370
363
|
});
|
|
371
364
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
372
|
-
await
|
|
365
|
+
await inputsRendered(view, inputsMap);
|
|
373
366
|
for (const [name, input] of Object.entries(inputsMap)) {
|
|
374
367
|
input.value = inputValues[name];
|
|
375
368
|
const element = (input as any).input;
|
|
376
369
|
element.dispatchEvent(new Event('input', {bubbles: true}));
|
|
377
370
|
}
|
|
378
|
-
await
|
|
379
|
-
|
|
380
|
-
expectDeepEqual(
|
|
381
|
-
results,
|
|
371
|
+
await eventually(() => expectDeepEqual(
|
|
372
|
+
view.getValidationState(),
|
|
382
373
|
{
|
|
383
374
|
'a': {
|
|
384
375
|
'revalidate': ['b', 'c'],
|
|
@@ -398,6 +389,6 @@ category('Compute: RichFunctionView Validation', async () => {
|
|
|
398
389
|
],
|
|
399
390
|
},
|
|
400
391
|
},
|
|
401
|
-
);
|
|
392
|
+
));
|
|
402
393
|
});
|
|
403
394
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
|
-
import {category, test, before
|
|
2
|
+
import {category, test, before} from '@datagrok-libraries/test/src/test';
|
|
3
3
|
import {createRFV, initComputeApi} from '@datagrok-libraries/compute-api';
|
|
4
4
|
import {take, filter} from 'rxjs/operators';
|
|
5
5
|
import {applyTransformations} from '@datagrok-libraries/utils/src/json-serialization';
|
|
6
|
-
import {getFuncCallIO} from './utils';
|
|
6
|
+
import {getFuncCallIO, inputsRendered, inputsApplied, eventually} from './utils';
|
|
7
7
|
import {expectDeepEqual} from '@datagrok-libraries/utils/src/expect';
|
|
8
8
|
import fc1 from './snapshots/fc1.json';
|
|
9
9
|
import {InputVariants} from '@datagrok-libraries/compute-utils/old-views/src/rich-function-view';
|
|
@@ -77,13 +77,13 @@ category('Compute API: RFV Inputs', async () => {
|
|
|
77
77
|
inputsMap[prop.name] = input;
|
|
78
78
|
});
|
|
79
79
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
80
|
-
await
|
|
80
|
+
await inputsRendered(view, inputsMap);
|
|
81
81
|
for (const [name, input] of Object.entries(inputsMap)) {
|
|
82
82
|
input.value = inputValues[name];
|
|
83
83
|
const element = (input as any).input;
|
|
84
84
|
element.dispatchEvent(new Event('input', {bubbles: true}));
|
|
85
85
|
}
|
|
86
|
-
await
|
|
86
|
+
await inputsApplied(view, inputValues);
|
|
87
87
|
await view.doRun();
|
|
88
88
|
const expected = {
|
|
89
89
|
'inputs': [
|
|
@@ -132,7 +132,7 @@ category('Compute API: RFV Inputs', async () => {
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
135
|
-
await
|
|
135
|
+
await inputsRendered(view, inputsMap);
|
|
136
136
|
await view.doRun();
|
|
137
137
|
view.funcCall.setParamValue('a', 2);
|
|
138
138
|
view.funcCall.setParamValue('b', 3.2);
|
|
@@ -186,15 +186,14 @@ category('Compute API: RFV Inputs', async () => {
|
|
|
186
186
|
inputsMap[prop.name] = input;
|
|
187
187
|
});
|
|
188
188
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
189
|
-
await
|
|
189
|
+
await inputsRendered(view, inputsMap);
|
|
190
190
|
await view.doRun();
|
|
191
|
-
await delay(100);
|
|
192
191
|
for (const [name, input] of Object.entries(inputsMap)) {
|
|
193
192
|
input.value = inputValues[name];
|
|
194
193
|
const element = (input as any).input;
|
|
195
194
|
element.dispatchEvent(new Event('input', {bubbles: true}));
|
|
196
195
|
}
|
|
197
|
-
await
|
|
196
|
+
await inputsApplied(view, inputValues);
|
|
198
197
|
await view.doRun();
|
|
199
198
|
const expected = {
|
|
200
199
|
'inputs': [
|
|
@@ -234,7 +233,6 @@ category('Compute API: RFV Inputs', async () => {
|
|
|
234
233
|
const view = createRFV('Compute:simpleInputsDefaultValues', {historyEnabled: false, isTabbed: false});
|
|
235
234
|
|
|
236
235
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
237
|
-
await delay(100);
|
|
238
236
|
const expected = {
|
|
239
237
|
'inputs': [
|
|
240
238
|
[
|
|
@@ -251,7 +249,7 @@ category('Compute API: RFV Inputs', async () => {
|
|
|
251
249
|
],
|
|
252
250
|
],
|
|
253
251
|
};
|
|
254
|
-
expectDeepEqual(getFuncCallIO(view.funcCall).inputs, expected.inputs);
|
|
252
|
+
await eventually(() => expectDeepEqual(getFuncCallIO(view.funcCall).inputs, expected.inputs));
|
|
255
253
|
});
|
|
256
254
|
|
|
257
255
|
test('Complex inputs setParamValue', async () => {
|
|
@@ -287,11 +285,11 @@ category('Compute API: RFV Inputs', async () => {
|
|
|
287
285
|
inputsMap[prop.name] = input;
|
|
288
286
|
});
|
|
289
287
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
290
|
-
await
|
|
288
|
+
await inputsRendered(view, inputsMap);
|
|
291
289
|
inputsMap['data'].value = inputValues['data'];
|
|
292
290
|
// TODO: test df input, not rly used rn
|
|
293
291
|
view.funcCall.setParamValue('df', inputValues['df']);
|
|
294
|
-
await
|
|
292
|
+
await inputsApplied(view, inputValues);
|
|
295
293
|
await view.doRun();
|
|
296
294
|
expectDeepEqual(getFuncCallIO(view.funcCall), applyTransformations(fc1), {prefix: 'funcCall'});
|
|
297
295
|
expectDeepEqual(getFuncCallIO(view.lastCall!), applyTransformations(fc1), {prefix: 'lastCall'});
|
|
@@ -341,11 +339,11 @@ category('Compute API: RFV Inputs', async () => {
|
|
|
341
339
|
inputsMap[prop.name] = input;
|
|
342
340
|
});
|
|
343
341
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
344
|
-
await
|
|
342
|
+
await inputsRendered(view, inputsMap);
|
|
345
343
|
inputsMap['data'].value = inputValuesPre['data'];
|
|
346
344
|
// TODO: test df input, not rly used rn
|
|
347
345
|
view.funcCall.setParamValue('df', inputValuesPre['df']);
|
|
348
|
-
await
|
|
346
|
+
await inputsApplied(view, inputValuesPre);
|
|
349
347
|
await view.doRun();
|
|
350
348
|
const inputValues: Record<string, any> = {
|
|
351
349
|
df: DG.DataFrame.fromColumns([
|
|
@@ -356,7 +354,7 @@ category('Compute API: RFV Inputs', async () => {
|
|
|
356
354
|
inputsMap['data'].value = inputValues['data'];
|
|
357
355
|
// TODO: test df input, not rly used rn
|
|
358
356
|
view.funcCall.setParamValue('df', inputValues['df']);
|
|
359
|
-
await
|
|
357
|
+
await inputsApplied(view, inputValues);
|
|
360
358
|
await view.doRun();
|
|
361
359
|
expectDeepEqual(getFuncCallIO(view.funcCall), applyTransformations(fc1), {prefix: 'funcCall'});
|
|
362
360
|
expectDeepEqual(getFuncCallIO(view.lastCall!), applyTransformations(fc1), {prefix: 'lastCall'});
|
|
@@ -372,10 +370,8 @@ category('Compute API: RFV Validation', async () => {
|
|
|
372
370
|
test('Validate on start', async () => {
|
|
373
371
|
const view = createRFV('Compute:validationTest', {historyEnabled: false, isTabbed: false});
|
|
374
372
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
375
|
-
await
|
|
376
|
-
|
|
377
|
-
expectDeepEqual(
|
|
378
|
-
results,
|
|
373
|
+
await eventually(() => expectDeepEqual(
|
|
374
|
+
view.getValidationState(),
|
|
379
375
|
{
|
|
380
376
|
'a': {
|
|
381
377
|
'errors': [
|
|
@@ -417,7 +413,7 @@ category('Compute API: RFV Validation', async () => {
|
|
|
417
413
|
'context': {},
|
|
418
414
|
},
|
|
419
415
|
},
|
|
420
|
-
);
|
|
416
|
+
));
|
|
421
417
|
});
|
|
422
418
|
|
|
423
419
|
test('Validate on input', async () => {
|
|
@@ -432,17 +428,14 @@ category('Compute API: RFV Validation', async () => {
|
|
|
432
428
|
inputsMap[prop.name] = input;
|
|
433
429
|
});
|
|
434
430
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
435
|
-
await
|
|
431
|
+
await inputsRendered(view, inputsMap);
|
|
436
432
|
for (const [name, input] of Object.entries(inputsMap)) {
|
|
437
433
|
input.value = inputValues[name];
|
|
438
434
|
const element = (input as any).input;
|
|
439
435
|
element.dispatchEvent(new Event('input', {bubbles: true}));
|
|
440
436
|
}
|
|
441
|
-
await
|
|
442
|
-
|
|
443
|
-
const results = view.getValidationState();
|
|
444
|
-
expectDeepEqual(
|
|
445
|
-
results,
|
|
437
|
+
await eventually(() => expectDeepEqual(
|
|
438
|
+
view.getValidationState(),
|
|
446
439
|
{
|
|
447
440
|
'b': {
|
|
448
441
|
'errors': [
|
|
@@ -452,7 +445,7 @@ category('Compute API: RFV Validation', async () => {
|
|
|
452
445
|
],
|
|
453
446
|
},
|
|
454
447
|
},
|
|
455
|
-
);
|
|
448
|
+
));
|
|
456
449
|
});
|
|
457
450
|
|
|
458
451
|
test('Revalidation sequence', async () => {
|
|
@@ -467,16 +460,14 @@ category('Compute API: RFV Validation', async () => {
|
|
|
467
460
|
inputsMap[prop.name] = input;
|
|
468
461
|
});
|
|
469
462
|
await view.isReady.pipe(filter((x) => x), take(1)).toPromise();
|
|
470
|
-
await
|
|
463
|
+
await inputsRendered(view, inputsMap);
|
|
471
464
|
for (const [name, input] of Object.entries(inputsMap)) {
|
|
472
465
|
input.value = inputValues[name];
|
|
473
466
|
const element = (input as any).input;
|
|
474
467
|
element.dispatchEvent(new Event('input', {bubbles: true}));
|
|
475
468
|
}
|
|
476
|
-
await
|
|
477
|
-
|
|
478
|
-
expectDeepEqual(
|
|
479
|
-
results,
|
|
469
|
+
await eventually(() => expectDeepEqual(
|
|
470
|
+
view.getValidationState(),
|
|
480
471
|
{
|
|
481
472
|
'a': {
|
|
482
473
|
'revalidate': [
|
|
@@ -507,6 +498,6 @@ category('Compute API: RFV Validation', async () => {
|
|
|
507
498
|
],
|
|
508
499
|
},
|
|
509
500
|
},
|
|
510
|
-
);
|
|
501
|
+
));
|
|
511
502
|
});
|
|
512
503
|
});
|
package/src/tests/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
|
+
import {waitUntil} from '@datagrok-libraries/test/src/test';
|
|
2
3
|
|
|
3
4
|
export function getFuncCallIO(fc: DG.FuncCall) {
|
|
4
5
|
return {
|
|
@@ -6,3 +7,35 @@ export function getFuncCallIO(fc: DG.FuncCall) {
|
|
|
6
7
|
outputs: [...fc.outputs.entries()],
|
|
7
8
|
};
|
|
8
9
|
}
|
|
10
|
+
|
|
11
|
+
/** Resolves once the view has rendered an input for each input of its function. */
|
|
12
|
+
export async function inputsRendered(view: {funcCall: DG.FuncCall}, inputsMap: Record<string, unknown>): Promise<void> {
|
|
13
|
+
await waitUntil(() => view.funcCall.func.inputs.every((p) => inputsMap[p.name] != null),
|
|
14
|
+
() => `inputs not rendered: ${view.funcCall.func.inputs.map((p) => p.name).filter((n) => inputsMap[n] == null)}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Resolves once the view's call holds [values]: an input passes its value on after a validation debounce. */
|
|
18
|
+
export async function inputsApplied(view: {funcCall: DG.FuncCall}, values: Record<string, any>): Promise<void> {
|
|
19
|
+
// a dataframe comes back in a new wrapper on every read
|
|
20
|
+
const holds = (name: string) => values[name] instanceof DG.DataFrame ?
|
|
21
|
+
view.funcCall.inputs[name]?.dart === values[name].dart : view.funcCall.inputs[name] === values[name];
|
|
22
|
+
await waitUntil(() => Object.keys(values).every(holds),
|
|
23
|
+
() => `the call did not take the inputs: ${JSON.stringify(Object.keys(values).filter((name) => !holds(name)))}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Retries [assertion] until it passes; after [timeout] ms throws what it threw last. */
|
|
27
|
+
export async function eventually(assertion: () => void, timeout: number = 10000): Promise<void> {
|
|
28
|
+
let last: unknown = null;
|
|
29
|
+
const passes = () => {
|
|
30
|
+
try {
|
|
31
|
+
assertion();
|
|
32
|
+
return true;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
last = e;
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
await waitUntil(passes, 'unreached', timeout).catch(() => {
|
|
39
|
+
throw last;
|
|
40
|
+
});
|
|
41
|
+
}
|