@platforma-sdk/workflow-tengo 4.7.1 → 4.7.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 (36) hide show
  1. package/dist/tengo/lib/exec.lib.tengo +23 -3
  2. package/dist/tengo/lib/feats.lib.tengo +6 -1
  3. package/dist/tengo/lib/ll.lib.tengo +138 -1
  4. package/dist/tengo/lib/pt.lib.tengo +72 -1
  5. package/dist/tengo/lib/smart.lib.tengo +55 -1
  6. package/dist/tengo/lib/tpl.state-await.lib.tengo +1 -1
  7. package/dist/tengo/tpl/check_network.create_workdir_from_storage.plj.gz +0 -0
  8. package/dist/tengo/tpl/check_network.download_blob.plj.gz +0 -0
  9. package/dist/tengo/tpl/check_network.run_hello_world.plj.gz +0 -0
  10. package/dist/tengo/tpl/check_network.run_hello_world_py.plj.gz +0 -0
  11. package/dist/tengo/tpl/check_network.upload_blob.plj.gz +0 -0
  12. package/dist/tengo/tpl/check_network.upload_template.plj.gz +0 -0
  13. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  14. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  15. package/dist/tengo/tpl/exec.monetization_info.plj.gz +0 -0
  16. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  17. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  18. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  19. package/dist/tengo/tpl/exec.python.venv-bin-path.plj.gz +0 -0
  20. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  21. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  22. package/dist/tengo/tpl/pframes.export-pframe-for-ui.plj.gz +0 -0
  23. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  24. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  25. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  26. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  27. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  28. package/dist/tengo/tpl/pframes.slice-data.plj.gz +0 -0
  29. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  30. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  31. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  32. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  33. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  34. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  35. package/dist/tengo/tpl/workflow.query-anchored.plj.gz +0 -0
  36. package/package.json +2 -2
