@platforma-sdk/workflow-tengo 4.9.0 → 4.9.2

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 (46) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -0
  3. package/dist/index.mjs +1 -0
  4. package/dist/tengo/lib/exec.R.internal.lib.tengo +4 -3
  5. package/dist/tengo/lib/exec.lib.tengo +10 -9
  6. package/dist/tengo/lib/exec.package.lib.tengo +13 -1
  7. package/dist/tengo/lib/exec.runcmd.lib.tengo +1 -4
  8. package/dist/tengo/lib/pframes.lib.tengo +14 -0
  9. package/dist/tengo/lib/render.lib.tengo +3 -3
  10. package/dist/tengo/lib/smart.lib.tengo +44 -10
  11. package/dist/tengo/lib/tpl.base.lib.tengo +14 -5
  12. package/dist/tengo/lib/workdir.lib.tengo +85 -24
  13. package/dist/tengo/tpl/check_network.create_workdir_from_storage.plj.gz +0 -0
  14. package/dist/tengo/tpl/check_network.download_blob.plj.gz +0 -0
  15. package/dist/tengo/tpl/check_network.run_hello_world.plj.gz +0 -0
  16. package/dist/tengo/tpl/check_network.run_hello_world_py.plj.gz +0 -0
  17. package/dist/tengo/tpl/check_network.upload_blob.plj.gz +0 -0
  18. package/dist/tengo/tpl/check_network.upload_template.plj.gz +0 -0
  19. package/dist/tengo/tpl/check_network.workdir_type_name_extractor.plj.gz +0 -0
  20. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  21. package/dist/tengo/tpl/exec.delayed-compute-allocation.impl.plj.gz +0 -0
  22. package/dist/tengo/tpl/exec.exec-impl.plj.gz +0 -0
  23. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  24. package/dist/tengo/tpl/exec.load-software.impl.plj.gz +0 -0
  25. package/dist/tengo/tpl/exec.monetization_info.plj.gz +0 -0
  26. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  27. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  28. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  29. package/dist/tengo/tpl/exec.python.venv-bin-path.plj.gz +0 -0
  30. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  31. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  32. package/dist/tengo/tpl/pframes.export-pframe-for-ui.plj.gz +0 -0
  33. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  34. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  35. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  36. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  37. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  38. package/dist/tengo/tpl/pframes.slice-data.plj.gz +0 -0
  39. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  40. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  41. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  42. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  43. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  44. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  45. package/dist/tengo/tpl/workflow.query-anchored.plj.gz +0 -0
  46. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
2
- declare type TplName = "ll.get-field" | "pframes.export-single-pcolumn" | "pframes.import-dir" | "pframes.remove-nulls" | "waiter.waiter" | "workdir.save" | "workflow.build-ctx" | "workflow.query-anchored" | "exec.delayed-compute-allocation.impl" | "exec.monetization_to_json" | "exec.python.install-deps" | "exec.python.venv-bin-path" | "pframes.export-multiple-pcolumns" | "pframes.slice-data" | "check_network.create_workdir_from_storage" | "check_network.download_blob" | "check_network.upload_blob" | "check_network.upload_template" | "exec.R.create-renv" | "exec.exec-impl" | "exec.monetization_info" | "exec.python.create-venv" | "exec.load-software.impl" | "exec.exec" | "pframes.xsv-export-pframe" | "pframes.xsv-import-if-not-null" | "pframes.xsv-import-map" | "check_network.run_hello_world" | "check_network.run_hello_world_py" | "pframes.process-pcolumn-data" | "pframes.export-pframe" | "pframes.export-pframe-for-ui";
2
+ declare type TplName = "ll.get-field" | "pframes.export-single-pcolumn" | "pframes.import-dir" | "pframes.remove-nulls" | "waiter.waiter" | "workdir.save" | "workflow.build-ctx" | "workflow.query-anchored" | "check_network.workdir_type_name_extractor" | "exec.delayed-compute-allocation.impl" | "exec.monetization_to_json" | "exec.python.install-deps" | "exec.python.venv-bin-path" | "pframes.export-multiple-pcolumns" | "pframes.slice-data" | "check_network.create_workdir_from_storage" | "check_network.download_blob" | "check_network.upload_blob" | "check_network.upload_template" | "exec.R.create-renv" | "exec.exec-impl" | "exec.monetization_info" | "exec.python.create-venv" | "exec.load-software.impl" | "exec.exec" | "pframes.xsv-export-pframe" | "pframes.xsv-import-if-not-null" | "pframes.xsv-import-map" | "check_network.run_hello_world" | "check_network.run_hello_world_py" | "pframes.process-pcolumn-data" | "pframes.export-pframe" | "pframes.export-pframe-for-ui";
3
3
  declare const Templates: Record<TplName, TemplateFromFile>;
