@platforma-sdk/workflow-tengo 2.9.6 → 2.9.8

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 (64) hide show
  1. package/dist/tengo/lib/assets.lib.tengo +52 -52
  2. package/dist/tengo/lib/assets.swinfo.lib.tengo +45 -45
  3. package/dist/tengo/lib/constants.lib.tengo +32 -32
  4. package/dist/tengo/lib/exec.R.internal.lib.tengo +29 -29
  5. package/dist/tengo/lib/exec.R.lib.tengo +166 -166
  6. package/dist/tengo/lib/exec.constants.lib.tengo +4 -4
  7. package/dist/tengo/lib/exec.descriptor.lib.tengo +31 -31
  8. package/dist/tengo/lib/exec.internal.lib.tengo +297 -297
  9. package/dist/tengo/lib/exec.lib.tengo +815 -815
  10. package/dist/tengo/lib/exec.monetization.lib.tengo +130 -130
  11. package/dist/tengo/lib/exec.package.lib.tengo +212 -212
  12. package/dist/tengo/lib/exec.python.internal.lib.tengo +6 -6
  13. package/dist/tengo/lib/exec.python.lib.tengo +146 -146
  14. package/dist/tengo/lib/exec.runcmd.lib.tengo +371 -371
  15. package/dist/tengo/lib/exec.runenv.lib.tengo +92 -92
  16. package/dist/tengo/lib/exec.stream.lib.tengo +40 -40
  17. package/dist/tengo/lib/file.internal.lib.tengo +77 -77
  18. package/dist/tengo/lib/file.lib.tengo +57 -57
  19. package/dist/tengo/lib/ll.lib.tengo +244 -244
  20. package/dist/tengo/lib/maps.lib.tengo +152 -152
  21. package/dist/tengo/lib/objects.lib.tengo +13 -13
  22. package/dist/tengo/lib/oop.lib.tengo +19 -19
  23. package/dist/tengo/lib/path.lib.tengo +125 -125
  24. package/dist/tengo/lib/pframes.constants.lib.tengo +28 -28
  25. package/dist/tengo/lib/pframes.export-pcolumn.lib.tengo +33 -33
  26. package/dist/tengo/lib/pframes.lib.tengo +43 -43
  27. package/dist/tengo/lib/pframes.ll.lib.tengo +72 -72
  28. package/dist/tengo/lib/pframes.pcolumn.lib.tengo +49 -49
  29. package/dist/tengo/lib/pframes.spec.lib.tengo +96 -96
  30. package/dist/tengo/lib/pframes.util.lib.tengo +288 -288
  31. package/dist/tengo/lib/pframes.xsv.lib.tengo +272 -272
  32. package/dist/tengo/lib/render.lib.tengo +75 -75
  33. package/dist/tengo/lib/sets.lib.tengo +68 -68
  34. package/dist/tengo/lib/slices.lib.tengo +258 -155
  35. package/dist/tengo/lib/smart.lib.tengo +1069 -1069
  36. package/dist/tengo/lib/test.lib.tengo +161 -161
  37. package/dist/tengo/lib/tpl.lib.tengo +515 -515
  38. package/dist/tengo/lib/tpl.state-await.lib.tengo +240 -240
  39. package/dist/tengo/lib/tpl.util.lib.tengo +9 -9
  40. package/dist/tengo/lib/validation.lib.tengo +378 -378
  41. package/dist/tengo/lib/workdir.lib.tengo +331 -331
  42. package/dist/tengo/lib/workdir.proc.lib.tengo +144 -144
  43. package/dist/tengo/lib/workdir.save.lib.tengo +130 -130
  44. package/dist/tengo/lib/workflow.bobject.lib.tengo +26 -26
  45. package/dist/tengo/lib/workflow.bquery.lib.tengo +165 -165
  46. package/dist/tengo/lib/workflow.constants.lib.tengo +2 -2
  47. package/dist/tengo/lib/workflow.context.lib.tengo +32 -32
  48. package/dist/tengo/lib/workflow.lib.tengo +206 -206
  49. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  50. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  51. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  52. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  53. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  54. package/dist/tengo/tpl/pframes.aggregate.plj.gz +0 -0
  55. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  56. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  57. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  58. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  59. package/dist/tengo/tpl/pframes.map-pframe.plj.gz +0 -0
  60. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  61. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  62. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  63. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  64. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
