@platforma-sdk/workflow-tengo 2.14.0 → 2.15.1

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 (80) hide show
  1. package/README.md +17 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +3 -1
  4. package/dist/index.mjs +3 -1
  5. package/dist/tengo/lib/assets.lib.tengo +28 -28
  6. package/dist/tengo/lib/assets.swinfo.lib.tengo +24 -24
  7. package/dist/tengo/lib/constants.lib.tengo +6 -3
  8. package/dist/tengo/lib/exec.R.internal.lib.tengo +2 -2
  9. package/dist/tengo/lib/exec.R.lib.tengo +41 -41
  10. package/dist/tengo/lib/exec.descriptor.lib.tengo +3 -3
  11. package/dist/tengo/lib/exec.internal.lib.tengo +41 -41
  12. package/dist/tengo/lib/exec.lib.tengo +289 -289
  13. package/dist/tengo/lib/exec.limits.lib.tengo +49 -49
  14. package/dist/tengo/lib/exec.monetization.lib.tengo +1 -1
  15. package/dist/tengo/lib/exec.monetization_internal.lib.tengo +38 -38
  16. package/dist/tengo/lib/exec.package.lib.tengo +53 -53
  17. package/dist/tengo/lib/exec.python.internal.lib.tengo +1 -1
  18. package/dist/tengo/lib/exec.python.lib.tengo +37 -37
  19. package/dist/tengo/lib/exec.runcmd.lib.tengo +138 -138
  20. package/dist/tengo/lib/exec.runenv.lib.tengo +18 -18
  21. package/dist/tengo/lib/exec.stream.lib.tengo +25 -25
  22. package/dist/tengo/lib/feats.lib.tengo +3 -3
  23. package/dist/tengo/lib/file.internal.lib.tengo +31 -31
  24. package/dist/tengo/lib/file.lib.tengo +29 -29
  25. package/dist/tengo/lib/ll.get-future-field-default.lib.tengo +137 -0
  26. package/dist/tengo/lib/ll.lib.tengo +129 -129
  27. package/dist/tengo/lib/maps.lib.tengo +38 -38
  28. package/dist/tengo/lib/objects.lib.tengo +6 -6
  29. package/dist/tengo/lib/oop.lib.tengo +11 -11
  30. package/dist/tengo/lib/path.lib.tengo +60 -60
  31. package/dist/tengo/lib/pframes.builder.lib.tengo +3 -3
  32. package/dist/tengo/lib/pframes.constants.lib.tengo +20 -20
  33. package/dist/tengo/lib/pframes.export-pcolumn.lib.tengo +5 -5
  34. package/dist/tengo/lib/pframes.lib.tengo +206 -198
  35. package/dist/tengo/lib/pframes.ll.lib.tengo +59 -59
  36. package/dist/tengo/lib/pframes.pcolumn.lib.tengo +18 -18
  37. package/dist/tengo/lib/pframes.remove-nulls.lib.tengo +36 -0
  38. package/dist/tengo/lib/pframes.spec.lib.tengo +83 -83
  39. package/dist/tengo/lib/pframes.util.lib.tengo +176 -176
  40. package/dist/tengo/lib/pframes.xsv-import-file.lib.tengo +160 -0
  41. package/dist/tengo/lib/pframes.xsv.lib.tengo +84 -167
  42. package/dist/tengo/lib/render.lib.tengo +100 -45
  43. package/dist/tengo/lib/sets.lib.tengo +44 -44
  44. package/dist/tengo/lib/slices.lib.tengo +126 -126
  45. package/dist/tengo/lib/smart.lib.tengo +654 -507
  46. package/dist/tengo/lib/test.lib.tengo +120 -120
  47. package/dist/tengo/lib/tpl.lib.tengo +206 -170
  48. package/dist/tengo/lib/tpl.state-await.lib.tengo +17 -17
  49. package/dist/tengo/lib/tpl.util.lib.tengo +5 -5
  50. package/dist/tengo/lib/units.lib.tengo +2 -2
  51. package/dist/tengo/lib/validation.lib.tengo +130 -130
  52. package/dist/tengo/lib/waiter.lib.tengo +13 -13
  53. package/dist/tengo/lib/workdir.lib.tengo +126 -126
  54. package/dist/tengo/lib/workdir.proc.lib.tengo +47 -47
  55. package/dist/tengo/lib/workdir.save.lib.tengo +53 -53
  56. package/dist/tengo/lib/workflow.bobject.lib.tengo +11 -11
  57. package/dist/tengo/lib/workflow.bquery.lib.tengo +40 -40
  58. package/dist/tengo/lib/workflow.constants.lib.tengo +1 -1
  59. package/dist/tengo/lib/workflow.context.lib.tengo +16 -16
  60. package/dist/tengo/lib/workflow.lib.tengo +76 -76
  61. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  62. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  63. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  64. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  65. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  66. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  67. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  68. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  69. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  70. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  71. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  72. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  73. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  74. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  75. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  76. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  77. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  78. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  79. package/package.json +2 -2
  80. package/dist/tengo/tpl/pframes.map-pframe.plj.gz +0 -0
