@mat3ra/wode 2026.8.27-0 → 2026.8.29-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.
|
@@ -29,14 +29,25 @@ declare class ExecutionUnit extends BaseUnit<Schema> implements Schema {
|
|
|
29
29
|
* ApplicationRegistry.
|
|
30
30
|
*/
|
|
31
31
|
private isPersistedInputItemCompatible;
|
|
32
|
+
/**
|
|
33
|
+
* Pair each input slot of the current flavor with a row persisted in saved workflow JSON. A slot
|
|
34
|
+
* first claims the persisted row carrying the same `template.name`; slots still unpaired then fall
|
|
35
|
+
* back to the row in the same position, which is how a row the user renamed in the UI is still
|
|
36
|
+
* recognized. Every persisted row is claimed by at most one slot, so a flavor with more input files
|
|
37
|
+
* than the saved JSON has rows cannot end up with the same file twice.
|
|
38
|
+
*/
|
|
39
|
+
private matchPersistedInput;
|
|
32
40
|
/**
|
|
33
41
|
* Build `inputInstances` from the current flavor’s defaults (`ApplicationRegistry#getInput(application, flavor)`),
|
|
34
|
-
* merged with persisted `this.input` from saved workflow JSON
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
42
|
+
* merged with persisted `this.input` from saved workflow JSON (see `matchPersistedInput`); incompatible or
|
|
43
|
+
* missing rows use the registry template. `render()` then serializes from these instances into `this.input`,
|
|
44
|
+
* so UI and saved JSON stay aligned when Subworkflow re-serializes units after render. Pass
|
|
45
|
+
* `reusePersistedInput: false` to ignore `this.input` and take every slot from the registry, as `setFlavor`
|
|
46
|
+
* does when the flavor changes and the persisted rows describe the previous flavor's files.
|
|
38
47
|
*/
|
|
39
|
-
setDefaultInput(
|
|
48
|
+
setDefaultInput({ reusePersistedInput }?: {
|
|
49
|
+
reusePersistedInput?: boolean;
|
|
50
|
+
}): void;
|
|
40
51
|
render(externalContext: ExternalContext, convergence?: ConvergenceParameter): void;
|
|
41
52
|
private getContextProvidersInstances;
|
|
42
53
|
savePersistentContext(): void;
|
|
@@ -69,14 +69,21 @@ class ExecutionUnit extends BaseUnit_1.default {
|
|
|
69
69
|
this.defaultPostProcessors = flavor.postProcessors;
|
|
70
70
|
// flavor is missing on the first run, so do not use getter this.flavor with requiredProperty
|
|
71
71
|
const previousFlavor = this._json.flavor;
|
|
72
|
-
|
|
72
|
+
const isSameFlavor = (previousFlavor === null || previousFlavor === void 0 ? void 0 : previousFlavor.name) === flavor.name;
|
|
73
|
+
if (!isSameFlavor) {
|
|
73
74
|
this.results = flavor.results;
|
|
74
75
|
this.monitors = flavor.monitors;
|
|
75
76
|
this.preProcessors = flavor.preProcessors;
|
|
76
77
|
this.postProcessors = flavor.postProcessors;
|
|
77
78
|
}
|
|
78
79
|
this.flavor = flavor;
|
|
79
|
-
|
|
80
|
+
// Persisted input belongs to the flavor it was saved with: another flavor's files are a
|
|
81
|
+
// different set of templates under names that often collide (`script.py`,
|
|
82
|
+
// `requirements.txt`), so keeping them would silently serve the previous flavor's content
|
|
83
|
+
// - and leave slots the new flavor adds (e.g. `utils.py`) to be filled by whatever row sits
|
|
84
|
+
// in the same position. Reuse persisted rows only when the flavor is unchanged, i.e. when
|
|
85
|
+
// reconstructing a unit from saved JSON rather than switching flavor in the UI.
|
|
86
|
+
this.setDefaultInput({ reusePersistedInput: isSameFlavor });
|
|
80
87
|
}
|
|
81
88
|
/**
|
|
82
89
|
* Persisted `input[].template` must match the current application/executable (and optional
|
|
@@ -95,19 +102,44 @@ class ExecutionUnit extends BaseUnit_1.default {
|
|
|
95
102
|
}
|
|
96
103
|
return true;
|
|
97
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Pair each input slot of the current flavor with a row persisted in saved workflow JSON. A slot
|
|
107
|
+
* first claims the persisted row carrying the same `template.name`; slots still unpaired then fall
|
|
108
|
+
* back to the row in the same position, which is how a row the user renamed in the UI is still
|
|
109
|
+
* recognized. Every persisted row is claimed by at most one slot, so a flavor with more input files
|
|
110
|
+
* than the saved JSON has rows cannot end up with the same file twice.
|
|
111
|
+
*/
|
|
112
|
+
matchPersistedInput(driverTemplates) {
|
|
113
|
+
const persisted = Array.isArray(this.input) ? this.input : [];
|
|
114
|
+
const claimedIndices = new Set();
|
|
115
|
+
const matchedIndices = driverTemplates.map((driverTemplate) => {
|
|
116
|
+
const index = persisted.findIndex((item, i) => { var _a; return !claimedIndices.has(i) && ((_a = item === null || item === void 0 ? void 0 : item.template) === null || _a === void 0 ? void 0 : _a.name) === driverTemplate.name; });
|
|
117
|
+
if (index !== -1)
|
|
118
|
+
claimedIndices.add(index);
|
|
119
|
+
return index;
|
|
120
|
+
});
|
|
121
|
+
return matchedIndices.map((matchedIndex, index) => {
|
|
122
|
+
if (matchedIndex !== -1)
|
|
123
|
+
return persisted[matchedIndex];
|
|
124
|
+
if (claimedIndices.has(index))
|
|
125
|
+
return undefined;
|
|
126
|
+
claimedIndices.add(index);
|
|
127
|
+
return persisted[index];
|
|
128
|
+
});
|
|
129
|
+
}
|
|
98
130
|
/**
|
|
99
131
|
* Build `inputInstances` from the current flavor’s defaults (`ApplicationRegistry#getInput(application, flavor)`),
|
|
100
|
-
* merged with persisted `this.input` from saved workflow JSON
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
132
|
+
* merged with persisted `this.input` from saved workflow JSON (see `matchPersistedInput`); incompatible or
|
|
133
|
+
* missing rows use the registry template. `render()` then serializes from these instances into `this.input`,
|
|
134
|
+
* so UI and saved JSON stay aligned when Subworkflow re-serializes units after render. Pass
|
|
135
|
+
* `reusePersistedInput: false` to ignore `this.input` and take every slot from the registry, as `setFlavor`
|
|
136
|
+
* does when the flavor changes and the persisted rows describe the previous flavor's files.
|
|
104
137
|
*/
|
|
105
|
-
setDefaultInput() {
|
|
138
|
+
setDefaultInput({ reusePersistedInput = true } = {}) {
|
|
106
139
|
const driverTemplates = new standata_1.ApplicationRegistry().getInput(this.application, this.flavor);
|
|
107
|
-
const
|
|
140
|
+
const persistedItems = reusePersistedInput ? this.matchPersistedInput(driverTemplates) : [];
|
|
108
141
|
this.inputInstances = driverTemplates.map((driverTemplate, index) => {
|
|
109
|
-
|
|
110
|
-
const persistedItem = (_a = persisted.find((item) => { var _a; return ((_a = item === null || item === void 0 ? void 0 : item.template) === null || _a === void 0 ? void 0 : _a.name) === driverTemplate.name; })) !== null && _a !== void 0 ? _a : persisted[index];
|
|
142
|
+
const persistedItem = persistedItems[index];
|
|
111
143
|
if (persistedItem && this.isPersistedInputItemCompatible(persistedItem)) {
|
|
112
144
|
return new ExecutionUnitInput_1.default(persistedItem);
|
|
113
145
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type Taggable } from "@mat3ra/code/dist/js/entity/mixins/TaggableMixin";
|
|
2
2
|
import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
ExecutionUnitInputItemSchema,
|
|
5
|
+
ExecutionUnitSchema,
|
|
6
|
+
TemplateSchema,
|
|
7
|
+
} from "@mat3ra/esse/dist/js/types";
|
|
4
8
|
import { ApplicationRegistry, applicationVersionSatisfiesSupportedRange } from "@mat3ra/standata";
|
|
5
9
|
import { Utils } from "@mat3ra/utils";
|
|
6
10
|
|
|
@@ -111,8 +115,9 @@ class ExecutionUnit extends BaseUnit<Schema> implements Schema {
|
|
|
111
115
|
|
|
112
116
|
// flavor is missing on the first run, so do not use getter this.flavor with requiredProperty
|
|
113
117
|
const previousFlavor = this._json.flavor;
|
|
118
|
+
const isSameFlavor = previousFlavor?.name === flavor.name;
|
|
114
119
|
|
|
115
|
-
if (
|
|
120
|
+
if (!isSameFlavor) {
|
|
116
121
|
this.results = flavor.results;
|
|
117
122
|
this.monitors = flavor.monitors;
|
|
118
123
|
this.preProcessors = flavor.preProcessors;
|
|
@@ -120,7 +125,13 @@ class ExecutionUnit extends BaseUnit<Schema> implements Schema {
|
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
this.flavor = flavor;
|
|
123
|
-
|
|
128
|
+
// Persisted input belongs to the flavor it was saved with: another flavor's files are a
|
|
129
|
+
// different set of templates under names that often collide (`script.py`,
|
|
130
|
+
// `requirements.txt`), so keeping them would silently serve the previous flavor's content
|
|
131
|
+
// - and leave slots the new flavor adds (e.g. `utils.py`) to be filled by whatever row sits
|
|
132
|
+
// in the same position. Reuse persisted rows only when the flavor is unchanged, i.e. when
|
|
133
|
+
// reconstructing a unit from saved JSON rather than switching flavor in the UI.
|
|
134
|
+
this.setDefaultInput({ reusePersistedInput: isSameFlavor });
|
|
124
135
|
}
|
|
125
136
|
|
|
126
137
|
/**
|
|
@@ -150,21 +161,53 @@ class ExecutionUnit extends BaseUnit<Schema> implements Schema {
|
|
|
150
161
|
return true;
|
|
151
162
|
}
|
|
152
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Pair each input slot of the current flavor with a row persisted in saved workflow JSON. A slot
|
|
166
|
+
* first claims the persisted row carrying the same `template.name`; slots still unpaired then fall
|
|
167
|
+
* back to the row in the same position, which is how a row the user renamed in the UI is still
|
|
168
|
+
* recognized. Every persisted row is claimed by at most one slot, so a flavor with more input files
|
|
169
|
+
* than the saved JSON has rows cannot end up with the same file twice.
|
|
170
|
+
*/
|
|
171
|
+
private matchPersistedInput(
|
|
172
|
+
driverTemplates: TemplateSchema[],
|
|
173
|
+
): (ExecutionUnitInputItemSchema | undefined)[] {
|
|
174
|
+
const persisted = Array.isArray(this.input) ? this.input : [];
|
|
175
|
+
const claimedIndices = new Set<number>();
|
|
176
|
+
|
|
177
|
+
const matchedIndices = driverTemplates.map((driverTemplate) => {
|
|
178
|
+
const index = persisted.findIndex(
|
|
179
|
+
(item, i) => !claimedIndices.has(i) && item?.template?.name === driverTemplate.name,
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
if (index !== -1) claimedIndices.add(index);
|
|
183
|
+
|
|
184
|
+
return index;
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
return matchedIndices.map((matchedIndex, index) => {
|
|
188
|
+
if (matchedIndex !== -1) return persisted[matchedIndex];
|
|
189
|
+
if (claimedIndices.has(index)) return undefined;
|
|
190
|
+
|
|
191
|
+
claimedIndices.add(index);
|
|
192
|
+
|
|
193
|
+
return persisted[index];
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
153
197
|
/**
|
|
154
198
|
* Build `inputInstances` from the current flavor’s defaults (`ApplicationRegistry#getInput(application, flavor)`),
|
|
155
|
-
* merged with persisted `this.input` from saved workflow JSON
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
199
|
+
* merged with persisted `this.input` from saved workflow JSON (see `matchPersistedInput`); incompatible or
|
|
200
|
+
* missing rows use the registry template. `render()` then serializes from these instances into `this.input`,
|
|
201
|
+
* so UI and saved JSON stay aligned when Subworkflow re-serializes units after render. Pass
|
|
202
|
+
* `reusePersistedInput: false` to ignore `this.input` and take every slot from the registry, as `setFlavor`
|
|
203
|
+
* does when the flavor changes and the persisted rows describe the previous flavor's files.
|
|
159
204
|
*/
|
|
160
|
-
setDefaultInput() {
|
|
205
|
+
setDefaultInput({ reusePersistedInput = true }: { reusePersistedInput?: boolean } = {}) {
|
|
161
206
|
const driverTemplates = new ApplicationRegistry().getInput(this.application, this.flavor);
|
|
162
|
-
const
|
|
207
|
+
const persistedItems = reusePersistedInput ? this.matchPersistedInput(driverTemplates) : [];
|
|
163
208
|
|
|
164
209
|
this.inputInstances = driverTemplates.map((driverTemplate, index) => {
|
|
165
|
-
const persistedItem =
|
|
166
|
-
persisted.find((item) => item?.template?.name === driverTemplate.name) ??
|
|
167
|
-
persisted[index];
|
|
210
|
+
const persistedItem = persistedItems[index];
|
|
168
211
|
|
|
169
212
|
if (persistedItem && this.isPersistedInputItemCompatible(persistedItem)) {
|
|
170
213
|
return new ExecutionUnitInput(persistedItem);
|