-
2
-
3
-
1
+ /**
2
+ * Set of basic operations for PColumn data payload
3
+ */
4
4
 
5
5
  ll := import("@platforma-sdk/workflow-tengo:ll")
6
6
  assets := import("@platforma-sdk/workflow-tengo:assets")
@@ -9,77 +9,77 @@ render := import("@platforma-sdk/workflow-tengo:render")
9
9
 
10
10
  llAggTpl := assets.importTemplate("@platforma-sdk/workflow-tengo:pframes.aggregate")
11
11
 
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
12
+ /**
13
+ * Instantiate an aggregation pipeline for the given inputs, and returns rendered ephemeral template.
14
+ * Use r.output("output_name") method to get corresponding result, where r is an object returned by
15
+ * this method.
16
+ *
17
+ * Contract for the body template:
18
+ *
19
+ * Inputs:
20
+ * "__key__" - will be set to the json representation of the group key (i.e. keys in all
21
+ * positions not specified in the indices parameter)
22
+ * "__value__" - "PColumnData/ResourceMap" resource with all the records in the current group
23
+ * ...extra - all values or references passed to optional last parameter of this method
24
+ * will be forwarded to the template as is
25
+ *
26
+ * Outputs:
27
+ * array of output names to collect from aggregation operations is specified as a parameter
28
+ * of this operation
29
+ *
30
+ * @param data data resource (currently only PColumnData/ResourceMap is supported)
31
+ * @param indices indices to aggregate over (these indices will be stripped from the input map,
32
+ * meaning of this parameter is the opposite of GROUP BY from SQL)
33
+ * @param bodyTpl reference to the template implementing particular aggregation (see contract above)
34
+ * @param outputs array of output settings to to collect from rendered templates
35
+ *
36
+ * Common fields for all subtypes:
37
+ * {
38
+ * name: string - name of the output
39
+ * path?: string[] - [optional] overrides the path inside the body template
40
+ * result, first name is interpreted as output name. If
41
+ * not specified path equals to `[name]`.
42
+ * }
43
+ *
44
+ * Variants:
45
+ * | { type: "Resource" } // - assume normal singular resource is produced by
46
+ * this output
47
+ * | {
48
+ * type: "ResourceMap",
49
+ * keyLength: number // - expected key length of result from each operation
50
+ * } // - assume each record is ResourceMap
51
+ * | {
52
+ * type: "BinaryPartitioned" | "JsonPartitioned",
53
+ * partitionKeyLength: number // - expected partition length of result from
54
+ * each operation
55
+ * } // - assume each record is a partitionded Json or Binary PColumn data itself
56
+ *
57
+ * @param isEph if true, body template will be rendered as ephemeral
58
+ * @param extra optional map of parameters to pass to the template
59
+ */
60
60
  aggregate := func(data, indices, bodyTpl, outputs, isEph, ...extra) {
61
- renderInputs := {
62
- params: smart.createJsonResource({
63
- indices: indices,
64
- eph: isEph,
65
- outputs: outputs
66
- }),
67
- body: bodyTpl,
68
- data: data
69
- }
70
-
71
- if len(extra) == 1 {
72
- for k, v in extra[0] {
73
- renderInputs["__extra_" + k] = v
74
- }
75
- } else if len(extra) != 0 {
76
- ll.panic("Wrong number of parameters for aggregate method.")
77
- }
78
-
79
- renderResult := render.createEphemeral(llAggTpl, renderInputs)
80
- return renderResult;
61
+ renderInputs := {
62
+ params: smart.createJsonResource({
63
+ indices: indices,
64
+ eph: isEph,
65
+ outputs: outputs
66
+ }),
67
+ body: bodyTpl,
68
+ data: data
69
+ }
70
+
71
+ if len(extra) == 1 {
72
+ for k, v in extra[0] {
73
+ renderInputs["__extra_" + k] = v
74
+ }
75
+ } else if len(extra) != 0 {
76
+ ll.panic("Wrong number of parameters for aggregate method.")
77
+ }
78
+
79
+ renderResult := render.createEphemeral(llAggTpl, renderInputs)
80
+ return renderResult;
81
81
  }
