@platforma-sdk/workflow-tengo 5.3.3 → 5.3.5
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.
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/tengo/lib/exec.lib.tengo +4 -0
- package/dist/tengo/lib/exec.monetization_internal.lib.tengo +8 -0
- package/dist/tengo/lib/pframes.spec.lib.tengo +6 -0
- package/dist/tengo/lib/pframes.util.lib.tengo +404 -1
- package/dist/tengo/lib/pframes.xsv.lib.tengo +117 -65
- package/dist/tengo/lib/pt.expression.lib.tengo +828 -268
- package/dist/tengo/lib/pt.lib.tengo +567 -216
- package/dist/tengo/lib/pt.util.lib.tengo +231 -15
- package/dist/tengo/lib/slices.lib.tengo +20 -1
- package/dist/tengo/lib/smart.lib.tengo +0 -1
- package/dist/tengo/tpl/anonymize.deanonymize.plj.gz +0 -0
- package/dist/tengo/tpl/anonymize.impl.plj.gz +0 -0
- package/dist/tengo/tpl/check_network.create_workdir_from_storage.plj.gz +0 -0
- package/dist/tengo/tpl/check_network.download_blob.plj.gz +0 -0
- package/dist/tengo/tpl/check_network.run_hello_world.plj.gz +0 -0
- package/dist/tengo/tpl/check_network.run_hello_world_py.plj.gz +0 -0
- package/dist/tengo/tpl/check_network.upload_blob.plj.gz +0 -0
- package/dist/tengo/tpl/check_network.upload_template.plj.gz +0 -0
- package/dist/tengo/tpl/check_network.workdir_type_name_extractor.plj.gz +0 -0
- package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
- package/dist/tengo/tpl/exec.delayed-compute-allocation.impl.plj.gz +0 -0
- package/dist/tengo/tpl/exec.exec-impl.plj.gz +0 -0
- package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
- package/dist/tengo/tpl/exec.load-software.impl.plj.gz +0 -0
- package/dist/tengo/tpl/exec.monetization_info.plj.gz +0 -0
- package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
- package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
- package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
- package/dist/tengo/tpl/exec.python.venv-bin-path.plj.gz +0 -0
- package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.export-pframe-for-ui.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.parse-to-json.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.slice-data.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
- package/dist/tengo/tpl/pt.import-dir.plj.gz +0 -0
- package/dist/tengo/tpl/pt.workflow-run.plj.gz +0 -0
- package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
- package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
- package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
- package/dist/tengo/tpl/workflow.query-anchored.plj.gz +0 -0
- package/package.json +4 -4
- package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
|
@@ -10,10 +10,15 @@ render := import("@platforma-sdk/workflow-tengo:render")
|
|
|
10
10
|
maps := import("@platforma-sdk/workflow-tengo:maps")
|
|
11
11
|
util := import("@platforma-sdk/workflow-tengo:pframes.util")
|
|
12
12
|
pBuilder := import("@platforma-sdk/workflow-tengo:pframes.builder")
|
|
13
|
+
pframesSpec := import("@platforma-sdk/workflow-tengo:pframes.spec")
|
|
13
14
|
ll := import("@platforma-sdk/workflow-tengo:ll")
|
|
14
15
|
assets := import("@platforma-sdk/workflow-tengo:assets")
|
|
15
16
|
xsvIF := import("@platforma-sdk/workflow-tengo:pframes.xsv-import-file")
|
|
16
17
|
text := import("text")
|
|
18
|
+
execConstants := import("@platforma-sdk/workflow-tengo:exec.constants")
|
|
19
|
+
pt := import("@platforma-sdk/workflow-tengo:pt")
|
|
20
|
+
slices := import("@platforma-sdk/workflow-tengo:slices")
|
|
21
|
+
canonical := import("@platforma-sdk/workflow-tengo:canonical")
|
|
17
22
|
|
|
18
23
|
importXsvIfNullTpl := assets.importTemplate("@platforma-sdk/workflow-tengo:pframes.xsv-import-if-not-null")
|
|
19
24
|
|
|
@@ -210,60 +215,6 @@ importFileMap := func(xsvMap, xsvType, spec, ...ops) {
|
|
|
210
215
|
return result
|
|
211
216
|
}
|
|
212
217
|
|
|
213
|
-
isFlatPfMap := func(pf) {
|
|
214
|
-
if !is_map(pf) {
|
|
215
|
-
return false
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
for key, _ in pf {
|
|
219
|
-
if !text.has_suffix(key, ".spec") && !text.has_suffix(key, ".data") {
|
|
220
|
-
return false
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return true
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
isStructuredPfMap := func(pf) {
|
|
228
|
-
if !is_map(pf) {
|
|
229
|
-
return false
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
for _, value in pf {
|
|
233
|
-
if !is_map(value) {
|
|
234
|
-
return false
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
for k, _ in value {
|
|
238
|
-
if k != "spec" && k != "data" {
|
|
239
|
-
return false
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if is_undefined(value.spec) || is_undefined(value.data) {
|
|
244
|
-
return false
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return true
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
218
|
|
|
268
219
|
|
|
269
220
|
|
|
@@ -288,13 +239,44 @@ isStructuredPfMap := func(pf) {
|
|
|
288
239
|
|
|
289
240
|
|
|
290
241
|
|
|
242
|
+
exportFrame := func(pf, xsvType, params, ...ops) {
|
|
243
|
+
validation.assertType(params, util.PFCONV_EXPORT_CFG_SCHEMA)
|
|
244
|
+
partialParams := objects.deleteUndefined({
|
|
245
|
+
naStr: params.naStr,
|
|
246
|
+
nullStr: params.nullStr,
|
|
247
|
+
joinType: params.joinType
|
|
248
|
+
})
|
|
291
249
|
|
|
250
|
+
ops := renderOps({}, ops...)
|
|
251
|
+
ll.assert(is_undefined(ops.partitions), "partitions option is no longer supported")
|
|
292
252
|
|
|
253
|
+
runMetaInputs := {
|
|
254
|
+
queue: ops.queue,
|
|
255
|
+
cpu: ops.cpu,
|
|
256
|
+
mem: ops.mem,
|
|
257
|
+
inputCache: ops.inputCache
|
|
258
|
+
}
|
|
293
259
|
|
|
294
|
-
|
|
295
|
-
|
|
260
|
+
if !is_undefined(params.queue) {
|
|
261
|
+
runMetaInputs.queue = params.queue
|
|
262
|
+
delete(params, "queue")
|
|
263
|
+
}
|
|
264
|
+
if !is_undefined(params.cpu) {
|
|
265
|
+
runMetaInputs.cpu = params.cpu
|
|
266
|
+
delete(params, "cpu")
|
|
267
|
+
}
|
|
268
|
+
if !is_undefined(params.mem) {
|
|
269
|
+
runMetaInputs.mem = params.mem
|
|
270
|
+
delete(params, "mem")
|
|
271
|
+
}
|
|
272
|
+
if !is_undefined(params.inputCache) {
|
|
273
|
+
runMetaInputs.inputCache = params.inputCache
|
|
274
|
+
delete(params, "inputCache")
|
|
275
|
+
}
|
|
296
276
|
|
|
297
|
-
|
|
277
|
+
if len(partialParams) < len(params) {
|
|
278
|
+
ll.panic("Some params are not supported: %v", params)
|
|
279
|
+
}
|
|
298
280
|
|
|
299
281
|
if is_array(pf) {
|
|
300
282
|
|
|
@@ -308,7 +290,7 @@ exportFrame := func(pf, xsvType, params, ...ops) {
|
|
|
308
290
|
i = i + 1
|
|
309
291
|
}
|
|
310
292
|
pf = pfBuilder.build()
|
|
311
|
-
} else if isStructuredPfMap(pf) {
|
|
293
|
+
} else if util.isStructuredPfMap(pf) {
|
|
312
294
|
pfBuilder := pBuilder.pFrameBuilder()
|
|
313
295
|
for key, value in pf {
|
|
314
296
|
pfBuilder.add(key, value.spec, value.data)
|
|
@@ -318,18 +300,88 @@ exportFrame := func(pf, xsvType, params, ...ops) {
|
|
|
318
300
|
if !pf.checkResourceType(constants.RTYPE_P_FRAME) {
|
|
319
301
|
ll.panic("Unexpected resource type: %s", pf.info().Type.Name)
|
|
320
302
|
}
|
|
321
|
-
} else if !isFlatPfMap(pf) && !smart.isReference(pf) {
|
|
303
|
+
} else if !util.isFlatPfMap(pf) && !smart.isReference(pf) {
|
|
322
304
|
ll.panic("Unexpected p-frame format: %s", pf)
|
|
323
305
|
}
|
|
324
306
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
307
|
+
resultFile := "result." + xsvType
|
|
308
|
+
|
|
309
|
+
columnEntries := []
|
|
310
|
+
rawColumns := []
|
|
311
|
+
maps.forEach(util.pFrameToColumnsMap(pf), func(frameUniqueColumnId, columnInfo) {
|
|
312
|
+
columnEntries = append(columnEntries, pt.p.column(frameUniqueColumnId, columnInfo))
|
|
313
|
+
rawColumns = append(rawColumns, { id: frameUniqueColumnId, spec: columnInfo.spec })
|
|
330
314
|
})
|
|
331
315
|
|
|
332
|
-
|
|
316
|
+
frameInput := undefined
|
|
317
|
+
if params.joinType == "Inner" {
|
|
318
|
+
frameInput = pt.p.inner(columnEntries...)
|
|
319
|
+
} else {
|
|
320
|
+
frameInput = pt.p.full(columnEntries...)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
numericSelector := pt.sc.numeric()
|
|
324
|
+
if is_string(params.naStr) {
|
|
325
|
+
numericSelector = numericSelector.fillNull(params.naStr)
|
|
326
|
+
}
|
|
327
|
+
stringSelector := pt.sc.string()
|
|
328
|
+
if is_string(params.nullStr) {
|
|
329
|
+
stringSelector = stringSelector.fillNull(params.nullStr)
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
specDistiller := pframesSpec.createSpecDistiller(slices.map(rawColumns, func(c) { return c.spec }))
|
|
333
|
+
canonicalMap := {}
|
|
334
|
+
uniqueAxes := []
|
|
335
|
+
for column in rawColumns {
|
|
336
|
+
for axis in column.spec.axesSpec {
|
|
337
|
+
distilledAxis := specDistiller.distill(axis)
|
|
338
|
+
canonicalizedAxisSpec := canonical.encode(distilledAxis)
|
|
339
|
+
if is_undefined(canonicalMap[canonicalizedAxisSpec]) {
|
|
340
|
+
canonicalMap[canonicalizedAxisSpec] = true
|
|
341
|
+
distilledAxis.label = axis.annotations["pl7.app/label"]
|
|
342
|
+
uniqueAxes = append(uniqueAxes, distilledAxis)
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
columnSelectors := []
|
|
348
|
+
for axis in uniqueAxes {
|
|
349
|
+
label := axis.label
|
|
350
|
+
delete(axis, "label")
|
|
351
|
+
columnSelectors = append(columnSelectors, pt.sc.axis(axis).alias(label))
|
|
352
|
+
}
|
|
353
|
+
for column in rawColumns {
|
|
354
|
+
columnSelectors = append(columnSelectors, pt.col(column.id).alias(column.spec.annotations["pl7.app/label"]))
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
wf := pt.workflow()
|
|
358
|
+
if runMetaInputs.queue == execConstants.LIGHT_QUEUE {
|
|
359
|
+
wf = wf.inLightQueue()
|
|
360
|
+
} else if runMetaInputs.queue == execConstants.MEDIUM_QUEUE {
|
|
361
|
+
wf = wf.inMediumQueue()
|
|
362
|
+
} else if runMetaInputs.queue == execConstants.HEAVY_QUEUE {
|
|
363
|
+
wf = wf.inHeavyQueue()
|
|
364
|
+
} else if runMetaInputs.queue == execConstants.UI_TASKS_QUEUE {
|
|
365
|
+
wf = wf.inUiQueue()
|
|
366
|
+
} else if !is_undefined(runMetaInputs.queue) {
|
|
367
|
+
ll.panic("Unsupported queue: %v", runMetaInputs.queue)
|
|
368
|
+
}
|
|
369
|
+
if !is_undefined(runMetaInputs.cpu) {
|
|
370
|
+
wf = wf.cpu(runMetaInputs.cpu)
|
|
371
|
+
}
|
|
372
|
+
if !is_undefined(runMetaInputs.mem) {
|
|
373
|
+
wf = wf.mem(runMetaInputs.mem)
|
|
374
|
+
}
|
|
375
|
+
if !is_undefined(runMetaInputs.inputCache) {
|
|
376
|
+
wf = wf.cacheInputs(runMetaInputs.inputCache)
|
|
377
|
+
}
|
|
378
|
+
wf.frame(frameInput).
|
|
379
|
+
select(numericSelector, stringSelector).
|
|
380
|
+
select(columnSelectors...).
|
|
381
|
+
save(resultFile)
|
|
382
|
+
|
|
383
|
+
result := wf.run()
|
|
384
|
+
return result.getFile(resultFile)
|
|
333
385
|
}
|
|
334
386
|
|
|
335
387
|
export ll.toStrict({
|