@platforma-sdk/workflow-tengo 4.9.1 → 4.9.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.
Files changed (43) 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 +7 -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/validation.lib.tengo +2 -0
  9. package/dist/tengo/lib/workdir.lib.tengo +85 -24
  10. package/dist/tengo/tpl/check_network.create_workdir_from_storage.plj.gz +0 -0
  11. package/dist/tengo/tpl/check_network.download_blob.plj.gz +0 -0
  12. package/dist/tengo/tpl/check_network.run_hello_world.plj.gz +0 -0
  13. package/dist/tengo/tpl/check_network.run_hello_world_py.plj.gz +0 -0
  14. package/dist/tengo/tpl/check_network.upload_blob.plj.gz +0 -0
  15. package/dist/tengo/tpl/check_network.upload_template.plj.gz +0 -0
  16. package/dist/tengo/tpl/check_network.workdir_type_name_extractor.plj.gz +0 -0
  17. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  18. package/dist/tengo/tpl/exec.delayed-compute-allocation.impl.plj.gz +0 -0
  19. package/dist/tengo/tpl/exec.exec-impl.plj.gz +0 -0
  20. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  21. package/dist/tengo/tpl/exec.load-software.impl.plj.gz +0 -0
  22. package/dist/tengo/tpl/exec.monetization_info.plj.gz +0 -0
  23. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  24. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  25. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  26. package/dist/tengo/tpl/exec.python.venv-bin-path.plj.gz +0 -0
  27. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  28. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  29. package/dist/tengo/tpl/pframes.export-pframe-for-ui.plj.gz +0 -0
  30. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  31. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  32. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  33. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  34. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  35. package/dist/tengo/tpl/pframes.slice-data.plj.gz +0 -0
  36. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  37. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  38. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  39. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  40. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  41. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  42. package/dist/tengo/tpl/workflow.query-anchored.plj.gz +0 -0
  43. package/package.json +2 -2
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
 
@@ -826,16 +825,15 @@ builder := func() {
826
825
  assetCache: assetCache
827
826
  }
828
827
 
829
- serviceExecInputs := {}
830
- if feats.workdirLimits || feats.computeLimits || limits.useBatch(queue) {
831
- if (is_int(ramRequest)) {
832
- ramRequest = string(ramRequest) + "b"
833
- }
834
- serviceExecInputs.quota = {
828
+ if (is_int(ramRequest)) {
829
+ ramRequest = string(ramRequest) + "b"
830
+ }
831
+ metaExecInputs := {
832
+ quota: smart.createJsonResource({
835
833
  queue: queue,
836
834
  cpu: cpuRequest,
837
835
  ram: ramRequest
838
- }
836
+ })
839
837
  }
840
838
 
841
839
 
@@ -861,7 +859,7 @@ builder := func() {
861
859
  }
862
860
  }
863
861
 
864
- 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)
865
863
 
866
864
  self := undefined
867
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)
@@ -364,6 +364,8 @@ assert := func(condition, msg, ...args) {
364
364
 
365
365
 
366
366
 
367
+
368
+
367
369
  assertType := func(value, schema, ...failMsg) {
368
370
  r := _validateJson(value, schema, "")
369
371
 
@@ -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.1",
3
+ "version": "4.9.3",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "@platforma-open/milaboratories.software-ptabler": "1.6.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@platforma-sdk/tengo-builder": "^2.1.11"
24
+ "@platforma-sdk/tengo-builder": "^2.1.12"
25
25
  },
26
26
  "scripts": {
27
27
  "type-check": "pl-tengo check",