@@ -219,6 +219,16 @@ builder := func() {
219
219
 
220
220
 
221
221
 
222
+
223
+
224
+ setQueue: func(newQueue) {
225
+ queue = newQueue
226
+ return self
227
+ },
228
+
229
+
230
+
231
+
222
232
  inHeavyQueue: func() {
223
233
  queue = execConstants.HEAVY_QUEUE
224
234
  return self
@@ -272,9 +282,9 @@ builder := func() {
272
282
 
273
283
 
274
284
 
275
- ram: func(amount) {
276
- validation.assertType(amount, ["or", "number", "string"], "exec.builder.ram: RAM amount should be a number or string")
277
- ll.assert(is_string(amount) || amount > 0, "exec.builder.ram: amount in bytes should be greater than 0")
285
+ mem: func(amount) {
286
+ validation.assertType(amount, ["or", "number", "string"], "exec.builder.mem: RAM amount should be a number or string")
287
+ ll.assert(is_string(amount) || amount > 0, "exec.builder.mem: amount in bytes should be greater than 0")
278
288
  ramRequest = amount
279
289
 
280
290
  return self
@@ -285,6 +295,16 @@ builder := func() {
285
295
 
286
296
 
287
297
 
298
+ ram: func(amount) {
299
+ self.mem(amount)
300
+ return self
301
+ },
302
+
303
+
304
+
305
+
306
+
307
+
288
308
 
289
309
  cache: func(time) {
290
310
  ll.assert(
@@ -38,5 +38,10 @@ export ll.toStrict({
38
38
  commandExpressions: _isEnabled("commandExpressions") || _api >= 2, // rich expressions in command arguments ( {{ system.ram_bytes / 20 }} )
39
39
  workdirLimits: _isEnabled("workdirLimits") || _api >= 4, // workdir storage controller can limit concurrency
40
40
  computeLimits: _isEnabled("computeLimits"), // runner can plan CPU and RAM
41
- resourceDuplicateEvent: false // template can subscribe to ResourceDuplicate event
41
+
42
+
43
+
44
+
45
+
46
+ fullFeaturedApi: _isEnabled("fullFeaturedAPI")
42
47
  })
@@ -289,10 +289,137 @@ parseUrl := func(url) {
289
289
 
290
290
 
291
291
 
292
+
293
+
292
294
  getCtx := func() {
295
+ if methodExists(plapi, "getPersistentCtx") {
296
+ return plapi.getPersistentCtx()
297
+ }
298
+
299
+
300
+ return plapi.getCtx()
301
+ }
302
+
303
+
304
+
305
+
306
+
307
+ getPersistentCtx := func() {
308
+ if methodExists(plapi, "getPersistentCtx") {
309
+ return plapi.getPersistentCtx()
310
+ }
311
+
312
+
293
313
  return plapi.getCtx()
294
314
  }
295
315
 
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+ getExecutionCtx := func() {
327
+ assert(methodExists(plapi, "getExecutionCtx"), "ll.getExecutionCtx: method does not exists in this backend instance.")
328
+ return plapi.getExecutionCtx()
329
+ }
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+ moduleVars := func(moduleName) {
338
+ assert(is_string(moduleName), "ll.moduleVars: moduleName must be a string")
339
+
340
+ name := "module/" + moduleName
341
+
342
+ ctx := getExecutionCtx()
343
+ if is_undefined(ctx[name]) {
344
+ ctx[name] = {}
345
+ }
346
+
347
+ return {
348
+ get: func(k) {
349
+ return ctx[name][k]
350
+ },
351
+
352
+ set: func(k, v) {
353
+ ctx[name][k] = v
354
+ }
355
+ }
356
+ }
357
+
358
+
359
+
360
+
361
+ sha256Encode := func(b) {
362
+ assert(methodExists(plapi, "sha256Encode"), "ll.sha256Encode: method does not exists in this backend instance.")
363
+ return plapi.sha256Encode(b)
364
+ }
365
+
366
+
367
+
368
+
369
+ gzipEncode := func(b) {
370
+ assert(methodExists(plapi, "gzipEncode"), "ll.gzipEncode: method does not exists in this backend instance.")
371
+ return plapi.gzipEncode(b)
372
+ }
373
+
374
+
375
+
376
+
377
+ gzipDecode := func(b) {
378
+ assert(methodExists(plapi, "gzipDecode"), "ll.gzipDecode: method does not exists in this backend instance.")
379
+ return plapi.gzipDecode(b)
380
+ }
381
+
382
+
383
+
384
+
385
+ base32Encode := func(b) {
386
+ assert(methodExists(plapi, "base32Encode"), "ll.base32Encode: method does not exists in this backend instance.")
387
+ return plapi.base32Encode(b)
388
+ }
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+ base32HexEncode := func(b) {
398
+ assert(methodExists(plapi, "base32HexEncode"), "ll.base32HexEncode: method does not exists in this backend instance.")
399
+ return plapi.base32HexEncode(b)
400
+ }
401
+
402
+
403
+
404
+
405
+ base32Decode := func(s) {
406
+ assert(methodExists(plapi, "base32Decode"), "ll.base32Decode: method does not exists in this backend instance.")
407
+ return plapi.base32Decode(s)
408
+ }
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+ base32HexDecode := func(s) {
418
+ assert(methodExists(plapi, "base32HexDecode"), "ll.base32HexDecode: method does not exists in this backend instance.")
419
+ return plapi.base32HexDecode(s)
420
+ }
421
+
422
+
296
423
  export toStrict({
297
424
  apiVersion: apiVersion,
298
425
  print: print,
@@ -315,5 +442,15 @@ export toStrict({
315
442
  pathSeparator: pathSeparator,
316
443
  filepathCanonize: filepathCanonize,
317
444
  parseUrl: parseUrl,
318
- getCtx: getCtx
445
+ getCtx: getCtx,
446
+ getPersistentCtx: getPersistentCtx,
447
+ getExecutionCtx: getExecutionCtx,
448
+ moduleVars: moduleVars,
449
+ sha256Encode: sha256Encode,
450
+ gzipEncode: gzipEncode,
451
+ gzipDecode: gzipDecode,
452
+ base32Encode: base32Encode,
453
+ base32HexEncode: base32HexEncode,
454
+ base32Decode: base32Decode,
455
+ base32HexDecode: base32HexDecode
319
456
  })
@@ -6,6 +6,7 @@ exec := import("@platforma-sdk/workflow-tengo:exec")
6
6
  json := import("json")
7
7
  text := import("text")
8
8
  slices := import("@platforma-sdk/workflow-tengo:slices")
9
+ execConstants := import("@platforma-sdk/workflow-tengo:exec.constants")
9
10
 
10
11
 
11
12
 
@@ -67,6 +68,10 @@ workflow := func() {
67
68
  anonymousFilesCounter := 0
68
69
  anonymousDFCounter := 0
69
70
 
71
+ cpu := undefined
72
+ mem := undefined
73
+ queue := execConstants.MEDIUM_QUEUE
74
+
70
75
  self := undefined
71
76
 
72
77
  id := workflowCounter
@@ -266,13 +271,71 @@ workflow := func() {
266
271
 
267
272
 
268
273
 
274
+ inHeavyQueue: func() {
275
+ queue = execConstants.HEAVY_QUEUE
276
+ return self
277
+ },
278
+
279
+
280
+
281
+
282
+ inMediumQueue: func() {
283
+ queue = execConstants.MEDIUM_QUEUE
284
+ return self
285
+ },
286
+
287
+
288
+
289
+
290
+ inLightQueue: func() {
291
+ queue = execConstants.LIGHT_QUEUE
292
+ return self
293
+ },
294
+
295
+
296
+
297
+
298
+ inUiQueue: func() {
299
+ queue = execConstants.UI_TASKS_QUEUE
300
+ return self
301
+ },
302
+
303
+
304
+
305
+
306
+
307
+
308
+ cpu: func(amount) {
309
+ cpu = amount
310
+ return self
311
+ },
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+ mem: func(amount) {
325
+ mem = amount
326
+ return self
327
+ },
328
+
329
+
330
+
331
+
269
332
 
270
333
 
271
334
 
272
335
  run: func() {
273
336
  ptablerSw := assets.importSoftware("@platforma-open/milaboratories.software-ptabler:main")
274
337
  ptablerCmdBuilder := exec.builder().
275
- inMediumQueue().
338
+ setQueue(queue).
276
339
  printErrStreamToStdout().
277
340
  dontSaveStdoutOrStderr().
278
341
  software(ptablerSw).
@@ -281,6 +344,14 @@ workflow := func() {
281
344
  workflow: steps
282
345
  }));
283
346
 
347
+ if !is_undefined(cpu) {
348
+ ptablerCmdBuilder.cpu(cpu)
349
+ }
350
+
351
+ if !is_undefined(mem) {
352
+ ptablerCmdBuilder.mem(mem)
353
+ }
354
+
284
355
  for inFile in inFiles {
285
356
  if !is_undefined(inFile.file) {
286
357
  ptablerCmdBuilder.addFile(inFile.name, inFile.file)
@@ -362,6 +362,13 @@ resource = func(r) {
362
362
 
363
363
 
364
364
 
365
+
366
+
367
+
368
+
369
+
370
+
371
+
365
372
 
366
373
 
367
374
 
@@ -390,7 +397,14 @@ resource = func(r) {
390
397
 
391
398
 
392
399
  isFinal: func() {
393
- return self.info().ResourceReady || self.info().IsDuplicate || self.info().HasErrors
400
+
401
+ if false {
402
+ return self.info().IsFinal
403
+ }
404
+
405
+ info := self.info()
406
+
407
+ return info.ResourceReady || info.IsDuplicate || info.HasErrors
394
408
  },
395
409
 
396
410
  isEphemeral: func() {
@@ -702,6 +716,8 @@ resource = func(r) {
702
716
 
703
717
 
704
718
 
719
+
720
+
705
721
  kvGet: func(key) {
706
722
  return tx.resourceKeyValueGet(self.id, key)
707
723
  },
@@ -712,6 +728,17 @@ resource = func(r) {
712
728
 
713
729
 
714
730
 
731
+ kvGetFlag: func(key) {
732
+ ll.assert(feats.fullFeaturedApi, "smart.resource.kvGetFlag: the feature is not available on older backends. Please, update the backend.")
733
+ return tx.resourceKeyValueGetFlag(self.id, key)
734
+ },
735
+
736
+
737
+
738
+
739
+
740
+
741
+
715
742
 
716
743
  kvSet: func(key, value) {
717
744
  tx.resourceKeyValueSet(self.id, key, value)
@@ -723,6 +750,17 @@ resource = func(r) {
723
750
 
724
751
 
725
752
 
753
+ kvSetFlag: func(key, flag) {
754
+ ll.assert(feats.fullFeaturedApi, "smart.resource.kvSetFlag: the feature is not available on older backends. Please, update the backend.")
755
+ tx.resourceKeyValueSetFlag(self.id, key, flag)
756
+ },
757
+
758
+
759
+
760
+
761
+
762
+
763
+
726
764
 
727
765
  kvGetAsString: func(key) {
728
766
  value := tx.resourceKeyValueGet(self.id, key)
@@ -1108,6 +1146,22 @@ field = func(f) {
1108
1146
 
1109
1147
  buildFutureField: func(nameOrPath) {
1110
1148
  return _buildFutureField(strictSelf, nameOrPath)
1149
+ },
1150
+
1151
+
1152
+
1153
+
1154
+ reset: func() {
1155
+ ll.assert(feats.fullFeaturedApi, "smart.field.reset: the feature is not available on older backends. Please, update the backend.")
1156
+ tx.resetField(self.id)
1157
+ },
1158
+
1159
+
1160
+
1161
+
1162
+ remove: func() {
1163
+ ll.assert(feats.fullFeaturedApi, "smart.field.remove: the feature is not available on older backends. Please, update the backend.")
1164
+ tx.removeField(self.id)
1111
1165
  }
1112
1166
  }
1113
1167
 
@@ -261,7 +261,7 @@ await := func(rootField, ctxStorageResource, requests) {
261
261
  targetEvents := [firstSubscription.event]
262
262
 
263
263
  if firstSubscription.event == "Final" { // special case
264
- if !feats.resourceDuplicateEvent {
264
+ if !feats.fullFeaturedApi {
265
265
 
266
266
 
267
267
 
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.7.1",
3
+ "version": "4.7.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.6"
24
+ "@platforma-sdk/tengo-builder": "^2.1.10"
25
25
  },
26
26
  "scripts": {
27
27
  "type-check": "pl-tengo check",