82
82
 
83
83
  export ll.toStrict({
84
- aggregate: aggregate
84
+ aggregate: aggregate
85
85
  })
@@ -1,6 +1,6 @@
1
-
2
-
3
-
1
+ /**
2
+ * Working with a single p-column
3
+ */
4
4
 
5
5
  ll := import("@platforma-sdk/workflow-tengo:ll")
6
6
  oop := import("@platforma-sdk/workflow-tengo:oop")
@@ -8,62 +8,62 @@ json := import("json")
8
8
  smart := import("@platforma-sdk/workflow-tengo:smart")
9
9
  constants := import("@platforma-sdk/workflow-tengo:pframes.constants")
10
10
 
11
-
12
-
13
-
11
+ /**
12
+ * Returns true if given resource is a p-column resource map data
13
+ */
14
14
  isResourceMap := func(r) {
15
- return smart.isResource(r) && r.info().Type.Name == constants.RTYPE_P_COLUMN_DATA_RESOURCE_MAP.Name
15
+ return smart.isResource(r) && r.info().Type.Name == constants.RTYPE_P_COLUMN_DATA_RESOURCE_MAP.Name
16
16
  }
17
17
 
18
-
19
-
20
-
21
-
22
-
18
+ /**
19
+ * Creates a builder for a resource map p-column's data.
20
+ *
21
+ * @param keyLength: int - key length
22
+ */
23
23
  resourceMapBuilder := func(keyLength) {
24
- r := smart.structBuilder(
25
- constants.RTYPE_P_COLUMN_DATA_RESOURCE_MAP,
26
- json.encode({ keyLength: keyLength })
27
- )
28
-
29
- self := undefined
30
- self = ll.toStrict(oop.inherit(r, {
31
-
32
- add: func(key, data) {
33
- ll.assert(is_array(key), "key must be an array, got ", key)
34
- ll.assert(len(key) == keyLength, "array length does not match specified keyLength", key, keyLength)
35
- r.createInputField(json.encode(key)).setRefOrJson(data)
36
- return self
37
- },
38
-
39
- build: func() {
40
- return r.lockAndBuild()
41
- }
42
- }))
43
- return self
24
+ r := smart.structBuilder(
25
+ constants.RTYPE_P_COLUMN_DATA_RESOURCE_MAP,
26
+ json.encode({ keyLength: keyLength })
27
+ )
28
+
29
+ self := undefined
30
+ self = ll.toStrict(oop.inherit(r, {
31
+
32
+ add: func(key, data) {
33
+ ll.assert(is_array(key), "key must be an array, got ", key)
34
+ ll.assert(len(key) == keyLength, "array length does not match specified keyLength", key, keyLength)
35
+ r.createInputField(json.encode(key)).setRefOrJson(data)
36
+ return self
37
+ },
38
+
39
+ build: func() {
40
+ return r.lockAndBuild()
41
+ }
42
+ }))
43
+ return self
44
44
  }
45
45
 
46
-
47
-
48
-
49
-
50
-
51
-
52
-
46
+ /**
47
+ * Convert map object to a p-column resource map.
48
+ *
49
+ * @param map - tengo map
50
+ * @param keyLength: int - length of the partitioned key
51
+ * @param keyParser: func - function to parse string map keys and return array of p-column keys
52
+ */
53
53
  fromMap := func(map, keyLength, keyParser) {
54
- b := resourceMapBuilder(keyLength)
54
+ b := resourceMapBuilder(keyLength)
55
55
 
56
- for k, v in map {
57
- arr := keyParser(k)
58
- ll.assert(is_array(arr), "keyParser should return array")
59
- b.add(arr, v)
60
- }
56
+ for k, v in map {
57
+ arr := keyParser(k)
58
+ ll.assert(is_array(arr), "keyParser should return array")
59
+ b.add(arr, v)
60
+ }
61
61
 
62
- return b.build()
62
+ return b.build()
63
63
  }
64
64
 
