@platforma-sdk/workflow-tengo 2.8.1 → 2.8.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 (59) hide show
  1. package/dist/tengo/lib/assets.lib.tengo +76 -82
  2. package/dist/tengo/lib/constants.lib.tengo +28 -31
  3. package/dist/tengo/lib/exec.R.internal.lib.tengo +14 -14
  4. package/dist/tengo/lib/exec.R.lib.tengo +158 -167
  5. package/dist/tengo/lib/exec.internal.lib.tengo +222 -234
  6. package/dist/tengo/lib/exec.lib.tengo +647 -714
  7. package/dist/tengo/lib/exec.package.lib.tengo +229 -238
  8. package/dist/tengo/lib/exec.python.internal.lib.tengo +5 -6
  9. package/dist/tengo/lib/exec.python.lib.tengo +138 -146
  10. package/dist/tengo/lib/exec.runcmd.lib.tengo +234 -253
  11. package/dist/tengo/lib/exec.runenv.lib.tengo +88 -92
  12. package/dist/tengo/lib/exec.stream.lib.tengo +36 -40
  13. package/dist/tengo/lib/file.internal.lib.tengo +70 -77
  14. package/dist/tengo/lib/file.lib.tengo +54 -57
  15. package/dist/tengo/lib/ll.lib.tengo +217 -241
  16. package/dist/tengo/lib/maps.lib.tengo +98 -106
  17. package/dist/tengo/lib/objects.lib.tengo +11 -13
  18. package/dist/tengo/lib/oop.lib.tengo +16 -19
  19. package/dist/tengo/lib/path.lib.tengo +116 -125
  20. package/dist/tengo/lib/pframes.constants.lib.tengo +25 -28
  21. package/dist/tengo/lib/pframes.export-pcolumn.lib.tengo +28 -33
  22. package/dist/tengo/lib/pframes.lib.tengo +38 -43
  23. package/dist/tengo/lib/pframes.ll.lib.tengo +70 -73
  24. package/dist/tengo/lib/pframes.pcolumn.lib.tengo +45 -51
  25. package/dist/tengo/lib/pframes.spec.lib.tengo +70 -96
  26. package/dist/tengo/lib/pframes.util.lib.tengo +154 -289
  27. package/dist/tengo/lib/pframes.xsv.lib.tengo +260 -273
  28. package/dist/tengo/lib/render.lib.tengo +65 -76
  29. package/dist/tengo/lib/sets.lib.tengo +61 -68
  30. package/dist/tengo/lib/slices.lib.tengo +169 -180
  31. package/dist/tengo/lib/smart.lib.tengo +956 -1069
  32. package/dist/tengo/lib/test.lib.tengo +129 -161
  33. package/dist/tengo/lib/tpl.lib.tengo +448 -516
  34. package/dist/tengo/lib/tpl.state-await.lib.tengo +226 -241
  35. package/dist/tengo/lib/tpl.util.lib.tengo +4 -9
  36. package/dist/tengo/lib/validation.lib.tengo +334 -379
  37. package/dist/tengo/lib/workdir.lib.tengo +309 -332
  38. package/dist/tengo/lib/workdir.proc.lib.tengo +126 -144
  39. package/dist/tengo/lib/workdir.save.lib.tengo +113 -130
  40. package/dist/tengo/lib/workflow.bobject.lib.tengo +21 -26
  41. package/dist/tengo/lib/workflow.bquery.lib.tengo +140 -166
  42. package/dist/tengo/lib/workflow.constants.lib.tengo +1 -2
  43. package/dist/tengo/lib/workflow.context.lib.tengo +27 -32
  44. package/dist/tengo/lib/workflow.lib.tengo +167 -207
  45. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  46. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  47. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  48. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  49. package/dist/tengo/tpl/pframes.aggregate.plj.gz +0 -0
  50. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  51. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  52. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  53. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  54. package/dist/tengo/tpl/pframes.map-pframe.plj.gz +0 -0
  55. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  56. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  57. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  58. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  59. package/package.json +8 -8
@@ -1,6 +1,5 @@
1
- /**
2
- * A library that creates RunCommand resource.
3
- */
1
+
2
+
4
3
 
5
4
  ll := import("@platforma-sdk/workflow-tengo:ll")
6
5
  maps := import("@platforma-sdk/workflow-tengo:maps")
@@ -14,264 +13,246 @@ _RTYPE_RUN_COMMAND_ARGS := { Name: "RunCommandArgs", Version: "1" }
14
13
  _RTYPE_RUN_COMMAND_OPTIONS := { Name: "run-command/options", Version: "1" }