4
4
  export { Templates };
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ module.exports = { Templates: {
7
7
  'workdir.save': { type: 'from-file', path: require.resolve('./tengo/tpl/workdir.save.plj.gz') },
8
8
  'workflow.build-ctx': { type: 'from-file', path: require.resolve('./tengo/tpl/workflow.build-ctx.plj.gz') },
9
9
  'workflow.query-anchored': { type: 'from-file', path: require.resolve('./tengo/tpl/workflow.query-anchored.plj.gz') },
10
+ 'check_network.workdir_type_name_extractor': { type: 'from-file', path: require.resolve('./tengo/tpl/check_network.workdir_type_name_extractor.plj.gz') },
10
11
  'exec.delayed-compute-allocation.impl': { type: 'from-file', path: require.resolve('./tengo/tpl/exec.delayed-compute-allocation.impl.plj.gz') },
11
12
  'exec.monetization_to_json': { type: 'from-file', path: require.resolve('./tengo/tpl/exec.monetization_to_json.plj.gz') },
12
13
  'exec.python.install-deps': { type: 'from-file', path: require.resolve('./tengo/tpl/exec.python.install-deps.plj.gz') },
package/dist/index.mjs CHANGED
@@ -8,6 +8,7 @@ export const Templates = {
8
8
  'workdir.save': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/workdir.save.plj.gz') },
9
9
  'workflow.build-ctx': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/workflow.build-ctx.plj.gz') },
10
10
  'workflow.query-anchored': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/workflow.query-anchored.plj.gz') },
11
+ 'check_network.workdir_type_name_extractor': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/check_network.workdir_type_name_extractor.plj.gz') },
11
12
  'exec.delayed-compute-allocation.impl': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/exec.delayed-compute-allocation.impl.plj.gz') },
12
13
  'exec.monetization_to_json': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/exec.monetization_to_json.plj.gz') },
13
14
  'exec.python.install-deps': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/exec.python.install-deps.plj.gz') },
@@ -6,6 +6,7 @@ runcmd := import("@platforma-sdk/workflow-tengo:exec.runcmd")
6
6
  path := import("@platforma-sdk/workflow-tengo:path")
7
7
  desc := import("@platforma-sdk/workflow-tengo:exec.descriptor")
8
8
  constants := import("@platforma-sdk/workflow-tengo:exec.constants")
9
+ pkg := import("@platforma-sdk/workflow-tengo:exec.package")
9
10
 
10
11
  rVenvInputSchema := {
11
12
  operationMode: "string",
@@ -22,9 +23,9 @@ runRBuilder := func(operationMode, wd, rPackage, rDescriptor) {
22
23
  rule := feats.commandExpressions ? "R" : "{R}"
23
24
 
24
25
  builder := runcmd.builder(wd).
25
- inQueue("light").
26
- cpu(1).
27
- mem("1GiB").
26
+ inQueue(pkg.DEFAULT_ALLOCATION_QUEUE).
27
+ cpu(pkg.DEFAULT_ALLOCATION_CPU).
28
+ mem(pkg.DEFAULT_ALLOCATION_RAM).
28
29
  ref("r-run-environment", rPackage).
29
30
  substitutionRule(rule, "r-run-environment").
30
31
  addPathTyped(t, path.join("{R}", rDescriptor.binDir)).
@@ -17,7 +17,6 @@ render := import("@platforma-sdk/workflow-tengo:render")
17
17
  enum := import("enum")
18
18
  oop := import("@platforma-sdk/workflow-tengo:oop")
19
19
  constants := import("@platforma-sdk/workflow-tengo:constants")
20
- limits := import("@platforma-sdk/workflow-tengo:exec.limits")
21
20
  monetization := import("@platforma-sdk/workflow-tengo:exec.monetization_internal")
22
21
  execConstants := import("@platforma-sdk/workflow-tengo:exec.constants")
23
22
 
@@ -144,6 +143,7 @@ builder := func() {
144
143
 
145
144
 
146
145
 
146
+
147
147
  argWithVar: func(arg) {
148
148
  ll.assert(is_string(arg), "exec.argWithVar(): argument with var must be a string, got: %v", arg)
149
149
 
@@ -180,6 +180,7 @@ builder := func() {
180
180
 
181
181
 
182
182
 
183
+
183
184
  envWithVar: func(name, value) {
184
185
  validation.assertType([name, value], ["string"])
185
186
 
@@ -340,6 +341,7 @@ builder := func() {
340
341
 
341
342
 
342
343
 
344
+
343
345
  ram: func(amount) {
344
346
  self.mem(amount)
345
347
  return self
@@ -823,16 +825,15 @@ builder := func() {
823
825
  assetCache: assetCache
824
826
  }
825
827
 
826
- serviceExecInputs := {}
827
- if feats.workdirLimits || feats.computeLimits || limits.useBatch(queue) {
828
- if (is_int(ramRequest)) {
829
- ramRequest = string(ramRequest) + "b"
830
- }
831
- serviceExecInputs.quota = {
828
+ if (is_int(ramRequest)) {
829
+ ramRequest = string(ramRequest) + "b"
830
+ }
831
+ metaExecInputs := {
832
+ quota: smart.createJsonResource({
832
833
  queue: queue,
833
834
  cpu: cpuRequest,
834
835
  ram: ramRequest
835
- }
836
+ })
836
837
  }
837
838
 
838
839
 
@@ -858,7 +859,7 @@ builder := func() {
858
859
  }
859
860
  }
860
861
 
861
- tpl := render.create(assets.importTemplate("@platforma-sdk/workflow-tengo:exec.exec"), pureExecInputs, serviceExecInputs)
862
+ tpl := render.create(assets.importTemplate("@platforma-sdk/workflow-tengo:exec.exec"), pureExecInputs, metaExecInputs)
862
863
 
863
864
  self := undefined
864
865
  self = ll.toStrict(oop.inherit(tpl, {
@@ -24,6 +24,10 @@ _INPUT_PACKAGE_NAME := "packageName"
24
24
  _INPUT_REGISTRY := "registry"
25
25
  _OUTPUT_ARCHIVE := "archive"
26
26
 
27
+ DEFAULT_ALLOCATION_QUEUE := "light"
28
+ DEFAULT_ALLOCATION_RAM := "1GiB"
29
+ DEFAULT_ALLOCATION_CPU := 1
30
+
27
31
  get := func(registryName, pkgName) {
28
32
  res := smart.structBuilder(_RTYPE_PACKAGE_GET)
29
33
 
@@ -163,7 +167,11 @@ pkgFileLoader := func(pkg) {
163
167
  },
164
168
 
165
169
  load: func() {
166
- wd := workdir.create()
170
+ wd := workdir.builder().
171
+ inQueue(DEFAULT_ALLOCATION_QUEUE).
172
+ cpu(DEFAULT_ALLOCATION_CPU).
173
+ mem(DEFAULT_ALLOCATION_RAM).
174
+ build()
167
175
 
168
176
  allPaths := sets.fromSlice(filePaths)
169
177
  allPaths = sets.add(allPaths, fileContentPaths...)
@@ -261,6 +269,10 @@ export ll.toStrict({
261
269
 
262
270
  META_KEY_DESCRIPTOR : META_KEY_DESCRIPTOR,
263
271
 
272
+ DEFAULT_ALLOCATION_QUEUE : DEFAULT_ALLOCATION_QUEUE,
273
+ DEFAULT_ALLOCATION_RAM : DEFAULT_ALLOCATION_RAM,
274
+ DEFAULT_ALLOCATION_CPU : DEFAULT_ALLOCATION_CPU,
275
+
264
276
  get : get,
265
277
  install : install,
266
278
  use : use,
@@ -617,11 +617,8 @@ builder := func(workdir, ...initialState) {
617
617
 
618
618
  runRes = smart.ephemeralBuilder(_RTYPE_RUN_COMMAND_BATCH_V2)
619
619
 
620
- } else if feats.computeLimits {
621
- runRes = smart.ephemeralBuilder(_RTYPE_RUN_COMMAND_EXEC_V2)
622
-
623
620
  } else {
624
- runRes = smart.ephemeralBuilder(_RTYPE_RUN_COMMAND_V1)
621
+ runRes = smart.ephemeralBuilder(_RTYPE_RUN_COMMAND_EXEC_V2)
625
622
  }
626
623
 
627
624
  runRes.getField(_FIELD_WORKDIR_IN).set(workdir)
@@ -36,6 +36,7 @@ exportColumnData := func(data) {
36
36
 
37
37
 
38
38
 
39
+
39
40
  pColumnResourceMapDataBuilder := func(keyLength) {
40
41
  ll.panic("pframes.pColumnResourceMapDataBuilder is not supported any more; use pcolumn.resourceMapBuilder")
41
42
  }
@@ -182,6 +183,10 @@ __primitiveValueTypes := { "Int": true, "Long": true, "Float": true, "Double": t
182
183
 
183
184
 
184
185
 
186
+
187
+
188
+
189
+
185
190
 
186
191
 
187
192
 
@@ -261,6 +266,11 @@ processColumn := func(input, bodyTpl, outputs, ...opts) {
261
266
  extra = {}
262
267
  }
263
268
 
269
+ metaExtra := opts.metaExtra
270
+ if is_undefined(metaExtra) {
271
+ metaExtra = {}
272
+ }
273
+
264
274
  iterationAxesSpec := input.spec.axesSpec
265
275
 
266
276
 
@@ -372,6 +382,10 @@ processColumn := func(input, bodyTpl, outputs, ...opts) {
372
382
  renderInputs["__extra_" + k] = v
373
383
  }
374
384
 
385
+ for k, v in metaExtra {
386
+ renderInputs["__meta_" + k] = v
387
+ }
388
+
375
389
  renderResult := render.createEphemeral(llProcessTpl, renderInputs)
376
390
 
377
391
  self := undefined
@@ -29,7 +29,7 @@ _SUBSCRIPTION_FIELD := "subscription"
29
29
 
30
30
 
31
31
  createUniversal := func(tpl, isEph, inputs, ...opts) {
32
- serviceInputs := opts[0]
32
+ metaInputs := opts[0]
33
33
 
34
34
 
35
35
  rbuilder := undefined
@@ -54,10 +54,10 @@ createUniversal := func(tpl, isEph, inputs, ...opts) {
54
54
  inputsMap.add(name, value)
55
55
  }
56
56
  }
57
- for name, value in serviceInputs {
57
+ for name, value in metaInputs {
58
58
  if !is_undefined(value) {
59
59
  if feats.serviceFields {
60
- inputsMap.addService(name, value)
60
+ inputsMap.addMeta(name, value)
61
61
  } else {
62
62
  inputsMap.add(name, value)
63
63
  }
@@ -160,6 +160,7 @@ _getFutureField := func(from, name, fieldType, isEph) {
160
160
 
161
161
 
162
162
 
163
+
163
164
  _buildFutureField := func(resourceOrField, nameOrPath, ...eph) {
164
165
  globalIsEph := undefined
165
166
  if len(eph) > 0 && is_bool(eph[0]) {
@@ -517,19 +518,20 @@ resource = func(r) {
517
518
  },
518
519
 
519
520
 
520
- _serviceInputs: undefined,
521
+ _metaInputs: undefined,
521
522
 
522
523
 
523
524
 
524
- serviceInputs: func() {
525
- if self._serviceInputs == undefined {
525
+
526
+ metaInputs: func() {
527
+ if self._metaInputs == undefined {
526
528
  info := self.info()
527
529
 
528
530
  if !maps.containsKey(info, "ServiceFields") {
529
531
 
530
532
 
531
- self._serviceInputs = {}
532
- return self._serviceInputs
533
+ self._metaInputs = {}
534
+ return self._metaInputs
533
535
  }
534
536
 
535
537
  svcs := maps.mapValues(info.ServiceFields, field)
@@ -537,9 +539,17 @@ resource = func(r) {
537
539
  if !info.InputsLocked {
538
540
  return svcs
539
541
  }
540
- self._serviceInputs = svcs
542
+ self._metaInputs = svcs
541
543
  }
542
- return self._serviceInputs
544
+ return self._metaInputs
545
+ },
546
+
547
+
548
+
549
+
550
+
551
+ serviceInputs: func() {
552
+ return self.metaInputs()
543
553
  },
544
554
 
545
555
 
@@ -1211,7 +1221,7 @@ resourceBuilder = func(r) {
1211
1221
 
1212
1222
 
1213
1223
 
1214
- createServiceField: func(name) {
1224
+ createMetaField: func(name) {
1215
1225
  assertNotBuilt()
1216
1226
  return self.createField(name, constants.FTYPE_SERVICE)
1217
1227
  },
@@ -1221,6 +1231,17 @@ resourceBuilder = func(r) {
1221
1231
 
1222
1232
 
1223
1233
 
1234
+
1235
+
1236
+ createServiceField: func(name) {
1237
+ return self.createMetaField(name)
1238
+ },
1239
+
1240
+
1241
+
1242
+
1243
+
1244
+
1224
1245
  createInputField: func(name) {
1225
1246
  assertNotBuilt()
1226
1247
  return self.createField(name, constants.FTYPE_INPUT)
@@ -1380,8 +1401,8 @@ _mapBuilder := func(isEph, ...resourceType) {
1380
1401
 
1381
1402
 
1382
1403
 
1383
- addService: func(key, value) {
1384
- builder.createServiceField(key).setRefOrJson(value)
1404
+ addMeta: func(key, value) {
1405
+ builder.createMetaField(key).setRefOrJson(value)
1385
1406
  return self
1386
1407
  },
1387
1408
 
@@ -1390,6 +1411,19 @@ _mapBuilder := func(isEph, ...resourceType) {
1390
1411
 
1391
1412
 
1392
1413
 
1414
+
1415
+
1416
+
1417
+
1418
+ addService: func(key, value) {
1419
+ return self.addMeta(key, value)
1420
+ },
1421
+
1422
+
1423
+
1424
+
1425
+
1426
+
1393
1427
  build: func() {
1394
1428
  return builder.lockAndBuild()
1395
1429
  }
@@ -68,9 +68,9 @@ _unmarshal := func(resource, preprocessors) {
68
68
  }
69
69
  }
70
70
 
71
- for field, value in resource.serviceInputs() {
71
+ for field, value in resource.metaInputs() {
72
72
  if value.isErrorSet() {
73
- ll.panic("service input %v field has error: %v", field, field.getError().getDataAsJson().message)
73
+ ll.panic("meta input %v field has error: %v", field, field.getError().getDataAsJson().message)
74
74
  } else if value.isSet() {
75
75
  result[field] = _unmarshal(value.getValue(), preprocessors)
76
76
  } else {
@@ -183,8 +183,16 @@ tpl := func(ops) {
183
183
 
184
184
 
185
185
 
186
+
186
187
  rawServiceInputs: func() {
187
- return self.renderer().get(tplutil.INPUTS_MAP_FIELD).serviceInputs()
188
+ return self.rawMetaInputs()
189
+ },
190
+
191
+
192
+
193
+
194
+ rawMetaInputs: func() {
195
+ return self.renderer().get(tplutil.INPUTS_MAP_FIELD).metaInputs()
188
196
  },
189
197
 
190
198
 
@@ -395,8 +403,8 @@ tpl := func(ops) {
395
403
 
396
404
  inputs := self.inputs()
397
405
 
398
- if len(self.rawServiceInputs()) > 0 {
399
- ll.panic("prepare() statement is not available for templates with service inputs in this verson of workflow-tengo SDK")
406
+ if len(self.rawMetaInputs()) > 0 {
407
+ ll.panic("prepare() statement is not available for templates with meta inputs in this verson of workflow-tengo SDK")
400
408
  }
401
409
 
402
410
 
@@ -648,6 +656,7 @@ tpl := func(ops) {
648
656
  registerUnmarshaller : self.registerUnmarshaller,
649
657
  rawInputs : self.rawInputs,
650
658
  rawServiceInputs : self.rawServiceInputs,
659
+ rawMetaInputs : self.rawMetaInputs,
651
660
  hasInput : self.hasInput,
652
661
  inputs : self.inputs,
653
662
  defineOutputs : self.defineOutputs,
@@ -5,8 +5,9 @@
5
5
  json := import("json")
6
6
 
7
7
  ll := import("@platforma-sdk/workflow-tengo:ll")
8
- feats := import("@platforma-sdk/workflow-tengo:feats")
9
8
  validation := import("@platforma-sdk/workflow-tengo:validation")
9
+ limits := import("@platforma-sdk/workflow-tengo:exec.limits")
10
+ execConstants := import("@platforma-sdk/workflow-tengo:exec.constants")
10
11
 
11
12
  assets := import("@platforma-sdk/workflow-tengo:assets")
12
13
  constants := import("@platforma-sdk/workflow-tengo:constants")
@@ -29,23 +30,12 @@ _WD_FILL_FIELD_WORKDIR_OUT := "workdirOut"
29
30
 
30
31
 
31
32
 
32
- create := func() {
33
-
34
- wdCreate := smart.ephemeralBuilder(constants.RTYPE_WORKDIR_CREATE).lockAndBuild()
35
- return wdCreate.getField(_WD_CREATE_FIELD_WORKDIR)
36
- }
37
-
38
-
39
-
40
33
 
41
34
 
42
35
 
43
-
44
-
45
-
46
- createV2 := func(allocation) {
36
+ createV2 := func(allocationRef) {
47
37
  wdCreate := smart.ephemeralBuilder(constants.RTYPE_WORKDIR_CREATE_2).lockAndBuild()
48
- wdCreate.getField(_WD_CREATE_FIELD_ALLOCATION).set(allocation)
38
+ wdCreate.getField(_WD_CREATE_FIELD_ALLOCATION).set(allocationRef)
49
39
 
50
40
  return wdCreate.getField(_WD_CREATE_FIELD_WORKDIR)
51
41
  }
@@ -121,13 +111,17 @@ _fill := func() {
121
111
  wd := smart.ephemeralBuilder(constants.RTYPE_WORKDIR_FILL)
122
112
 
123
113
 
124
- _allocation := undefined
114
+ _allocationRef := undefined
125
115
  blobs := {}
126
116
  files := {}
127
117
  zipExtractions := {}
128
118
  values := {}
129
119
  dirs := {}
130
120
 
121
+ queue := undefined
122
+ cpu := undefined
123
+ ram := undefined
124
+
131
125
  self := undefined
132
126
  self = ll.toStrict(oop.inherit(wd, {
133
127
  _getAllDirs: func(fileName) {
@@ -145,9 +139,49 @@ _fill := func() {
145
139
 
146
140
 
147
141
 
148
- allocation: func(allocation) {
149
- validation.assertType(allocation, validation.reference, "workdir.builder: allocation should be a valid reference")
150
- _allocation = allocation
142
+ allocation: func(ref) {
143
+ validation.assertType(ref, validation.reference, "workdir.builder: allocation should be a valid reference")
144
+ _allocationRef = ref
145
+ return self
146
+ },
147
+
148
+
149
+
150
+
151
+
152
+
153
+ inQueue: func(queueName) {
154
+ queue = queueName
155
+ return self
156
+ },
157
+
158
+
159
+
160
+
161
+
162
+
163
+ mem: func(value) {
164
+ if is_undefined(value) {
165
+ return self
166
+ }
167
+ validation.assertType(value, ["or", "number", "string"], "workdir.builder.mem: RAM amount should be a number or string")
168
+ ll.assert(is_string(value) || value > 0, "workdir.builder.mem: amount in bytes should be greater than 0")
169
+ ram = value
170
+ return self
171
+ },
172
+
173
+
174
+
175
+
176
+
177
+
178
+ cpu: func(value) {
179
+ if is_undefined(value) {
180
+ return self
181
+ }
182
+ validation.assertType(value, "number", "workdir.builder.cpu: value must be a number")
183
+ cpu = value
184
+ return self
151
185
  },
152
186
 
153
187
 
@@ -269,13 +303,41 @@ _fill := func() {
269
303
 
270
304
 
271
305
  build: func() {
272
- emptyWorkdir := undefined
273
- if feats.workdirLimits && smart.isReference(_allocation) {
274
- emptyWorkdir = createV2(_allocation)
275
- } else {
276
- emptyWorkdir = create()
306
+ ll.assert(!is_undefined(_allocationRef) || !is_undefined(queue),
307
+ "workdir.builder: either allocation or queue must be provided")
308
+ ll.assert(is_undefined(_allocationRef) || is_undefined(queue),
309
+ "workdir.builder: allocation and queue must not be set at the same time")
310
+
311
+ if !is_undefined(_allocationRef) {
312
+ ll.assert(is_undefined(cpu) && is_undefined(ram),
313
+ "workdir.builder: cpu and ram cannot be set when allocation is provided")
314
+ }
315
+
316
+ allocationRef := _allocationRef
317
+ if is_undefined(allocationRef) {
318
+ quotaBuilder := limits.quotaBuilder()
319
+ if !is_undefined(cpu) {
320
+ quotaBuilder.cpu(cpu)
321
+ }
322
+ if !is_undefined(ram) {
323
+ quotaBuilder.ram(ram)
324
+ }
325
+
326
+ if limits.useBatch(queue) {
327
+ quotaBuilder.queue(execConstants.BATCH_QUEUE)
328
+ } else {
329
+ quotaBuilder.queue(queue)
330
+ }
331
+
332
+ storageSpaceRef := limits.storageSpaceRequestBuilder().
333
+ quota(quotaBuilder.build()).
334
+ build()
335
+
336
+ allocationRef = storageSpaceRef.allocation
277
337
  }
278
338
 
339
+ emptyWorkdir := createV2(allocationRef)
340
+
279
341
  wd.getField(_WD_FILL_FIELD_WORKDIR_IN).set(emptyWorkdir)
280
342
 
281
343
  rules := []
@@ -422,7 +484,6 @@ save := func(workdir) {
422
484
 
423
485
  export ll.toStrict({
424
486
  builder: builder,
425
- create: create,
426
487
  createV2: createV2,
427
488
  save: save
428
489
  })
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/workflow-tengo",
3
- "version": "4.9.0",
3
+ "version": "4.9.2",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",