65
65
  export ll.toStrict({
66
- fromMap: fromMap,
67
- isResourceMap: isResourceMap,
68
- resourceMapBuilder: resourceMapBuilder
66
+ fromMap: fromMap,
67
+ isResourceMap: isResourceMap,
68
+ resourceMapBuilder: resourceMapBuilder
69
69
  })
@@ -1,136 +1,136 @@
1
-
2
-
3
-
4
-
5
-
1
+ /**
2
+ * PFrames spec library:
3
+ * - well known domains, annotations and column names.
4
+ * - utility methods to manipulate column and axis spec
5
+ */
6
6
 
7
7
  ll := import("@platforma-sdk/workflow-tengo:ll")
8
8
  maps := import("@platforma-sdk/workflow-tengo:maps")
9
9
  validation := import("@platforma-sdk/workflow-tengo:validation")
10
10
  json := import("json")
11
11
 
12
-
13
-
14
-
12
+ //
13
+ // Common schemas
14
+ //
15
15
 
16
16
  P_AXIS_SPEC_SCHEMA := {
17
-
18
- `type`: `string,regex=Int|Long|Float|Double|String`,
19
- `name`: `string`,
20
- `domain,?`: { any: `string` },
21
- `annotations,?`: { any: `string` },
22
- `parentAxes,?`: `any` // [ `number` ]
17
+ // `__options__,closed`: ``, // commented out to keep the room for future schema modifications
18
+ `type`: `string,regex=Int|Long|Float|Double|String`,
19
+ `name`: `string`,
20
+ `domain,?`: { any: `string` },
21
+ `annotations,?`: { any: `string` },
22
+ `parentAxes,?`: `any` // [ `number` ]
23
23
  }
24
24
 
25
25
  P_COLUMN_SPEC_SCHEMA := {
26
-
27
- `kind`: `string,regex=PColumn`,
28
- `valueType`: `string`,
29
- `name`: `string`,
30
- `domain,?`: { any: `string` },
31
- `annotations,?`: { any: `string` },
32
- `parentAxes,?`: `any`, // [ `number` ]
33
- `axesSpec,?`: [ P_AXIS_SPEC_SCHEMA ]
26
+ // `__options__,closed`: ``, // commented out to keep the room for future schema modifications
27
+ `kind`: `string,regex=PColumn`,
28
+ `valueType`: `string`,
29
+ `name`: `string`,
30
+ `domain,?`: { any: `string` },
31
+ `annotations,?`: { any: `string` },
32
+ `parentAxes,?`: `any`, // [ `number` ]
33
+ `axesSpec,?`: [ P_AXIS_SPEC_SCHEMA ]
34
34
  }
35
35
 
36
36
  KIND_P_COLUMN := "PColumn"
37
37
 
38
+ //
39
+ // Column / axis names
40
+ //
38
41
 
39
-
40
-
41
-
42
-
42
+ /** Column containing labels for axis keys */
43
43
  N_LABEL := "pl7.app/label"
44
44
 
45
+ //
46
+ // Column / axis domains
47
+ //
45
48
 
46
-
47
-
48
-
49
-
49
+ /** Domain marking column or axis as block-specific, value must contain block id */
50
50
  D_BLOCK := "pl7.app/block"
51
51
 
52
+ //
53
+ // Column / axis annotations
54
+ //
52
55
 
53
-
54
-
55
-
56
-
56
+ /** Annotation with axis or column label */
57
57
  A_LABEL := "pl7.app/label"
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
58
+ /**
59
+ * Annotation containing trace of operations resulting in a corresponding column.
60
+ *
61
+ * Value must containe JSON encoded array of structures:
62
+ * {
63
+ * type: string - type of the step, often equals to block package name (i.e. milaboratories.mixcr-clonotyping)
64
+ * label: string - string representation of the operation often a block title
65
+ * importance: number - higher the number higher the change label from trace step will be used to derive column label
66
+ * id: string - unique identifier of operation, often a block id
67
+ * }
68
+ */
69
69
  A_TRACE := "pl7.app/trace"
70
70
 
71
-
72
-
73
-
71
+ //
72
+ // Utility methods
73
+ //
74
74
 