15
14
  _RTYPE_RUN_COMMAND_REFS := { Name: "RunCommandRefs", Version: "1" }
16
15
 
17
- /**
18
- * Creates a simple argument for the command.
19
- *
20
- * @param argument: string - the argument to create.
21
- */
16
+
17
+
18
+
19
+
22
20
  _createSimpleArg := func(argument) {
23
- return {
24
- type: "string",
25
- value: argument
26
- }
21
+ return {
22
+ type: "string",
23
+ value: argument
27
24
  }
25
+ }
26
+
27
+
28
+
28
29
 
29
- /**
30
- * Creates 'variableRef' argument.
31
- * @param argTpl: string - argument value in any form with variables inside (e.g. "file://{pkg}/some-file" or "o-{java}-o")
32
- */
33
30
  _createVariableArg := func(argTpl) {
34
- return {
35
- type: "variableRef",
36
- value: argTpl
37
- }
31
+ return {
32
+ type: "variableRef",
33
+ value: argTpl
38
34
  }
35
+ }
36
+
37
+
38
+
39
+
40
+
39
41
 
40
- /**
41
- * Builder function for creating a RunCommand resource.
42
- *
43
- * @param workdir: string - the working directory for the command.
44
- * @return builder - the builder object with methods for configuring and building the RunCommand resource.
45
- */
46
42
  builder := func(workdir) {
47
- res := smart.ephemeralBuilder(_RTYPE_RUN_COMMAND)
48
- res.getField("workdirIn").set(workdir)
49
-
50
- self := undefined
51
-
52
- cmd := undefined
53
- args := []
54
- envs := {}
55
- queue := ""
56
- refs := {}
57
-
58
- substRules := {}
59
- hasPatternArgs := false
60
- customPaths := []
61
-
62
- stdout := "stdout.txt"
63
- stderr := "stderr.txt"
64
- nErrorLines := 200
65
-
66
- self = ll.toStrict(oop.inherit(res, {
67
- /**
68
- * Sets the command, e.g. /usr/bin/env or sh.
69
- *
70
- * @param commandName: string - the name of the command.
71
- */
72
- cmd: func(commandName) {
73
- cmd = _createSimpleArg(commandName)
74
- return self
75
- },
76
-
77
- /**
78
- * Sets the command with variables inside to be rendered using rules
79
- * from .substitutionRules().
80
- *
81
- * @param commandTpl: string - string with '{varName}' substitutions to be replaced with
82
- * software paths. Replace rules are defined by .substitutionRule()
83
- * and .substitutionRules(),
84
- */
85
- cmdVar: func(commandTpl) {
86
- cmd = _createVariableArg(commandTpl)
87
- hasPatternArgs = true
88
- return self
89
- },
90
-
91
- /**
92
- * Adds an argument to the command.
93
- *
94
- * @param arg: string - the argument to add.
95
- */
96
- arg: func(arg) {
97
- args = append(args, _createSimpleArg(arg))
98
- return self
99
- },
100
-
101
- /**
102
- * Adds an argument with variables inside to be rendered using rules
103
- * from .substitutionRules().
104
- *
105
- * @param argTpl: string - string with '{varName}' substitutions to be replaced with
106
- * software paths. Replace rules are defined by .substitutionRule()
107
- * and .substitutionRules(),
108
- */
109
- argVar: func(argTpl) {
110
- args = append(args, _createVariableArg(argTpl))
111
- hasPatternArgs = true
112
- return self
113
- },
114
-
115
- ref: func(refKey, ref) {
116
- ll.assert(smart.isReference(ref),
117
- "runcmd.builder().ref() must be a reference (valid field or resource)")
118
-
119
- ll.assert(!maps.containsKey(refs, refKey),
120
- "attempt to override existing reference %q", refKey)
121
-
122
- refs[refKey] = ref
123
- return self
124
- },
125
-
126
- /**
127
- * Sets an environment variable for the command.
128
- *
129
- * @param name: string - the name of the environment variable.
130
- * @param value: string - the value of the environment variable.
131
- */
132
- env: func(name, value) {
133
- envs[name] = value
134
- return self
135
- },
136
-
137
- /**
138
- * Sets environment variable with substitution inside value, to be rendered
139
- * using rules from .substitutionRules().
140
- *
141
- * @param name: string - the name of the environment variable.
142
- * @param valueTpl: string - the value of the environment variable.
143
- */
144
- envVar: func(name, valueTpl) {
145
- envs[name] = _createVariableArg(valueTpl)
146
- hasPatternArgs = true
147
- return self
148
- },
149
-
150
- /*
151
- * Patch 'PATH' environment variable, adding software path to it.
152
- *
153
- * @param value: string - the value of the environment variable with variables to be replaced to software path.
154
- * @param hasVars: boolean - wether Platforma Backend should try to substitute variables inside <value> on server side
155
- */
156
- addToPath: func(value, hasVars) {
157
- if hasVars {
158
- customPaths = append(customPaths, _createVariableArg(value))
159
- hasPatternArgs = true
160
- } else {
161
- customPaths = append(customPaths, _createSimpleArg(value))
162
- }
163
- return self
164
- },
165
-
166
- /**
167
- * Define substitution variable for software args.
168
- *
169
- * @param varName: string - variable to be substituted in arg value ("var1" would be
170
- * substituted in place of {var1} of arg value)
171
- * @param refKey: string - key of ref (added with .ref()) that points to installed software.
172
- */
173
- substitutionRule: func(varName, refKey) {
174
- substRules[varName] = refKey
175
- return self
176
- },
177
-
178
- /**
179
- * Batched .substitutionRule() call (add several rules in single call)
180
- *
181
- * @param rules: map[string]string - <var name> -> <ref key> pairs to be added to substitution rules.
182
- */
183
- substitutionRules: func(rules) {
184
- for k, v in rules {
185
- substRules[k] = v
186
- }
187
- return self
188
- },
189
-
190
- /**
191
- * Sets the queue name for the command.
192
- *
193
- * @param queueName: string - the name of the queue.
194
- */
195
- inQueue: func(queueName) {
196
- queue = queueName
197
- return self
198
- },
199
-
200
- /**
201
- * Sets the stdout file name for the command.
202
- *
203
- * @param fileName: string - the name of the stdout file.
204
- */
205
- stdout: func(fileName) {
206
- stdout = fileName
207
- return self
208
- },
209
-
210
- /**
211
- * Sets the stderr file name for the command.
212
- *
213
- * @param fileName: string - the name of the stderr file.
214
- */
215
- stderr: func(fileName) {
216
- stderr = fileName
217
- return self
218
- },
219
-
220
- /**
221
- * Sets the number of error lines for the command.
222
- *
223
- * @param number: int - the number of error lines.
224
- */
225
- nErrorLines: func(number) {
226
- nErrorLines = number
227
- return self
228
- },
229
-
230
- /**
231
- * Builds the RunCommand resource.
232
- *
233
- * @return object - the built RunCommand resource.
234
- */
235
- build: func() {
236
- // TODO: add assertions about the state
237
-
238
- ll.assert(!hasPatternArgs || len(substRules) != 0,
239
- "found pattern argument, but no substitution rules were set")
240
-
241
- refsRes := smart.createMapResourceWithType(_RTYPE_RUN_COMMAND_REFS, refs)
242
- self.getField("refs").set(refsRes)
243
-
244
- cmdRes := smart.createValueResource(_RTYPE_RUN_COMMAND_CMD, json.encode(cmd))
245
- self.getField("cmd").set(cmdRes)
246
-
247
- options := {
248
- queueName: queue,
249
- errorLines: nErrorLines,
250
- redirectStdout: stdout,
251
- redirectStderr: stderr,
252
- env: envs,
253
- additionalPaths: customPaths,
254
- substitutions: substRules
255
- }
256
-
257
- optionsRes := smart.createValueResource(_RTYPE_RUN_COMMAND_OPTIONS, json.encode(options))
258
- self.getField("options").set(optionsRes)
259
-
260
- argsRes := smart.createValueResource(_RTYPE_RUN_COMMAND_ARGS, json.encode(args))
261
- self.getField("args").set(argsRes)
262
-
263
- res := ll.toStrict(oop.inherit(self.lockAndBuild(), {
264
- "workdir": self.outputs().workdirOut,
265
- "options": options
266
- }))
267
-
268
- return res
269
- }
270
- }))
271
-
272
- return self
43
+ res := smart.ephemeralBuilder(_RTYPE_RUN_COMMAND)
44
+ res.getField("workdirIn").set(workdir)
45
+
46
+ self := undefined
47
+
48
+ cmd := undefined
49
+ args := []
50
+ envs := {}
51
+ queue := ""
52
+ refs := {}
53
+
54
+ substRules := {}
55
+ hasPatternArgs := false
56
+ customPaths := []
57
+
58
+ stdout := "stdout.txt"
59
+ stderr := "stderr.txt"
60
+ nErrorLines := 200
61
+
62
+ self = ll.toStrict(oop.inherit(res, {
63
+
64
+
65
+
66
+
67
+ cmd: func(commandName) {
68
+ cmd = _createSimpleArg(commandName)
69
+ return self
70
+ },
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ cmdVar: func(commandTpl) {
80
+ cmd = _createVariableArg(commandTpl)
81
+ hasPatternArgs = true
82
+ return self
83
+ },
84
+
85
+
86
+
87
+
88
+
89
+ arg: func(arg) {
90
+ args = append(args, _createSimpleArg(arg))
91
+ return self
92
+ },
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ argVar: func(argTpl) {
102
+ args = append(args, _createVariableArg(argTpl))
103
+ hasPatternArgs = true
104
+ return self
105
+ },
106
+
107
+ ref: func(refKey, ref) {
108
+ ll.assert(smart.isReference(ref),
109
+ "runcmd.builder().ref() must be a reference (valid field or resource)")
110
+
111
+ ll.assert(!maps.containsKey(refs, refKey),
112
+ "attempt to override existing reference %q", refKey)
113
+
114
+ refs[refKey] = ref
115
+ return self
116
+ },
117
+
118
+
119
+
120
+
121
+
122
+
123
+ env: func(name, value) {
124
+ envs[name] = value
125
+ return self
126
+ },
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+ envVar: func(name, valueTpl) {
135
+ envs[name] = _createVariableArg(valueTpl)
136
+ hasPatternArgs = true
137
+ return self
138
+ },
139
+
140
+
141
+
142
+
143
+
144
+
145
+ addToPath: func(value, hasVars) {
146
+ if hasVars {
147
+ customPaths = append(customPaths, _createVariableArg(value))
148
+ hasPatternArgs = true
149
+ } else {
150
+ customPaths = append(customPaths, _createSimpleArg(value))
151
+ }
152
+ return self
153
+ },
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+ substitutionRule: func(varName, refKey) {
162
+ substRules[varName] = refKey
163
+ return self
164
+ },
165
+
166
+
167
+
168
+
169
+
170
+ substitutionRules: func(rules) {
171
+ for k, v in rules {
172
+ substRules[k] = v
173
+ }
174
+ return self
175
+ },
176
+
177
+
178
+
179
+
180
+
181
+ inQueue: func(queueName) {
182
+ queue = queueName
183
+ return self
184
+ },
185
+
186
+
187
+
188
+
189
+
190
+ stdout: func(fileName) {
191
+ stdout = fileName
192
+ return self
193
+ },
194
+
195
+
196
+
197
+
198
+
199
+ stderr: func(fileName) {
200
+ stderr = fileName
201
+ return self
202
+ },
203
+
204
+
205
+
206
+
207
+
208
+ nErrorLines: func(number) {
209
+ nErrorLines = number
210
+ return self
211
+ },
212
+
213
+
214
+
215
+
216
+
217
+ build: func() {
218
+
219
+ ll.assert(!hasPatternArgs || len(substRules) != 0,
220
+ "found pattern argument, but no substitution rules were set")
221
+
222
+ refsRes := smart.createMapResourceWithType(_RTYPE_RUN_COMMAND_REFS, refs)
223
+ self.getField("refs").set(refsRes)
224
+
225
+ cmdRes := smart.createValueResource(_RTYPE_RUN_COMMAND_CMD, json.encode(cmd))
226
+ self.getField("cmd").set(cmdRes)
227
+
228
+ options := {
229
+ queueName: queue,
230
+ errorLines: nErrorLines,
231
+ redirectStdout: stdout,
232
+ redirectStderr: stderr,
233
+ env: envs,
234
+ additionalPaths: customPaths,
235
+ substitutions: substRules
236
+ }
237
+
238
+ optionsRes := smart.createValueResource(_RTYPE_RUN_COMMAND_OPTIONS, json.encode(options))
239
+ self.getField("options").set(optionsRes)
240
+
241
+ argsRes := smart.createValueResource(_RTYPE_RUN_COMMAND_ARGS, json.encode(args))
242
+ self.getField("args").set(argsRes)
243
+
244
+ res := ll.toStrict(oop.inherit(self.lockAndBuild(), {
245
+ "workdir": self.outputs().workdirOut,
246
+ "options": options
247
+ }))
248
+
249
+ return res
250
+ }
251
+ }))
252
+
253
+ return self
273
254
  }
274
255
 
275
256
  export ll.toStrict({
276
- builder: builder
257
+ builder: builder
277
258
  })