@@ -1,6 +1,6 @@
1
- /**
2
- * A builder for executing commands.
3
- */
1
+
2
+
3
+
4
4
 
5
5
  ll := import("@platforma-sdk/workflow-tengo:ll")
6
6
  feats := import("@platforma-sdk/workflow-tengo:feats")
@@ -21,11 +21,11 @@ limits := import("@platforma-sdk/workflow-tengo:exec.limits")
21
21
  monetization := import("@platforma-sdk/workflow-tengo:exec.monetization_internal")
22
22
  execConstants := import("@platforma-sdk/workflow-tengo:exec.constants")
23
23
 
24
- /**
25
- * Creates a new builder for constructing and executing commands.
26
- *
27
- * @return builder - a new builder instance.
28
- */
24
+
25
+
26
+
27
+
28
+
29
29
  builder := func() {
30
30
  self := undefined
31
31
 
@@ -46,9 +46,9 @@ builder := func() {
46
46
  "either a command with arguments or a software were already set.")
47
47
  }
48
48
 
49
- //
50
- // Limits
51
- //
49
+
50
+
51
+
52
52
  queue := execConstants.HEAVY_QUEUE
53
53
  hasLimits := false
54
54
  cpuRequest := undefined
@@ -57,27 +57,27 @@ builder := func() {
57
57
  cache := 0
58
58
  nErrorLines := 200
59
59
 
60
- // files to be added in workdir
60
+
61
61
  filesToAdd := {}
62
- // files to be created in the workdir with the content from resources
62
+
63
63
  filesToWrite := {}
64
- // directories to create in the workdir
64
+
65
65
  dirsToCreate := {}
66
66
 
67
- // files to save from the workdir
67
+
68
68
  filesToSave := {}
69
- // files which content to save from the workdir
69
+
70
70
  filesContentToSave := {}
71
- // file sets to save by regex
71
+
72
72
  fileSetsToSave := {}
73
- // file sets to save by regex (save file content)
73
+
74
74
  fileSetsContentToSave := {}
75
- // files to stream from the workdir
75
+
76
76
  filesToStream := {}
77
- // workdir processors
77
+
78
78
  wdProcessors := {}
79
79
 
80
- // assets to be extracted into workdir before execution
80
+
81
81
  assetInfos := {}
82
82
  assetDescriptors := {}
83
83
  assetRules := {}
@@ -93,11 +93,11 @@ builder := func() {
93
93
  stderrToStdout := false
94
94
 
95
95
  self = ll.toStrict({
96
- /**
97
- * Sets the command to be executed, e.g. /usr/bin/env or sh.
98
- *
99
- * @param commandName: string - the name of the command.
100
- */
96
+
97
+
98
+
99
+
100
+
101
101
  cmd: func(commandName) {
102
102
  assertEntrypointNotSet()
103
103
 
@@ -106,11 +106,11 @@ builder := func() {
106
106
  return self
107
107
  },
108
108
 
109
- /**
110
- * Sets the software to be executed.
111
- *
112
- * @param software: softwareInfo - the software to execute.
113
- */
109
+
110
+
111
+
112
+
113
+
114
114
  software: func(sw) {
115
115
  assertEntrypointNotSet()
116
116
  ll.assert(assets.isSoftwareInfo(sw),
@@ -122,11 +122,11 @@ builder := func() {
122
122
  return self
123
123
  },
124
124
 
125
- /**
126
- * Adds an argument to the command.
127
- *
128
- * @param arg: string - the argument to add.
129
- */
125
+
126
+
127
+
128
+
129
+
130
130
  arg: func(arg) {
131
131
  ll.assert(is_string(arg), "exec.arg(): argument must be a string, got: %v", arg)
132
132
  args = append(args, arg)
@@ -137,15 +137,15 @@ builder := func() {
137
137
  return self
138
138
  },
139
139
 
140
- /**
141
- * Adds an argument that will be evaluated as expression in the command.
142
- *
143
- * @param arg: string - e.g. -Xms{system.memory_mb * 80 / 100}m
144
- */
140
+
141
+
142
+
143
+
144
+
145
145
  argWithVar: func(arg) {
146
146
  ll.assert(is_string(arg), "exec.argWithVar(): argument with var must be a string, got: %v", arg)
147
147
 
148
- // deprecated: remove ARG_TYPE_VAR and this check after 15 Mar 2025
148
+
149
149
  t := feats.commandExpressions ? execConstants.ARG_TYPE_EXPRESSION : execConstants.ARG_TYPE_VAR
150
150
  argsTyped = append(argsTyped, {
151
151
  type: t,
@@ -156,12 +156,12 @@ builder := func() {
156
156
  return self
157
157
  },
158
158
 
159
- /**
160
- * Sets an environment variable.
161
- *
162
- * @param name: string - the name of the environment variable.
163
- * @param value: string - the value of the environment variable.
164
- */
159
+
160
+
161
+
162
+
163
+
164
+
165
165
  env: func(name, value) {
166
166
  validation.assertType([name, value], ["string"])
167
167
  envs[name] = value
@@ -172,16 +172,16 @@ builder := func() {
172
172
  return self
173
173
  },
174
174
 
175
- /**
176
- * Sets an environment variable.
177
- *
178
- * @param name: string - the name of the environment variable.
179
- * @param value: string - the value of the environment variable.
180
- */
175
+
176
+
177
+
178
+
179
+
180
+
181
181
  envWithVar: func(name, value) {
182
182
  validation.assertType([name, value], ["string"])
183
183
 
184
- // deprecated: remove ARG_TYPE_VAR and this check after 15 Mar 2025
184
+
185
185
  t := feats.commandExpressions ? execConstants.ARG_TYPE_EXPRESSION : execConstants.ARG_TYPE_VAR
186
186
  envsTyped[name] = {
187
187
  type: t,
@@ -192,65 +192,65 @@ builder := func() {
192
192
  return self
193
193
  },
194
194
 
195
- /**
196
- * Sets multiple environment variables.
197
- *
198
- * @param envMap: map[string]string - a map of environment variables.
199
- */
195
+
196
+
197
+
198
+
199
+
200
200
  envMap: func(envMap) {
201
201
  enum.each(envMap, self.env)
202
202
  return self
203
203
  },
204
204
 
205
- /**
206
- * Set environment variable to value of given secret.
207
- *
208
- * @param secretName: string - name of secret to pass as environment variable.
209
- * @param envName: string - name of environment variable to set with value of secret.
210
- */
205
+
206
+
207
+
208
+
209
+
210
+
211
211
  secret: func(secretName, envName) {
212
212
  validation.assertType([secretName, envName], ["string"])
213
213
  secrets[envName] = "{secrets."+secretName+"}"
214
214
  return self
215
215
  },
216
216
 
217
- /**
218
- * Execute command in the 'heavy' queue.
219
- */
217
+
218
+
219
+
220
220
  inHeavyQueue: func() {
221
221
  queue = execConstants.HEAVY_QUEUE
222
222
  return self
223
223
  },
224
224
 
225
- /**
226
- * Execute command in the 'medium' queue.
227
- */
225
+
226
+
227
+
228
228
  inMediumQueue: func() {
229
229
  queue = execConstants.MEDIUM_QUEUE
230
230
  return self
231
231
  },
232
232
 
233
- /**
234
- * Execute command in the 'light' queue.
235
- */
233
+
234
+
235
+
236
236
  inLightQueue: func() {
237
237
  queue = execConstants.LIGHT_QUEUE
238
238
  return self
239
239
  },
240
240
 
241
- /**
242
- * Execute command in the 'ui-tasks' queue.
243
- */
241
+
242
+
243
+
244
244
  inUiQueue: func() {
245
245
  queue = execConstants.UI_TASKS_QUEUE
246
246
  return self
247
247
  },
248
248
 
249
- /**
250
- * Preserve CPUs in environments that plan CPU resources (like PBS or Slurm).
251
- *
252
- * @param amount: number - number of cores requested for command.
253
- */
249
+
250
+
251
+
252
+
253
+
254
254
  cpu: func(amount) {
255
255
  validation.assertType(amount, "number", "exec.builder.cpu: amount of cores must be a number")
256
256
  ll.assert(amount > 0, "exec.builder.cpu: amount of cores should be greater than 0")
@@ -260,17 +260,17 @@ builder := func() {
260
260
  return self
261
261
  },
262
262
 
263
- /**
264
- * Amount of RAM to request.
265
- *
266
- * @param amount: number | string - amount of RAM in bytes or string with size suffix (case-insensitive):
267
- * K, KB, M, MB, G, GB for base-10 sizes (x1000)
268
- * Ki, KiB, Mi, MiB, Gi, GiB for base-2 sizes (x1024)
269
- * when operating with bytes, you may use 'units' package for convenience:
270
- * 120 * units.GiB
271
- *
272
- * @return builder
273
- */
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
274
  ram: func(amount) {
275
275
  validation.assertType(amount, ["or", "number", "string"], "exec.builder.ram: RAM amount should be a number or string")
276
276
  ll.assert(is_string(amount) || amount > 0, "exec.builder.ram: amount in bytes should be greater than 0")
@@ -280,12 +280,12 @@ builder := func() {
280
280
  return self
281
281
  },
282
282
 
283
- /**
284
- * Use cacheMillis, cacheSeconds, cacheMinutes, cacheHours and cacheDays to not make hidden mistakes in cache time ranges.
285
- * Sets the cache time.
286
- *
287
- * @param time: duration - the cache time from 'times' library.
288
- */
283
+
284
+
285
+
286
+
287
+
288
+
289
289
  cache: func(time) {
290
290
  ll.assert(
291
291
  is_int(time),
@@ -295,66 +295,66 @@ builder := func() {
295
295
  return self
296
296
  },
297
297
 
298
- /**
299
- * Sets the cache time in milliseconds.
300
- *
301
- * @param millis: number
302
- */
298
+
299
+
300
+
301
+
302
+
303
303
  cacheMillis: func(millis) {
304
304
  ll.assert(is_int(millis) && millis > 0, "cache time must be a number of milliseconds")
305
305
  cache = millis * times.millisecond
306
306
  return self
307
307
  },
308
308
 
309
- /**
310
- * Sets the cache time in seconds.
311
- *
312
- * @param seconds: number
313
- */
309
+
310
+
311
+
312
+
313
+
314
314
  cacheSeconds: func(seconds) {
315
315
  ll.assert(is_int(seconds) && seconds > 0, "cache time must be a number of seconds")
316
316
  cache = seconds * times.second
317
317
  return self
318
318
  },
319
319
 
320
- /**
321
- * Sets the cache time in minutes.
322
- *
323
- * @param minutes: number
324
- */
320
+
321
+
322
+
323
+
324
+
325
325
  cacheMinutes: func(minutes) {
326
326
  ll.assert(is_int(minutes) && minutes > 0, "cache time must be a number of minutes")
327
327
  cache = minutes * times.minute
328
328
  return self
329
329
  },
330
330
 
331
- /**
332
- * Sets the cache time in hours.
333
- *
334
- * @param hours: number
335
- */
331
+
332
+
333
+
334
+
335
+
336
336
  cacheHours: func(hours) {
337
337
  ll.assert(is_int(hours) && hours > 0, "cache time must be a number of hours")
338
338
  cache = hours * times.hour
339
339
  return self
340
340
  },
341
341
 
342
- /**
343
- * Sets the cache time in days
344
- *
345
- * @param days: number
346
- */
342
+
343
+
344
+
345
+
346
+
347
347
  cacheDays: func(days) {
348
348
  ll.assert(is_int(days) && days > 0, "cache time must be a number of days")
349
349
  cache = days * times.hour * 24
350
350
  return self
351
351
  },
352
352
 
353
- /**
354
- * Sets the number of error lines to be captured.
355
- *
356
- * @param lines: number - the number of error lines.
357
- */
353
+
354
+
355
+
356
+
357
+
358
358
  nErrorLines: func(lines) {
359
359
  ll.assert(
360
360
  is_int(lines) && lines >= 0,
@@ -364,21 +364,21 @@ builder := func() {
364
364
  return self
365
365
  },
366
366
 
367
- /**
368
- * Adds files from given asset into working directory.
369
- *
370
- * @param asset: assetInfo - asset info loaded from assets.importAsset()
371
- * @param destinationDir: string - path inside working directory for files to be extracted from archive. Use "." for root of the workdir.
372
- * @param pathsInArchive: string[] - paths inside the archive to be extracted into destinationDir.
373
- * Empty array means 'unpack full archive'.
374
- */
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
375
  addAsset: func(asset, destinationDir, ...pathsInArchive) {
376
376
  if (len(pathsInArchive) == 1 && is_array(pathsInArchive[0])) {
377
- // support [<paths>] single argument
377
+
378
378
  pathsInArchive = pathsInArchive[0]
379
379
  }
380
380
  if len(pathsInArchive) == 0 {
381
- // default for 'no paths' is to extract all
381
+
382
382
  pathsInArchive = []
383
383
  }
384
384
 
@@ -405,10 +405,10 @@ builder := func() {
405
405
  return self
406
406
  },
407
407
 
408
- /**
409
- * Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
410
- * This allows to customize cache time on per-asset basis
411
- */
408
+
409
+
410
+
411
+
412
412
  cacheAssetMillis: func (asset, millis) {
413
413
  ll.assert(assets.isAssetInfo(asset),
414
414
  "exec.builder.cacheAssetMillis: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
@@ -421,10 +421,10 @@ builder := func() {
421
421
  return self
422
422
  },
423
423
 
424
- /**
425
- * Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
426
- * This allows to customize cache time on per-asset basis
427
- */
424
+
425
+
426
+
427
+
428
428
  cacheAssetSeconds: func (asset, seconds) {
429
429
  ll.assert(assets.isAssetInfo(asset),
430
430
  "exec.builder.cacheAssetSeconds: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
@@ -437,10 +437,10 @@ builder := func() {
437
437
  return self
438
438
  },
439
439
 
440
- /**
441
- * Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
442
- * This allows to customize cache time on per-asset basis
443
- */
440
+
441
+
442
+
443
+
444
444
  cacheAssetMinutes: func (asset, minutes) {
445
445
  ll.assert(assets.isAssetInfo(asset),
446
446
  "exec.builder.cacheAssetMinutes: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
@@ -453,10 +453,10 @@ builder := func() {
453
453
  return self
454
454
  },
455
455
 
456
- /**
457
- * Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
458
- * This allows to customize cache time on per-asset basis
459
- */
456
+
457
+
458
+
459
+
460
460
  cacheAssetHours: func (asset, hours) {
461
461
  ll.assert(assets.isAssetInfo(asset),
462
462
  "exec.builder.cacheAssetHours: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
@@ -469,10 +469,10 @@ builder := func() {
469
469
  return self
470
470
  },
471
471
 
472
- /**
473
- * Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
474
- * This allows to customize cache time on per-asset basis
475
- */
472
+
473
+
474
+
475
+
476
476
  cacheAssetDays: func (asset, days) {
477
477
  ll.assert(assets.isAssetInfo(asset),
478
478
  "exec.builder.cacheAssetHours: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
@@ -495,12 +495,12 @@ builder := func() {
495
495
  return self
496
496
  },
497
497
 
498
- /**
499
- * Adds a file to the working directory
500
- *
501
- * @param fileName: string - the name of the input file.
502
- * @param file: reference - a resource id of the file or a field that points to it.
503
- */
498
+
499
+
500
+
501
+
502
+
503
+
504
504
  addFile: func(fileName, file, ...opts) {
505
505
  ll.assert(is_string(fileName), "exec.builder().addFile: fileName must be a string")
506
506
  ll.assert(smart.isReference(file), "exec.builder().addFile: file must be a reference")
@@ -511,11 +511,11 @@ builder := func() {
511
511
  return self
512
512
  },
513
513
 
514
- /**
515
- * Adds multiple files to the working directory.
516
- *
517
- * @param filesMap: map[string]reference - a map of file names to files' references.
518
- */
514
+
515
+
516
+
517
+
518
+
519
519
  addFiles: func(filesMap, ...opts) {
520
520
  ll.assert(ll.isMap(filesMap), "exec.builder().addFiles: filesMap must be map of file names to file resources")
521
521
  for fileName, file in filesMap {
@@ -524,13 +524,13 @@ builder := func() {
524
524
  return self
525
525
  },
526
526
 
527
- /**
528
- * Writes a file with a given content.
529
- *
530
- * @param fileName: string - the name of the content.
531
- * @param data: bytes|reference - a primitive tengo value (map or array) or a reference to
532
- * a resource from which data we create a file.
533
- */
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
534
  writeFile: func(fileName, data, ...opts) {
535
535
  validation.assertType(data, ["or",
536
536
  "string",
@@ -545,53 +545,53 @@ builder := func() {
545
545
  return self
546
546
  },
547
547
 
548
- /**
549
- * Creates a directory.
550
- *
551
- * @param dir: string - the directory to create.
552
- */
548
+
549
+
550
+
551
+
552
+
553
553
  mkDir: func(dir) {
554
554
  dir = path.canonize(dir)
555
555
  dirsToCreate = sets.add(dirsToCreate, dir)
556
556
  return self
557
557
  },
558
558
 
559
- /**
560
- * Saves a file.
561
- *
562
- * @param fileName: string - the name of the output file.
563
- */
559
+
560
+
561
+
562
+
563
+
564
564
  saveFile: func(fileName) {
565
565
  fileName = path.canonize(fileName)
566
566
  sets.add(filesToSave, fileName)
567
567
  return self
568
568
  },
569
569
 
570
- /**
571
- * Saves a file's content to a value resource.
572
- *
573
- * @param fileName: string - the name of the output value.
574
- */
570
+
571
+
572
+
573
+
574
+
575
575
  saveFileContent: func(fileName) {
576
576
  fileName = path.canonize(fileName)
577
577
  sets.add(filesContentToSave, fileName)
578
578
  return self
579
579
  },
580
580
 
581
- /**
582
- * Saves files from the exec workdir using regex.
583
- *
584
- * @param name: string - a name to refer this file set in the outputs
585
- * @param regex: string - regex pattern
586
- */
581
+
582
+
583
+
584
+
585
+
586
+
587
587
  saveFileSet: func(name, regex) {
588
588
  fileSetsToSave[name] = regex
589
589
  return self
590
590
  },
591
591
 
592
- /**
593
- * Run specified
594
- */
592
+
593
+
594
+
595
595
  processWorkdir: func(name, tpl, tplArgs) {
596
596
  wdProcessors[name] = {
597
597
  tpl: tpl,
@@ -600,22 +600,22 @@ builder := func() {
600
600
  return self
601
601
  },
602
602
 
603
- /**
604
- * Saves files content from the exec workdir using regex.
605
- *
606
- * @param name: string - a name to refer this file set in the outputs
607
- * @param regex: string - regex pattern
608
- */
603
+
604
+
605
+
606
+
607
+
608
+
609
609
  saveFileSetContent: func(name, regex) {
610
610
  fileSetsContentToSave[name] = regex
611
611
  return self
612
612
  },
613
613
 
614
- /**
615
- * A command to stream a file by a given file name.
616
- *
617
- * @param fileName: string - the name of the file to stream.
618
- */
614
+
615
+
616
+
617
+
618
+
619
619
  streamFile: func(fileName) {
620
620
  fileName = path.canonize(fileName)
621
621
  sets.add(filesToStream, fileName)
@@ -623,53 +623,53 @@ builder := func() {
623
623
  return self
624
624
  },
625
625
 
626
- /**
627
- * Set stdout file name
628
- */
626
+
627
+
628
+
629
629
  stdoutFileName: func(fileName) {
630
630
  fileName = path.canonize(fileName)
631
631
  stdout = fileName
632
632
  return self
633
633
  },
634
634
 
635
- /**
636
- * Set stderr file name
637
- */
635
+
636
+
637
+
638
638
  stderrFileName: func(fileName) {
639
639
  fileName = path.canonize(fileName)
640
640
  stderr = fileName
641
641
  return self
642
642
  },
643
643
 
644
- /**
645
- * Sets stdout to be captured as a value resource.
646
- */
644
+
645
+
646
+
647
647
  saveStdoutContent: func() {
648
648
  stdoutToValue = true
649
649
  return self
650
650
  },
651
651
 
652
- /**
653
- * Sets stderr to be captured as a value resource.
654
- */
652
+
653
+
654
+
655
655
  saveStderrContent: func() {
656
656
  stderrToValue = true
657
657
  return self
658
658
  },
659
659
 
660
- /**
661
- * Redirects stderr output to stdout.
662
- */
660
+
661
+
662
+
663
663
  printErrStreamToStdout: func() {
664
664
  stderrToStdout = true
665
665
  return self
666
666
  },
667
667
 
668
- /**
669
- * Executes the command.
670
- *
671
- * @return A map containing the execution results.
672
- */
668
+
669
+
670
+
671
+
672
+
673
673
  run: func() {
674
674
  if stderrToStdout {
675
675
  stderr = stdout
@@ -685,9 +685,9 @@ builder := func() {
685
685
  sets.add(filesContentToSave, stderr)
686
686
  }
687
687
 
688
- // We don't want these values to be encoded as JSON's since
689
- // values are pure bytes.
690
- // Thus, we create a resource with a custom type here manually.
688
+
689
+
690
+
691
691
  filesToWriteRefs := maps.mapValues(filesToWrite, func(v) {
692
692
  if smart.isReference(v) { return v }
693
693
  return smart.createValueResource(constants.RTYPE_BINARY_VALUE, v)
@@ -733,15 +733,15 @@ builder := func() {
733
733
  build()
734
734
  }
735
735
 
736
- // We add monetization only if it's enabled
737
- // to not break a deduplication of exec's
738
- // that were created before this feature existed.
736
+
737
+
738
+
739
739
  if monetization.shouldRun(mnz) {
740
740
  pureExecInputs.runOptions.monetization = monetization.toJson(mnz)
741
741
  }
742
742
 
743
- // We add new argsTyped and envsTyped only when they were added
744
- // to not break a deduplication on old pl backend.
743
+
744
+
745
745
  if typedArgSet || typedEnvSet {
746
746
  pureExecInputs.runOptions.argsTyped = argsTyped
747
747
  pureExecInputs.runOptions.envsTyped = envsTyped
@@ -760,52 +760,52 @@ builder := func() {
760
760
 
761
761
  self := undefined
762
762
  self = ll.toStrict(oop.inherit(tpl, {
763
- /**
764
- * Retrieves a file.
765
- *
766
- * @param fileName: string
767
- * @return field - a reference to the file resource.
768
- */
763
+
764
+
765
+
766
+
767
+
768
+
769
769
  getFile: func(fileName) {
770
770
  return tpl.output("files", cache).getFutureInputField(fileName)
771
771
  },
772
772
 
773
- /**
774
- * Retrieves the content of a file.
775
- *
776
- * @param fileName: string
777
- * @return field - a reference to the file content resource.
778
- */
773
+
774
+
775
+
776
+
777
+
778
+
779
779
  getFileContent: func(fileName) {
780
780
  return tpl.output("filesContent", cache).getFutureInputField(fileName)
781
781
  },
782
782
 
783
- /**
784
- * Retrieves a file stream.
785
- *
786
- * @param fileName: string
787
- * @return field - a reference to the file stream resource.
788
- */
783
+
784
+
785
+
786
+
787
+
788
+
789
789
  getFileStream: func(fileName) {
790
790
  return tpl.output("fileStreams", cache).getFutureInputField(fileName, true)
791
791
  },
792
792
 
793
- /**
794
- * Retrieves a file set resource.
795
- *
796
- * @param fileSetName: string - name of a file set
797
- * @return field - a reference to the map resource with files
798
- */
793
+
794
+
795
+
796
+
797
+
798
+
799
799
  getFileSet: func(fileSetName) {
800
800
  return tpl.output("fileSets", cache).getFutureInputField(fileSetName)
801
801
  },
802
802
 
803
- /**
804
- * Retrieves a file set content resource.
805
- *
806
- * @param fileSetName: string - name of a file set
807
- * @return field - a reference to the map resource with files
808
- */
803
+
804
+
805
+
806
+
807
+
808
+
809
809
  getFileSetContent: func(fileSetName) {
810
810
  return tpl.output("fileSetsContent", cache).getFutureInputField(fileSetName)
811
811
  },
@@ -814,37 +814,37 @@ builder := func() {
814
814
  return tpl.output("wdProcessors", cache).getFutureInputField(procName)
815
815
  },
816
816
 
817
- /**
818
- * Retrieves the stdout stream.
819
- */
817
+
818
+
819
+
820
820
  getStdoutStream: func() {
821
821
  return self.getFileStream(stdout)
822
822
  },
823
823
 
824
- /**
825
- * Retrieves the stderr stream.
826
- */
824
+
825
+
826
+
827
827
  getStderrStream: func() {
828
828
  return self.getFileStream(stderr)
829
829
  },
830
830
 
831
- /**
832
- * Retrieves the stdout file.
833
- */
831
+
832
+
833
+
834
834
  getStdoutFile: func() {
835
835
  return self.getFile(stdout)
836
836
  },
837
837
 
838
- /**
839
- * Retrieves the stderr file.
840
- */
838
+
839
+
840
+
841
841
  getStderrFile: func() {
842
842
  return self.getFile(stderr)
843
843
  },
844
844
 
845
- /**
846
- * Retrieves the content of the stdout file.
847
- */
845
+
846
+
847
+
848
848
  getStdoutFileContent: func() {
849
849
  if stdoutToValue {
850
850
  return self.getFileContent(stdout)
@@ -852,9 +852,9 @@ builder := func() {
852
852
  ll.panic("stdout was not saved as a content")
853
853
  },
854
854
 
855
- /**
856
- * Retrieves the content of the stderr file.
857
- */
855
+
856
+
857
+
858
858
  getStderrFileContent: func() {
859
859
  if stderrToValue {
860
860
  return self.getFileContent(stderr)