75
75
  _TRACE_STEP_SCHEMA := {
76
- `type`: `string`,
77
- `label`: `string`,
78
- `importance,?`: `number`,
79
- `id,?`: `string`,
80
- `__options__,closed`: ``
76
+ `type`: `string`,
77
+ `label`: `string`,
78
+ `importance,?`: `number`,
79
+ `id,?`: `string`,
80
+ `__options__,closed`: ``
81
81
  }
82
82
 
83
83
  _TRACE_SCHEMA := [_TRACE_STEP_SCHEMA]
84
84
 
85
-
86
-
87
-
88
-
89
-
90
-
85
+ /**
86
+ * Calculates content of pl7.app/trace annotation, given input column spec, or annotations section
87
+ * of specs, or directly content of pl7.app/trace from the input column spec.
88
+ *
89
+ * Basically validates and adds provided steps.
90
+ */
91
91
  makeTrace := func(input, ...steps) {
92
-
93
- validation.assertJsonSchema(steps, _TRACE_SCHEMA)
94
-
95
- currentTraceContent := undefined
96
- if is_string(input) {
97
- currentTraceContent = input
98
- } else if is_string(input[A_TRACE]) {
99
- currentTraceContent = input[A_TRACE]
100
- } else if is_string(input["annotations"][A_TRACE]) {
101
- currentTraceContent = input["annotations"][A_TRACE]
102
- }
103
-
104
- currentTrace := []
105
- if !is_undefined(currentTraceContent) {
106
- currentTrace = json.decode(currentTraceContent)
107
-
108
- validation.assertJsonSchema(currentTrace, _TRACE_SCHEMA)
109
- }
110
-
111
- currentTrace = append(currentTrace, steps...)
112
- currentTraceStr := string(json.encode(currentTrace))
113
-
114
- return ll.toStrict({
115
- value: currentTrace,
116
- valueStr: currentTraceStr,
117
-
118
- inject: func(spec) {
119
- validation.assertJsonSchema(spec, P_COLUMN_SPEC_SCHEMA)
120
- return maps.deepMerge(spec, {annotations: {"pl7.app/trace": currentTraceStr}})
121
- }
122
- })
92
+ // validating input step structure
93
+ validation.assertJsonSchema(steps, _TRACE_SCHEMA)
94
+
95
+ currentTraceContent := undefined
96
+ if is_string(input) {
97
+ currentTraceContent = input
98
+ } else if is_string(input[A_TRACE]) {
99
+ currentTraceContent = input[A_TRACE]
100
+ } else if is_string(input["annotations"][A_TRACE]) {
101
+ currentTraceContent = input["annotations"][A_TRACE]
102
+ }
103
+
104
+ currentTrace := []
105
+ if !is_undefined(currentTraceContent) {
106
+ currentTrace = json.decode(currentTraceContent)
107
+ // validating trace we just parsed
108
+ validation.assertJsonSchema(currentTrace, _TRACE_SCHEMA)
109
+ }
110
+
111
+ currentTrace = append(currentTrace, steps...)
112
+ currentTraceStr := string(json.encode(currentTrace))
113
+
114
+ return ll.toStrict({
115
+ value: currentTrace,
116
+ valueStr: currentTraceStr,
117
+ /** Injects trace information into column spec */
118
+ inject: func(spec) {
119
+ validation.assertJsonSchema(spec, P_COLUMN_SPEC_SCHEMA)
120
+ return maps.deepMerge(spec, {annotations: {"pl7.app/trace": currentTraceStr}})
121
+ }
122
+ })
123
123
  }
124
124
 
125
125
  export ll.toStrict({
126
- KIND_P_COLUMN: KIND_P_COLUMN,
126
+ KIND_P_COLUMN: KIND_P_COLUMN,
127
127
 
128
- N_LABEL: N_LABEL,
128
+ N_LABEL: N_LABEL,
129
129
 
130
- D_BLOCK: D_BLOCK,
130
+ D_BLOCK: D_BLOCK,
131
131
 
132
- A_LABEL: A_LABEL,
133
- A_TRACE: A_TRACE,
132
+ A_LABEL: A_LABEL,
133
+ A_TRACE: A_TRACE,
134
134
 
135
- makeTrace: makeTrace
135
+ makeTrace: makeTrace
136
136
  })