lhcb-ntuple-wizard-test 2.2.1 → 2.2.3
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/dist/models/dtt.js +10 -5
- package/dist/tests/models/Dtt.test.js +141 -0
- package/package.json +3 -3
package/dist/models/dtt.js
CHANGED
|
@@ -17,14 +17,15 @@ export default class Dtt {
|
|
|
17
17
|
static formatToolsForLoading(tools, toolMetadata) {
|
|
18
18
|
return Object.fromEntries(tools
|
|
19
19
|
.map((toolConfig) => {
|
|
20
|
-
const
|
|
21
|
-
const params = toolConfig[
|
|
20
|
+
const toolString = Object.keys(toolConfig)[0];
|
|
21
|
+
const params = toolConfig[toolString];
|
|
22
|
+
const toolClass = toolString.split("/")[0];
|
|
22
23
|
const toolInterface = toolMetadata[toolClass]?.interface;
|
|
23
24
|
if (!toolInterface) {
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
26
27
|
return [
|
|
27
|
-
|
|
28
|
+
toolString,
|
|
28
29
|
Object.fromEntries(Object.entries(params)
|
|
29
30
|
.map(([paramName, value]) => {
|
|
30
31
|
const paramMetadata = toolInterface.find((param) => param.name === paramName);
|
|
@@ -40,7 +41,8 @@ export default class Dtt {
|
|
|
40
41
|
}
|
|
41
42
|
static fromSavedConfig(savedConfig, toolMetadata) {
|
|
42
43
|
const config = {
|
|
43
|
-
|
|
44
|
+
input: savedConfig.inputs?.length ? savedConfig.inputs[0] : undefined,
|
|
45
|
+
descriptorTemplate: savedConfig.descriptorTemplate,
|
|
44
46
|
tools: Dtt.formatToolsForLoading(savedConfig.tools, toolMetadata),
|
|
45
47
|
branches: Object.fromEntries(Object.entries(savedConfig.branches).map(([branchId, branchConfig]) => [
|
|
46
48
|
branchId,
|
|
@@ -56,12 +58,14 @@ export default class Dtt {
|
|
|
56
58
|
tools: Dtt.formatToolsForLoading(groupConfig.tools, toolMetadata),
|
|
57
59
|
},
|
|
58
60
|
])),
|
|
61
|
+
name: savedConfig.name,
|
|
59
62
|
};
|
|
60
63
|
return new Dtt(config, {});
|
|
61
64
|
}
|
|
62
65
|
toSavedConfig() {
|
|
63
66
|
return {
|
|
64
|
-
|
|
67
|
+
inputs: this.config.input ? [this.config.input] : undefined,
|
|
68
|
+
descriptorTemplate: this.config.descriptorTemplate,
|
|
65
69
|
tools: Dtt.formatToolsForSaving(this.config.tools),
|
|
66
70
|
branches: Object.fromEntries(Object.entries(this.config.branches).map(([branchId, branchConfig]) => [
|
|
67
71
|
branchId,
|
|
@@ -77,6 +81,7 @@ export default class Dtt {
|
|
|
77
81
|
tools: Dtt.formatToolsForSaving(groupConfig.tools),
|
|
78
82
|
},
|
|
79
83
|
])),
|
|
84
|
+
name: this.config.name,
|
|
80
85
|
};
|
|
81
86
|
}
|
|
82
87
|
static getBranchConfigs(branchItemsList) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
+
import yaml from "js-yaml";
|
|
2
3
|
import Dtt from "../../models/dtt";
|
|
4
|
+
// @ts-expect-error this fixture import shows an error for some reason
|
|
5
|
+
// but doesn't cause any problems in practice
|
|
6
|
+
import fixtureYaml from "../fixtures/example_dtt.yaml?raw";
|
|
3
7
|
import { TupleTool } from "../../models/tupleTool";
|
|
4
8
|
import { mockBranchItems, mockToolMetadata } from "../testUtils";
|
|
5
9
|
const DEFAULT_TOOLS = [
|
|
@@ -374,3 +378,140 @@ describe("Dtt", () => {
|
|
|
374
378
|
});
|
|
375
379
|
});
|
|
376
380
|
});
|
|
381
|
+
// ---------------------------------------------------------------------------
|
|
382
|
+
// Fixture-based tests
|
|
383
|
+
// ---------------------------------------------------------------------------
|
|
384
|
+
const fixtureParsed = yaml.load(fixtureYaml);
|
|
385
|
+
const fixtureToolMetadata = {
|
|
386
|
+
TupleToolKinematic: {
|
|
387
|
+
description: "",
|
|
388
|
+
documentation: "",
|
|
389
|
+
tags: [],
|
|
390
|
+
interface: [
|
|
391
|
+
{ name: "ExtraName", type: "str", cpp_type: "std::string", default: "", description: "" },
|
|
392
|
+
{ name: "Verbose", type: "bool", cpp_type: "bool", default: false, description: "" },
|
|
393
|
+
{ name: "MaxPV", type: "uint", cpp_type: "unsigned int", default: 100, description: "" },
|
|
394
|
+
{
|
|
395
|
+
name: "Transporter",
|
|
396
|
+
type: "str",
|
|
397
|
+
cpp_type: "std::string",
|
|
398
|
+
default: "ParticleTransporter:PUBLIC",
|
|
399
|
+
description: "",
|
|
400
|
+
},
|
|
401
|
+
],
|
|
402
|
+
},
|
|
403
|
+
TupleToolPid: {
|
|
404
|
+
description: "",
|
|
405
|
+
documentation: "",
|
|
406
|
+
tags: [],
|
|
407
|
+
interface: [
|
|
408
|
+
{ name: "ExtraName", type: "str", cpp_type: "std::string", default: "", description: "" },
|
|
409
|
+
{ name: "Verbose", type: "bool", cpp_type: "bool", default: false, description: "" },
|
|
410
|
+
{ name: "MaxPV", type: "uint", cpp_type: "unsigned int", default: 100, description: "" },
|
|
411
|
+
],
|
|
412
|
+
},
|
|
413
|
+
TupleToolANNPID: {
|
|
414
|
+
description: "",
|
|
415
|
+
documentation: "",
|
|
416
|
+
tags: [],
|
|
417
|
+
interface: [
|
|
418
|
+
{ name: "ExtraName", type: "str", cpp_type: "std::string", default: "", description: "" },
|
|
419
|
+
{ name: "Verbose", type: "bool", cpp_type: "bool", default: false, description: "" },
|
|
420
|
+
{ name: "MaxPV", type: "uint", cpp_type: "unsigned int", default: 100, description: "" },
|
|
421
|
+
{
|
|
422
|
+
name: "ANNPIDTunes",
|
|
423
|
+
type: "text",
|
|
424
|
+
cpp_type: "std::vector<std::string>",
|
|
425
|
+
default: ["MC12TuneV2", "MC12TuneV3", "MC12TuneV4", "MC15TuneV1"],
|
|
426
|
+
description: "",
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: "PIDTypes",
|
|
430
|
+
type: "text",
|
|
431
|
+
cpp_type: "std::vector<std::string>",
|
|
432
|
+
default: ["Electron", "Muon", "Pion", "Kaon", "Proton", "Ghost"],
|
|
433
|
+
description: "",
|
|
434
|
+
},
|
|
435
|
+
],
|
|
436
|
+
},
|
|
437
|
+
TupleToolAngles: {
|
|
438
|
+
description: "",
|
|
439
|
+
documentation: "",
|
|
440
|
+
tags: [],
|
|
441
|
+
interface: [
|
|
442
|
+
{ name: "ExtraName", type: "str", cpp_type: "std::string", default: "", description: "" },
|
|
443
|
+
{ name: "Verbose", type: "bool", cpp_type: "bool", default: false, description: "" },
|
|
444
|
+
{ name: "MaxPV", type: "uint", cpp_type: "unsigned int", default: 100, description: "" },
|
|
445
|
+
{ name: "WRTMother", type: "bool", cpp_type: "bool", default: false, description: "" },
|
|
446
|
+
],
|
|
447
|
+
},
|
|
448
|
+
TupleToolCorrectedMass: {
|
|
449
|
+
description: "",
|
|
450
|
+
documentation: "",
|
|
451
|
+
tags: [],
|
|
452
|
+
interface: [
|
|
453
|
+
{ name: "ExtraName", type: "str", cpp_type: "std::string", default: "", description: "" },
|
|
454
|
+
{ name: "Verbose", type: "bool", cpp_type: "bool", default: false, description: "" },
|
|
455
|
+
{ name: "MaxPV", type: "uint", cpp_type: "unsigned int", default: 100, description: "" },
|
|
456
|
+
{ name: "MassInvisible", type: "float", cpp_type: "double", default: 0, description: "" },
|
|
457
|
+
],
|
|
458
|
+
},
|
|
459
|
+
};
|
|
460
|
+
describe("fromSavedConfig() with fixture", () => {
|
|
461
|
+
let dtt;
|
|
462
|
+
dtt = Dtt.fromSavedConfig(fixtureParsed, fixtureToolMetadata);
|
|
463
|
+
it("loads the correct branch IDs and particle assignments", () => {
|
|
464
|
+
expect(Object.keys(dtt.config.branches).sort()).toEqual(["eminus", "eplus", "gamma"]);
|
|
465
|
+
expect(dtt.config.branches["gamma"].particle).toBe("gamma");
|
|
466
|
+
expect(dtt.config.branches["eplus"].particle).toBe("e+");
|
|
467
|
+
expect(dtt.config.branches["eminus"].particle).toBe("e-");
|
|
468
|
+
});
|
|
469
|
+
it("loads the descriptor template", () => {
|
|
470
|
+
expect(dtt.config.descriptorTemplate).toBe("${gamma}gamma -> ${eplus}e+ ${eminus}e-");
|
|
471
|
+
});
|
|
472
|
+
it("loads the name", () => {
|
|
473
|
+
expect(dtt.config.name).toBe("DecayTreeTuple/MyDecayTree0");
|
|
474
|
+
});
|
|
475
|
+
it("loads the input location", () => {
|
|
476
|
+
expect(dtt.config.input).toBe("/Event/Leptonic/Phys/BuToKJpsiee2Line/Particles");
|
|
477
|
+
});
|
|
478
|
+
it("loads global tools by class", () => {
|
|
479
|
+
expect(dtt.toolExists(TupleTool.fromString("TupleToolKinematic"))).toBe(true);
|
|
480
|
+
expect(dtt.toolExists(TupleTool.fromString("TupleToolPid"))).toBe(true);
|
|
481
|
+
expect(dtt.toolExists(TupleTool.fromString("TupleToolANNPID"))).toBe(true);
|
|
482
|
+
});
|
|
483
|
+
it("loads a named tool instance", () => {
|
|
484
|
+
expect(dtt.toolExists(TupleTool.fromString("TupleToolAngles/myNamedTool"))).toBe(true);
|
|
485
|
+
});
|
|
486
|
+
it("loads a modified string param (TupleToolPid ExtraName)", () => {
|
|
487
|
+
expect(dtt.config.tools["TupleToolPid"]["ExtraName"].value).toBe("myExtraName");
|
|
488
|
+
});
|
|
489
|
+
it("loads a string param (TupleToolKinematic Transporter)", () => {
|
|
490
|
+
expect(dtt.config.tools["TupleToolKinematic"]["Transporter"].value).toBe("ParticleTransporter:PUBLIC");
|
|
491
|
+
});
|
|
492
|
+
it("loads an array param (TupleToolANNPID ANNPIDTunes)", () => {
|
|
493
|
+
expect(dtt.config.tools["TupleToolANNPID"]["ANNPIDTunes"].value).toEqual([
|
|
494
|
+
"MC12TuneV2",
|
|
495
|
+
"MC12TuneV3",
|
|
496
|
+
"MC12TuneV4",
|
|
497
|
+
"MC15TuneV1",
|
|
498
|
+
]);
|
|
499
|
+
});
|
|
500
|
+
it("loads a bool param on a named tool (TupleToolAngles/myNamedTool WRTMother)", () => {
|
|
501
|
+
expect(dtt.config.tools["TupleToolAngles/myNamedTool"]["WRTMother"].value).toBe(true);
|
|
502
|
+
});
|
|
503
|
+
it("loads the group key and its particle list", () => {
|
|
504
|
+
expect(dtt.config.groups["eminus,gamma"].particles).toEqual(["e-", "gamma"]);
|
|
505
|
+
});
|
|
506
|
+
it("loads the named group tool and its params", () => {
|
|
507
|
+
const groupTool = dtt.config.groups["eminus,gamma"].tools["TupleToolCorrectedMass/myGroupTool"];
|
|
508
|
+
expect(groupTool["MassInvisible"].value).toBe(0);
|
|
509
|
+
expect(groupTool["MaxPV"].value).toBe(100);
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
describe("toSavedConfig() roundtrip with fixture", () => {
|
|
513
|
+
it("fromSavedConfig -> toSavedConfig reproduces the fixture exactly", () => {
|
|
514
|
+
const dtt = Dtt.fromSavedConfig(fixtureParsed, fixtureToolMetadata);
|
|
515
|
+
expect(dtt.toSavedConfig()).toEqual(fixtureParsed);
|
|
516
|
+
});
|
|
517
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lhcb-ntuple-wizard-test",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "An application to access large-scale open data from LHCb",
|
|
5
5
|
"url": "https://gitlab.cern.ch/lhcb-dpa/wp6-analysis-preservation-and-open-data/lhcb-ntuple-wizard-frontend/issues",
|
|
6
6
|
"private": false,
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
".": "./dist/index.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@mathjax/src": "4.1.0",
|
|
19
20
|
"bootstrap": "5.3.8",
|
|
20
21
|
"cytoscape": "3.33.1",
|
|
21
22
|
"cytoscape-dagre": "^2.5.0",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
},
|
|
43
44
|
"overrides": {
|
|
44
45
|
"autoprefixer": "10.4.5",
|
|
45
|
-
"@xmldom/xmldom": "0.9.
|
|
46
|
+
"@xmldom/xmldom": "0.9.10"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"start": "vite --open",
|
|
@@ -73,7 +74,6 @@
|
|
|
73
74
|
"@babel/preset-react": "7.27.1",
|
|
74
75
|
"@eslint/js": "^9.17.0",
|
|
75
76
|
"@kennethwkz/unplugin-typia": "^2.6.7",
|
|
76
|
-
"@mathjax/src": "4.1.0",
|
|
77
77
|
"@testing-library/dom": "^10.4.1",
|
|
78
78
|
"@testing-library/jest-dom": "^6.9.1",
|
|
79
79
|
"@testing-library/react": "^16.3.2",
|