@mat3ra/wode 2025.10.1-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.
Files changed (252) hide show
  1. package/.babelrc +17 -0
  2. package/LICENSE.md +15 -0
  3. package/README.md +164 -0
  4. package/assets/subworkflows/deepmd/deepmd.yml +31 -0
  5. package/assets/subworkflows/deepmd/espresso_cp_md.yml +16 -0
  6. package/assets/subworkflows/espresso/average_electrostatic_potential_find_minima.yml +27 -0
  7. package/assets/subworkflows/espresso/average_electrostatic_potential_via_band_structure.yml +67 -0
  8. package/assets/subworkflows/espresso/band_gap.yml +21 -0
  9. package/assets/subworkflows/espresso/band_gap_hse_dos.yml +30 -0
  10. package/assets/subworkflows/espresso/band_structure.yml +26 -0
  11. package/assets/subworkflows/espresso/band_structure_dos.yml +34 -0
  12. package/assets/subworkflows/espresso/band_structure_hse.yml +30 -0
  13. package/assets/subworkflows/espresso/band_structure_magn.yml +31 -0
  14. package/assets/subworkflows/espresso/band_structure_soc.yml +30 -0
  15. package/assets/subworkflows/espresso/dielectric_tensor.yml +35 -0
  16. package/assets/subworkflows/espresso/dos.yml +24 -0
  17. package/assets/subworkflows/espresso/electronic_density_mesh.yml +19 -0
  18. package/assets/subworkflows/espresso/esm.yml +14 -0
  19. package/assets/subworkflows/espresso/esm_relax.yml +14 -0
  20. package/assets/subworkflows/espresso/espresso_extract_kpoints.yml +16 -0
  21. package/assets/subworkflows/espresso/espresso_xml_get_qpt_irr.yml +12 -0
  22. package/assets/subworkflows/espresso/fixed_cell_relaxation.yml +16 -0
  23. package/assets/subworkflows/espresso/gw_band_structure_band_gap_full_frequency.yml +22 -0
  24. package/assets/subworkflows/espresso/gw_band_structure_band_gap_plasmon_pole.yml +22 -0
  25. package/assets/subworkflows/espresso/hubbard_u_hp.yml +21 -0
  26. package/assets/subworkflows/espresso/kpoint_convergence.yml +86 -0
  27. package/assets/subworkflows/espresso/neb.yml +16 -0
  28. package/assets/subworkflows/espresso/ph_init_qpoints.yml +14 -0
  29. package/assets/subworkflows/espresso/ph_single_irr_qpt.yml +14 -0
  30. package/assets/subworkflows/espresso/phonon_dispersions.yml +29 -0
  31. package/assets/subworkflows/espresso/phonon_dos.yml +29 -0
  32. package/assets/subworkflows/espresso/phonon_dos_dispersion.yml +34 -0
  33. package/assets/subworkflows/espresso/phonon_reduce.yml +29 -0
  34. package/assets/subworkflows/espresso/post_processor.yml +14 -0
  35. package/assets/subworkflows/espresso/pre_processor.yml +14 -0
  36. package/assets/subworkflows/espresso/pw_scf.yml +16 -0
  37. package/assets/subworkflows/espresso/recalculate_bands.yml +19 -0
  38. package/assets/subworkflows/espresso/surface_energy.yml +16 -0
  39. package/assets/subworkflows/espresso/total_energy.yml +16 -0
  40. package/assets/subworkflows/espresso/valence_band_offset_calc_from_previous_esp_vbm.yml +35 -0
  41. package/assets/subworkflows/espresso/variable_cell_relaxation.yml +18 -0
  42. package/assets/subworkflows/espresso/zero_point_energy.yml +19 -0
  43. package/assets/subworkflows/jupyterLab/jupyter_notebook.yml +17 -0
  44. package/assets/subworkflows/nwchem/total_energy.yml +16 -0
  45. package/assets/subworkflows/python/ml/classification_tail.yml +56 -0
  46. package/assets/subworkflows/python/ml/clustering_tail.yml +62 -0
  47. package/assets/subworkflows/python/ml/regression_tail.yml +56 -0
  48. package/assets/subworkflows/python/ml/train_head.yml +61 -0
  49. package/assets/subworkflows/python/python_script.yml +14 -0
  50. package/assets/subworkflows/shell/batch_espresso_pwscf.yml +14 -0
  51. package/assets/subworkflows/shell/hello_world.yml +14 -0
  52. package/assets/subworkflows/vasp/band_gap.yml +21 -0
  53. package/assets/subworkflows/vasp/band_structure.yml +21 -0
  54. package/assets/subworkflows/vasp/band_structure_dos.yml +23 -0
  55. package/assets/subworkflows/vasp/dos.yml +18 -0
  56. package/assets/subworkflows/vasp/fixed_cell_relaxation.yml +16 -0
  57. package/assets/subworkflows/vasp/initial_final_total_energies.yml +25 -0
  58. package/assets/subworkflows/vasp/kpoint_convergence.yml +89 -0
  59. package/assets/subworkflows/vasp/neb_subworkflow.yml +16 -0
  60. package/assets/subworkflows/vasp/prepare_images.yml +16 -0
  61. package/assets/subworkflows/vasp/recalculate_bands.yml +16 -0
  62. package/assets/subworkflows/vasp/surface_energy.yml +18 -0
  63. package/assets/subworkflows/vasp/total_energy.yml +16 -0
  64. package/assets/subworkflows/vasp/variable_cell_relaxation.yml +18 -0
  65. package/assets/subworkflows/vasp/zero_point_energy.yml +16 -0
  66. package/assets/workflows/deepmd/deepmd_md.yml +6 -0
  67. package/assets/workflows/espresso/band_gap.yml +4 -0
  68. package/assets/workflows/espresso/band_gap_dos_hse.yml +4 -0
  69. package/assets/workflows/espresso/band_structure.yml +4 -0
  70. package/assets/workflows/espresso/band_structure_dos.yml +4 -0
  71. package/assets/workflows/espresso/band_structure_hse.yml +14 -0
  72. package/assets/workflows/espresso/band_structure_magn.yml +7 -0
  73. package/assets/workflows/espresso/band_structure_soc.yml +7 -0
  74. package/assets/workflows/espresso/dielectric_tensor.yml +4 -0
  75. package/assets/workflows/espresso/dos.yml +4 -0
  76. package/assets/workflows/espresso/electronic_density_mesh.yml +4 -0
  77. package/assets/workflows/espresso/esm.yml +4 -0
  78. package/assets/workflows/espresso/esm_relax.yml +4 -0
  79. package/assets/workflows/espresso/fixed_cell_relaxation.yml +4 -0
  80. package/assets/workflows/espresso/gw_band_structure_band_gap_full_frequency.yml +4 -0
  81. package/assets/workflows/espresso/gw_band_structure_band_gap_plasmon_pole.yml +4 -0
  82. package/assets/workflows/espresso/hubbard_u_hp.yml +7 -0
  83. package/assets/workflows/espresso/kpoint_convergence.yml +4 -0
  84. package/assets/workflows/espresso/neb.yml +4 -0
  85. package/assets/workflows/espresso/phonon_dispersions.yml +4 -0
  86. package/assets/workflows/espresso/phonon_dos.yml +4 -0
  87. package/assets/workflows/espresso/phonon_dos_dispersion.yml +4 -0
  88. package/assets/workflows/espresso/phonon_map.yml +28 -0
  89. package/assets/workflows/espresso/recalculate_bands.yml +4 -0
  90. package/assets/workflows/espresso/surface_energy.yml +4 -0
  91. package/assets/workflows/espresso/total_energy.yml +4 -0
  92. package/assets/workflows/espresso/valence_band_offset.yml +171 -0
  93. package/assets/workflows/espresso/variable_cell_relaxation.yml +4 -0
  94. package/assets/workflows/espresso/zero_point_energy.yml +4 -0
  95. package/assets/workflows/jupyterLab/jupyter_notebook.yml +4 -0
  96. package/assets/workflows/nwchem/total_energy.yml +4 -0
  97. package/assets/workflows/python/ml/classification_workflow.yml +9 -0
  98. package/assets/workflows/python/ml/clustering_workflow.yml +9 -0
  99. package/assets/workflows/python/ml/regression_workflow.yml +9 -0
  100. package/assets/workflows/python/python_script.yml +4 -0
  101. package/assets/workflows/shell/batch_espresso_pwscf.yml +4 -0
  102. package/assets/workflows/shell/hello_world.yml +4 -0
  103. package/assets/workflows/vasp/band_gap.yml +4 -0
  104. package/assets/workflows/vasp/band_structure.yml +4 -0
  105. package/assets/workflows/vasp/band_structure_dos.yml +4 -0
  106. package/assets/workflows/vasp/dos.yml +4 -0
  107. package/assets/workflows/vasp/fixed_cell_relaxation.yml +4 -0
  108. package/assets/workflows/vasp/kpoint_convergence.yml +4 -0
  109. package/assets/workflows/vasp/neb.yml +8 -0
  110. package/assets/workflows/vasp/recalculate_bands.yml +4 -0
  111. package/assets/workflows/vasp/surface_energy.yml +4 -0
  112. package/assets/workflows/vasp/total_energy.yml +4 -0
  113. package/assets/workflows/vasp/variable_cell_relaxation.yml +4 -0
  114. package/assets/workflows/vasp/zero_point_energy.yml +4 -0
  115. package/build_workflows.js +65 -0
  116. package/dist/context/context.js +49 -0
  117. package/dist/context/mixins/ApplicationContextMixin.js +19 -0
  118. package/dist/context/mixins/JobContextMixin.js +39 -0
  119. package/dist/context/mixins/MaterialContextMixin.js +40 -0
  120. package/dist/context/mixins/MaterialsContextMixin.js +19 -0
  121. package/dist/context/mixins/MaterialsSetContextMixin.js +25 -0
  122. package/dist/context/mixins/MethodDataContextMixin.js +48 -0
  123. package/dist/context/mixins/WorkflowContextMixin.js +28 -0
  124. package/dist/context/providers/BoundaryConditionsFormDataProvider.js +86 -0
  125. package/dist/context/providers/CollinearMagnetizationContextProvider.js +113 -0
  126. package/dist/context/providers/HubbardContextProviderLegacy.js +81 -0
  127. package/dist/context/providers/HubbardJContextProvider.js +74 -0
  128. package/dist/context/providers/HubbardUContextProvider.js +77 -0
  129. package/dist/context/providers/HubbardVContextProvider.js +104 -0
  130. package/dist/context/providers/IonDynamicsContextProvider.js +62 -0
  131. package/dist/context/providers/MLSettingsContextProvider.js +52 -0
  132. package/dist/context/providers/MLTrainTestSplitContextProvider.js +48 -0
  133. package/dist/context/providers/NEBFormDataProvider.js +38 -0
  134. package/dist/context/providers/NonCollinearMagnetizationContextProvider.js +253 -0
  135. package/dist/context/providers/PlanewaveCutoffsContextProvider.js +67 -0
  136. package/dist/context/providers/PointsGridFormDataProvider.js +272 -0
  137. package/dist/context/providers/PointsPathFormDataProvider.js +155 -0
  138. package/dist/context/providers/by_application/ExecutableContextProvider.js +17 -0
  139. package/dist/context/providers/by_application/espresso/QENEBContextProvider.js +60 -0
  140. package/dist/context/providers/by_application/espresso/QEPWXContextProvider.js +149 -0
  141. package/dist/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js +84 -0
  142. package/dist/context/providers/by_application/vasp/VASPContextProvider.js +64 -0
  143. package/dist/context/providers/by_application/vasp/VASPNEBContextProvider.js +56 -0
  144. package/dist/context/providers/settings.js +37 -0
  145. package/dist/context/providers.js +199 -0
  146. package/dist/enums.js +65 -0
  147. package/dist/index.js +64 -0
  148. package/dist/patch.js +19 -0
  149. package/dist/subworkflows/convergence/factory.js +35 -0
  150. package/dist/subworkflows/convergence/non_uniform_kgrid.js +31 -0
  151. package/dist/subworkflows/convergence/parameter.js +70 -0
  152. package/dist/subworkflows/convergence/uniform_kgrid.js +26 -0
  153. package/dist/subworkflows/convergence.js +189 -0
  154. package/dist/subworkflows/create.js +285 -0
  155. package/dist/subworkflows/dynamic/espresso/getQpointIrrep.js +34 -0
  156. package/dist/subworkflows/dynamic/index.js +19 -0
  157. package/dist/subworkflows/dynamic/surfaceEnergy.js +67 -0
  158. package/dist/subworkflows/index.js +19 -0
  159. package/dist/subworkflows/subworkflow.js +279 -0
  160. package/dist/units/assertion.js +37 -0
  161. package/dist/units/assignment.js +42 -0
  162. package/dist/units/base.js +91 -0
  163. package/dist/units/builders/AssertionUnitConfigBuilder.js +34 -0
  164. package/dist/units/builders/AssignmentUnitConfigBuilder.js +41 -0
  165. package/dist/units/builders/ExecutionUnitConfigBuilder.js +67 -0
  166. package/dist/units/builders/IOUnitConfigBuilder.js +54 -0
  167. package/dist/units/builders/UnitConfigBuilder.js +79 -0
  168. package/dist/units/builders/index.js +18 -0
  169. package/dist/units/condition.js +52 -0
  170. package/dist/units/execution.js +222 -0
  171. package/dist/units/factory.js +53 -0
  172. package/dist/units/index.js +82 -0
  173. package/dist/units/io.js +148 -0
  174. package/dist/units/map.js +38 -0
  175. package/dist/units/processing.js +41 -0
  176. package/dist/units/reduce.js +24 -0
  177. package/dist/units/subworkflow.js +23 -0
  178. package/dist/utils.js +92 -0
  179. package/dist/workflows/create.js +312 -0
  180. package/dist/workflows/default.js +41 -0
  181. package/dist/workflows/index.js +108 -0
  182. package/dist/workflows/relaxation.js +37 -0
  183. package/dist/workflows/workflow.js +303 -0
  184. package/package.json +94 -0
  185. package/src/context/context.js +47 -0
  186. package/src/context/mixins/ApplicationContextMixin.js +19 -0
  187. package/src/context/mixins/JobContextMixin.js +36 -0
  188. package/src/context/mixins/MaterialContextMixin.js +41 -0
  189. package/src/context/mixins/MaterialsContextMixin.js +18 -0
  190. package/src/context/mixins/MaterialsSetContextMixin.js +24 -0
  191. package/src/context/mixins/MethodDataContextMixin.js +48 -0
  192. package/src/context/mixins/WorkflowContextMixin.js +25 -0
  193. package/src/context/providers/BoundaryConditionsFormDataProvider.js +80 -0
  194. package/src/context/providers/CollinearMagnetizationContextProvider.js +117 -0
  195. package/src/context/providers/HubbardContextProviderLegacy.js +75 -0
  196. package/src/context/providers/HubbardJContextProvider.js +73 -0
  197. package/src/context/providers/HubbardUContextProvider.js +100 -0
  198. package/src/context/providers/HubbardVContextProvider.js +111 -0
  199. package/src/context/providers/IonDynamicsContextProvider.js +56 -0
  200. package/src/context/providers/MLSettingsContextProvider.js +48 -0
  201. package/src/context/providers/MLTrainTestSplitContextProvider.js +45 -0
  202. package/src/context/providers/NEBFormDataProvider.js +32 -0
  203. package/src/context/providers/NonCollinearMagnetizationContextProvider.js +269 -0
  204. package/src/context/providers/PlanewaveCutoffsContextProvider.js +68 -0
  205. package/src/context/providers/PointsGridFormDataProvider.js +285 -0
  206. package/src/context/providers/PointsPathFormDataProvider.js +165 -0
  207. package/src/context/providers/by_application/ExecutableContextProvider.js +10 -0
  208. package/src/context/providers/by_application/espresso/QENEBContextProvider.js +56 -0
  209. package/src/context/providers/by_application/espresso/QEPWXContextProvider.js +166 -0
  210. package/src/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js +86 -0
  211. package/src/context/providers/by_application/vasp/VASPContextProvider.js +56 -0
  212. package/src/context/providers/by_application/vasp/VASPNEBContextProvider.js +46 -0
  213. package/src/context/providers/settings.js +38 -0
  214. package/src/context/providers.js +140 -0
  215. package/src/enums.js +65 -0
  216. package/src/index.js +17 -0
  217. package/src/patch.js +12 -0
  218. package/src/subworkflows/convergence/factory.js +14 -0
  219. package/src/subworkflows/convergence/non_uniform_kgrid.js +28 -0
  220. package/src/subworkflows/convergence/parameter.js +58 -0
  221. package/src/subworkflows/convergence/uniform_kgrid.js +22 -0
  222. package/src/subworkflows/convergence.js +196 -0
  223. package/src/subworkflows/create.js +201 -0
  224. package/src/subworkflows/dynamic/espresso/getQpointIrrep.js +35 -0
  225. package/src/subworkflows/dynamic/index.js +8 -0
  226. package/src/subworkflows/dynamic/surfaceEnergy.js +124 -0
  227. package/src/subworkflows/index.js +2 -0
  228. package/src/subworkflows/subworkflow.js +329 -0
  229. package/src/units/assertion.js +29 -0
  230. package/src/units/assignment.js +34 -0
  231. package/src/units/base.js +97 -0
  232. package/src/units/builders/AssertionUnitConfigBuilder.js +28 -0
  233. package/src/units/builders/AssignmentUnitConfigBuilder.js +36 -0
  234. package/src/units/builders/ExecutionUnitConfigBuilder.js +59 -0
  235. package/src/units/builders/IOUnitConfigBuilder.js +53 -0
  236. package/src/units/builders/UnitConfigBuilder.js +86 -0
  237. package/src/units/builders/index.js +15 -0
  238. package/src/units/condition.js +47 -0
  239. package/src/units/execution.js +263 -0
  240. package/src/units/factory.js +53 -0
  241. package/src/units/index.js +25 -0
  242. package/src/units/io.js +163 -0
  243. package/src/units/map.js +33 -0
  244. package/src/units/processing.js +39 -0
  245. package/src/units/reduce.js +17 -0
  246. package/src/units/subworkflow.js +15 -0
  247. package/src/utils.js +73 -0
  248. package/src/workflows/create.js +222 -0
  249. package/src/workflows/default.js +39 -0
  250. package/src/workflows/index.js +99 -0
  251. package/src/workflows/relaxation.js +41 -0
  252. package/src/workflows/workflow.js +351 -0
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ProcessingUnit = void 0;
7
+ var _enums = require("../enums");
8
+ var _base = require("./base");
9
+ class ProcessingUnit extends _base.BaseUnit {
10
+ constructor(config) {
11
+ super({
12
+ ...ProcessingUnit.getProcessingConfig(),
13
+ ...config
14
+ });
15
+ }
16
+ static getProcessingConfig() {
17
+ return {
18
+ name: _enums.UNIT_TYPES.processing,
19
+ type: _enums.UNIT_TYPES.processing
20
+ };
21
+ }
22
+ setOperation(op) {
23
+ this.setProp("operation", op);
24
+ }
25
+ setOperationType(type) {
26
+ this.setProp("operationType", type);
27
+ }
28
+ setInput(input) {
29
+ this.setProp("input", input);
30
+ }
31
+ get operation() {
32
+ return this.prop("operation");
33
+ }
34
+ get operationType() {
35
+ return this.prop("operationType");
36
+ }
37
+ get input() {
38
+ return this.prop("input");
39
+ }
40
+ }
41
+ exports.ProcessingUnit = ProcessingUnit;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ReduceUnit = void 0;
7
+ var _enums = require("../enums");
8
+ var _base = require("./base");
9
+ class ReduceUnit extends _base.BaseUnit {
10
+ constructor(unitName, mapUnit, input) {
11
+ super({
12
+ ...ReduceUnit.getReduceConfig(unitName, mapUnit, input)
13
+ });
14
+ }
15
+ static getReduceConfig(unitName, mapUnit, input) {
16
+ return {
17
+ type: _enums.UNIT_TYPES.reduce,
18
+ name: unitName,
19
+ mapFlowchartId: mapUnit,
20
+ input
21
+ };
22
+ }
23
+ }
24
+ exports.ReduceUnit = ReduceUnit;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SubworkflowUnit = void 0;
7
+ var _enums = require("../enums");
8
+ var _base = require("./base");
9
+ class SubworkflowUnit extends _base.BaseUnit {
10
+ constructor(config) {
11
+ super({
12
+ ...SubworkflowUnit.getSubworkflowConfig(),
13
+ ...config
14
+ });
15
+ }
16
+ static getSubworkflowConfig() {
17
+ return {
18
+ name: "New Subworkflow",
19
+ type: _enums.UNIT_TYPES.subworkflow
20
+ };
21
+ }
22
+ }
23
+ exports.SubworkflowUnit = SubworkflowUnit;
package/dist/utils.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyConfig = applyConfig;
7
+ exports.findUnit = findUnit;
8
+ exports.setNextLinks = setNextLinks;
9
+ exports.setUnitsHead = setUnitsHead;
10
+ var _lodash = _interopRequireDefault(require("lodash"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ /**
13
+ * @summary set the head of an array of units
14
+ * @param units
15
+ * @returns {Unit[]}
16
+ */
17
+ function setUnitsHead(units) {
18
+ if (units.length > 0) {
19
+ units[0].head = true;
20
+ _lodash.default.tail(units).map(x => x.head = false);
21
+ }
22
+ return units;
23
+ }
24
+
25
+ // TODO: fix setNextLinks on unit removal and convergence logic.
26
+ /**
27
+ * @summary Re-establishes the linked `next => flowchartId` logic in an array of units
28
+ * @params units {Unit[]}
29
+ * @returns units {Unit[]}
30
+ */
31
+ function setNextLinks(units) {
32
+ const flowchartIds = units.map(u => u.flowchartId);
33
+ for (let i = 0; i < units.length - 1; i++) {
34
+ if (!units[i].next) {
35
+ // newly added units don't have next set yet => set it
36
+ units[i].next = units[i + 1].flowchartId;
37
+ if (i > 0) units[i - 1].next = units[i].flowchartId;
38
+ } else if (!flowchartIds.includes(units[i].next)) {
39
+ // newly removed units may create broken next links => fix it
40
+ units[i].next = units[i + 1].flowchartId;
41
+ }
42
+ }
43
+ return units;
44
+ }
45
+
46
+ /**
47
+ * @summary Apply configuration data to an object
48
+ * @param obj {*} object / class containing methods or attributes to be set
49
+ * @param config { functions: {}, attributes: {} } functions to call and attributes to set
50
+ * @param callBuild {boolean} if true; call build between applying functions and attributes
51
+ * @returns {*} updated object
52
+ */
53
+ function applyConfig({
54
+ obj,
55
+ config = {},
56
+ callBuild = false
57
+ }) {
58
+ const {
59
+ functions = {},
60
+ attributes = {}
61
+ } = config;
62
+ // eslint-disable-next-line no-restricted-syntax
63
+ for (const [func, args] of Object.entries(functions)) {
64
+ // eslint-disable-next-line no-nested-ternary
65
+ if (obj[func]) {
66
+ if (args) obj[func](args);else obj[func]();
67
+ }
68
+ }
69
+ const modified = callBuild ? obj.build() : obj;
70
+ // eslint-disable-next-line no-restricted-syntax
71
+ for (const [key, values] of Object.entries(attributes)) {
72
+ modified[key] = values;
73
+ }
74
+ return modified;
75
+ }
76
+
77
+ /**
78
+ * @summary Safely extract unit object from subworkflow data
79
+ * @param subworkflowData {Object} subworkflow data
80
+ * @param index {number} index of subworkflow unit
81
+ * @param type {string} type of subworkflow unit
82
+ * @returns {Object|null} subworkflow unit object (not a unit class instance!)
83
+ */
84
+ function findUnit({
85
+ subworkflowData,
86
+ index,
87
+ type
88
+ }) {
89
+ const unit = subworkflowData.units[index];
90
+ if (unit.type !== type) throw new Error("findUnit() error: unit type does not match!");
91
+ return unit;
92
+ }
@@ -0,0 +1,312 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createWorkflow = createWorkflow;
7
+ var _create = require("../subworkflows/create");
8
+ var _units = require("../units");
9
+ var _map = require("../units/map");
10
+ var _utils = require("../utils");
11
+ var _workflow = require("./workflow");
12
+ /**
13
+ * @summary Helper for creating Map units for complex workflows
14
+ * @param config {Object} map unit configuration
15
+ * @param unitFactoryCls {*} class factory for map unit
16
+ * @returns {*} map unit
17
+ */
18
+ function createMapUnit({
19
+ config,
20
+ unitFactoryCls = _units.UnitFactory
21
+ }) {
22
+ let {
23
+ input: defaultInput
24
+ } = _map.defaultMapConfig;
25
+ if (config.input) {
26
+ defaultInput = {
27
+ ...defaultInput,
28
+ ...config.input
29
+ };
30
+ }
31
+ const unit = unitFactoryCls.create({
32
+ ..._map.defaultMapConfig,
33
+ input: defaultInput
34
+ });
35
+ return unit;
36
+ }
37
+
38
+ /**
39
+ * @summary Update subworkflow units with patch configuration defined in the workflow config
40
+ * @param subworkflowData {Object} subworkflow data
41
+ * @param unitConfigs {Array<Object>} array of patch configs for subworkflow units
42
+ * @returns subworkflowData {Object} subworkflowData with patches applied to units
43
+ */
44
+ function updateUnitConfigs({
45
+ subworkflowData,
46
+ unitConfigs
47
+ }) {
48
+ unitConfigs.forEach(config => {
49
+ const {
50
+ index,
51
+ type,
52
+ config: unitConfig
53
+ } = config; // unitConfig should contain 'attributes' key
54
+ const unit = (0, _utils.findUnit)({
55
+ subworkflowData,
56
+ index,
57
+ type
58
+ });
59
+ console.log(` patching ${type} unit ${index} of subworkflow ${subworkflowData.name}`);
60
+ unit.config = (0, _utils.applyConfig)({
61
+ obj: unit.config,
62
+ config: unitConfig
63
+ });
64
+ return null;
65
+ });
66
+ return subworkflowData;
67
+ }
68
+
69
+ /**
70
+ * @summary Use subworkflow.createSubworkflow to create a Subworkflow unit
71
+ * @param appName {String} application name
72
+ * @param unitData {*} object containing subworkflow configuration data
73
+ * @param workflowData {*} object containing all workflow configuration data
74
+ * @param swArgs {*} subworkflow classes
75
+ * @returns {*} subworkflow object
76
+ */
77
+ function createSubworkflowUnit({
78
+ appName,
79
+ unitData,
80
+ workflowData,
81
+ ...swArgs
82
+ }) {
83
+ const {
84
+ name: unitName,
85
+ unitConfigs,
86
+ config
87
+ } = unitData;
88
+ const {
89
+ subworkflows
90
+ } = workflowData;
91
+ const {
92
+ [appName]: dataByApp
93
+ } = subworkflows;
94
+ let {
95
+ [unitName]: subworkflowData
96
+ } = dataByApp;
97
+ subworkflowData.config = {
98
+ ...subworkflowData.config,
99
+ ...config
100
+ };
101
+ if (unitConfigs) subworkflowData = updateUnitConfigs({
102
+ subworkflowData,
103
+ unitConfigs
104
+ });
105
+ return (0, _create.createSubworkflow)({
106
+ subworkflowData,
107
+ ...swArgs
108
+ });
109
+ }
110
+
111
+ /**
112
+ * @summary Create the first workflow object specified in a workflow configuration
113
+ * @param workflow {*|null} the workflow (if already initialized, no-op)
114
+ * @param unit {*} workflow unit object
115
+ * @param type {String} value in ["workflow", "subworkflow"]
116
+ * @param workflowCls {*} workflow class
117
+ * @returns {Workflow|*} workflow object
118
+ */
119
+ function createWorkflowHead({
120
+ workflow,
121
+ unit,
122
+ type,
123
+ workflowCls
124
+ }) {
125
+ if (workflow) return workflow;
126
+ let wf;
127
+ switch (type) {
128
+ case "workflow":
129
+ wf = unit;
130
+ break;
131
+ case "subworkflow":
132
+ wf = workflowCls.fromSubworkflow(unit);
133
+ break;
134
+ default:
135
+ throw new Error(`workflow type=${type} not understood.`);
136
+ }
137
+ return wf;
138
+ }
139
+
140
+ /**
141
+ * @summary Combine workflow units together
142
+ * @param workflow {*} the workflow object
143
+ * @param unit {*} workflow/subworkflow object
144
+ * @param config {*} additional configuration for e.g. map units
145
+ * @param type {String} value in ["workflow", "subworkflow"]
146
+ * @param unitFactoryCls {*} unit factory class for e.g. map units
147
+ * @returns {*} modified workflow
148
+ */
149
+ function composeWorkflow({
150
+ workflow,
151
+ unit,
152
+ config,
153
+ type,
154
+ unitFactoryCls
155
+ }) {
156
+ /* eslint-disable no-case-declarations */
157
+ switch (type) {
158
+ case "workflow":
159
+ const {
160
+ mapUnit: isMapUnit,
161
+ ...mapUnitConfig
162
+ } = config;
163
+ if (isMapUnit) {
164
+ const mapUnit = createMapUnit({
165
+ config: mapUnitConfig,
166
+ unitFactoryCls
167
+ });
168
+ workflow.addMapUnit(mapUnit, unit);
169
+ } else {
170
+ console.log("adding workflows directly to workflows is not supported.");
171
+ }
172
+ break;
173
+ case "subworkflow":
174
+ workflow.addSubworkflow(unit);
175
+ break;
176
+ default:
177
+ throw new Error(`workflow type=${type} not understood.`);
178
+ }
179
+ /* eslint-enable no-case-declarations */
180
+ return workflow;
181
+ }
182
+
183
+ /**
184
+ * @summary Convert a flattened array of workflow units to a properly constructed workflow
185
+ * @param wfUnits {Array} array of workflow units
186
+ * @param workflowCls {*} workflow class
187
+ * @param unitFactoryCls {*} unit factory class
188
+ * @returns {*} constructed workflow
189
+ */
190
+ function createFromWorkflowUnits({
191
+ wfUnits,
192
+ workflowCls,
193
+ unitFactoryCls
194
+ }) {
195
+ let workflow, unit, config, type;
196
+ wfUnits.map(wfUnit => {
197
+ ({
198
+ unit,
199
+ config,
200
+ type
201
+ } = wfUnit);
202
+ if (!workflow) {
203
+ workflow = createWorkflowHead({
204
+ workflow,
205
+ unit,
206
+ type,
207
+ workflowCls
208
+ });
209
+ } else {
210
+ workflow = composeWorkflow({
211
+ workflow,
212
+ unit,
213
+ config,
214
+ type,
215
+ unitFactoryCls
216
+ });
217
+ }
218
+ return null;
219
+ });
220
+ return (0, _utils.applyConfig)({
221
+ obj: workflow,
222
+ config
223
+ });
224
+ }
225
+
226
+ /**
227
+ * @summary Creates a flattened array of workflow units from nested workflow/subworkflow
228
+ * configuration data comprising a simple or complex workflow
229
+ * @param appName
230
+ * @param units
231
+ * @param swArgs
232
+ * @returns {*[]}
233
+ */
234
+ function createWorkflowUnits({
235
+ appName,
236
+ workflowData,
237
+ workflowSubworkflowMapByApplication,
238
+ workflowCls,
239
+ ...swArgs
240
+ }) {
241
+ const wfUnits = [];
242
+ const {
243
+ units
244
+ } = workflowData;
245
+ let unit, config;
246
+ units.map(unitData => {
247
+ const {
248
+ type
249
+ } = unitData;
250
+ switch (type) {
251
+ case "workflow":
252
+ ({
253
+ config
254
+ } = unitData);
255
+ unit = createWorkflowUnits({
256
+ appName,
257
+ workflowData: unitData,
258
+ workflowSubworkflowMapByApplication,
259
+ workflowCls,
260
+ ...swArgs
261
+ });
262
+ break;
263
+ case "subworkflow":
264
+ ({
265
+ config
266
+ } = workflowData);
267
+ unit = createSubworkflowUnit({
268
+ appName,
269
+ unitData,
270
+ workflowData: workflowSubworkflowMapByApplication,
271
+ ...swArgs
272
+ });
273
+ break;
274
+ default:
275
+ break;
276
+ }
277
+ wfUnits.push({
278
+ config,
279
+ unit,
280
+ type
281
+ });
282
+ return null;
283
+ });
284
+ return createFromWorkflowUnits({
285
+ wfUnits,
286
+ workflowCls,
287
+ subworkflowCls: swArgs.subworkflowCls,
288
+ unitFactoryCls: swArgs.unitFactoryCls
289
+ });
290
+ }
291
+ function createWorkflow({
292
+ appName,
293
+ workflowData,
294
+ workflowSubworkflowMapByApplication,
295
+ workflowCls = _workflow.Workflow,
296
+ ...swArgs
297
+ }) {
298
+ const {
299
+ name
300
+ } = workflowData;
301
+ console.log(`wode: creating ${appName} workflow ${name}`);
302
+ const wf = createWorkflowUnits({
303
+ appName,
304
+ workflowData,
305
+ workflowSubworkflowMapByApplication,
306
+ workflowCls,
307
+ ...swArgs
308
+ });
309
+ wf.setName(name);
310
+ wf.applicationName = appName;
311
+ return wf;
312
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = exports.default = {
8
+ name: "New Workflow",
9
+ properties: [],
10
+ subworkflows: [{
11
+ _id: "c6e9dbbee8929de01f4e76ee",
12
+ application: {
13
+ name: "espresso",
14
+ summary: "Quantum Espresso",
15
+ version: "6.3"
16
+ },
17
+ model: {
18
+ method: {
19
+ subtype: "us",
20
+ type: "pseudopotential"
21
+ },
22
+ subtype: "gga",
23
+ type: "dft"
24
+ },
25
+ name: "New Subworkflow",
26
+ properties: [],
27
+ units: []
28
+ }],
29
+ workflows: [],
30
+ units: [{
31
+ _id: "c6e9dbbee8929de01f4e76ee",
32
+ flowchartId: "da2c090ede4dc2fa6e66647f",
33
+ head: true,
34
+ monitors: [],
35
+ postProcessors: [],
36
+ preProcessors: [],
37
+ results: [],
38
+ type: "subworkflow",
39
+ name: "New Subworkflow"
40
+ }]
41
+ };
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Workflow", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _workflow.Workflow;
10
+ }
11
+ });
12
+ exports.createWorkflowConfigs = createWorkflowConfigs;
13
+ exports.createWorkflows = createWorkflows;
14
+ var _ade = require("@exabyte-io/ade.js");
15
+ var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
16
+ var _schemas = _interopRequireDefault(require("@mat3ra/esse/dist/js/schemas.json"));
17
+ var _standata = require("@mat3ra/standata");
18
+ var _patch = require("../patch");
19
+ var _create = require("./create");
20
+ var _workflow = require("./workflow");
21
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
+ // Import Template here to apply context provider patch
23
+ // eslint-disable-next-line no-unused-vars
24
+
25
+ // Running this to set schemas for validation, removing the redundant data from application-flavors tree: `flavors`
26
+ _JSONSchemasInterface.default.setSchemas(_schemas.default);
27
+
28
+ /*
29
+ Workflow construction follows these rules:
30
+ 1. Workflow is constructed as a collection of subworkflows defined in JSON
31
+ 2. A "units" key should contain at least one object referencing the workflow itself
32
+ 3. Additional workflows are added in order specified in the same "units" array
33
+ 4. map units are added along with their workflows according to data in "units"
34
+ 5. top-level subworkflows are added directly in the order also specified by "units"
35
+ */
36
+ function createWorkflows({
37
+ appName = null,
38
+ workflowCls = _workflow.Workflow,
39
+ workflowSubworkflowMapByApplication = _standata.workflowSubforkflowMapByApplication,
40
+ ...swArgs
41
+ }) {
42
+ let apps = appName !== null ? [appName] : _ade.allApplications;
43
+ const allApplicationsFromWorkflowData = Object.keys(workflowSubworkflowMapByApplication.workflows);
44
+ // output warning if allApplications and allApplicationsFromWorkflowData do not match
45
+ if (appName === null) {
46
+ if (apps.sort().join(",") !== allApplicationsFromWorkflowData.sort().join(",")) {
47
+ // eslint-disable-next-line no-console
48
+ console.warn(`Warning: allApplications and allApplicationsFromWorkflowData do not match:
49
+ ${apps.sort().join(",")} !== ${allApplicationsFromWorkflowData.sort().join(",")}`);
50
+ console.warn("Using allApplicationsFromWorkflowData");
51
+ }
52
+ apps = allApplicationsFromWorkflowData;
53
+ }
54
+ const wfs = [];
55
+ const {
56
+ workflows
57
+ } = workflowSubworkflowMapByApplication;
58
+ apps.map(name => {
59
+ const {
60
+ [name]: dataByApp
61
+ } = workflows;
62
+ Object.values(dataByApp).map(workflowDataForApp => {
63
+ wfs.push((0, _create.createWorkflow)({
64
+ appName: name,
65
+ workflowData: workflowDataForApp,
66
+ workflowSubworkflowMapByApplication,
67
+ workflowCls,
68
+ ...swArgs
69
+ }));
70
+ return null;
71
+ });
72
+ return null;
73
+ });
74
+ return wfs;
75
+ }
76
+
77
+ /**
78
+ * @summary Create workflow configurations for all applications
79
+ * @param applications {Array<String>} array of application names
80
+ * @param workflowCls {*} workflow class to instantiate
81
+ * @param workflowSubworkflowMapByApplication {Object} object containing all workflow/subworkflow map by application
82
+ * @param swArgs {Object} other classes for instantiation
83
+ * @returns {Array<Object>} array of workflow configurations
84
+ */
85
+ function createWorkflowConfigs({
86
+ applications,
87
+ workflowCls = _workflow.Workflow,
88
+ workflowSubworkflowMapByApplication,
89
+ ...swArgs
90
+ }) {
91
+ const configs = [];
92
+ applications.forEach(app => {
93
+ const workflows = createWorkflows({
94
+ appName: app,
95
+ workflowCls,
96
+ workflowSubworkflowMapByApplication,
97
+ ...swArgs
98
+ });
99
+ workflows.forEach(wf => {
100
+ configs.push({
101
+ application: app,
102
+ name: wf.prop("name"),
103
+ config: wf.toJSON()
104
+ });
105
+ });
106
+ });
107
+ return configs;
108
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RelaxationLogicMixin = void 0;
7
+ var _standata = require("@mat3ra/standata");
8
+ const RelaxationLogicMixin = superclass => class extends superclass {
9
+ get relaxationSubworkflow() {
10
+ const appName = this.subworkflows[0]?.application?.name;
11
+ if (!appName) return undefined;
12
+ const subworkflowStandata = new _standata.SubworkflowStandata();
13
+ const relaxationSubworkflow = subworkflowStandata.getRelaxationSubworkflowByApplication(appName);
14
+ return new this._Subworkflow(relaxationSubworkflow);
15
+ }
16
+ isRelaxationSubworkflow(subworkflow) {
17
+ const {
18
+ relaxationSubworkflow
19
+ } = this;
20
+ return relaxationSubworkflow?.systemName !== undefined && relaxationSubworkflow.systemName === subworkflow.systemName;
21
+ }
22
+ get hasRelaxation() {
23
+ return this.subworkflows.some(subworkflow => this.isRelaxationSubworkflow(subworkflow));
24
+ }
25
+ toggleRelaxation() {
26
+ if (this.hasRelaxation) {
27
+ const relaxSubworkflow = this.subworkflows.find(sw => this.isRelaxationSubworkflow(sw));
28
+ this.removeSubworkflow(relaxSubworkflow.id);
29
+ } else {
30
+ const vcRelax = this.relaxationSubworkflow;
31
+ if (vcRelax) {
32
+ this.addSubworkflow(vcRelax, true);
33
+ }
34
+ }
35
+ }
36
+ };
37
+ exports.RelaxationLogicMixin = RelaxationLogicMixin;