@platforma-sdk/workflow-tengo 1.4.1 → 1.5.0

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.
@@ -185,7 +185,7 @@ _remotePackageCallOptions := func(runOptions) {
185
185
  }
186
186
 
187
187
  binaryRunOptions := func(runOptions) {
188
- if (is_undefined(runOptions.software)) {
188
+ if (is_undefined(ll.fromStrict(runOptions).software)) {
189
189
  //
190
190
  // Simple local command run, no software pacakges involved (backward compatibility)
191
191
  //
@@ -159,10 +159,11 @@ purifySpec := func(spec) {
159
159
 
160
160
  newAxes := []
161
161
  for ax in spec.axes {
162
- newAxes = append(newAxes, {
162
+ newAxes = append(newAxes, objects.deleteUndefined({
163
163
  column: ax.column,
164
+ preProcess: ax.preProcess,
164
165
  spec: { type: ax.spec.type }
165
- })
166
+ }))
166
167
  }
167
168
  newSpec.axes = newAxes
168
169
 
@@ -170,6 +171,7 @@ purifySpec := func(spec) {
170
171
  for col in spec.columns {
171
172
  newCols = append(newCols, objects.deleteUndefined({
172
173
  column: col.column,
174
+ preProcess: col.preProcess,
173
175
  id: col.id,
174
176
  allowNA: col.allowNA,
175
177
  spec: { valueType: col.spec.valueType }
@@ -12,6 +12,7 @@ util := import("@platforma-sdk/workflow-tengo:pframes.util")
12
12
  ll := import("@platforma-sdk/workflow-tengo:ll")
13
13
  assets := import("@platforma-sdk/workflow-tengo:assets")
14
14
 
15
+ transposeXsvSw := assets.importSoftware("@milaboratories/software-small-binaries:table-converter")
15
16
  pfconvSw := assets.importSoftware("@milaboratories/software-pframes-conv:main")
16
17
 
17
18
  /**
@@ -60,7 +61,22 @@ getColumnSpec := func(axesSpec, col) {
60
61
  * @param xsvFile: reference - a reference to a file
61
62
  * @param xsvType: string - either csv or tsv
62
63
  * @param spec: object - xsv conversion specification
63
- * @param ops: dict - additional params (internal)
64
+ * @param ops: object - additional options
65
+ * {
66
+ * dataOnly: boolean - set to true to completely skip creation of specs
67
+ * transpose: object - if specified, then the input table will be transposed
68
+ * {
69
+ * separator: string - (optional) use separator instead of inferring from the file extension
70
+ * pAxisIdx: index - (optional) the index of the primary axis (column in the input xsv); default 0
71
+ * pAxisName: string - (optional) the name of the primary axis (column name in the input xsv); default undefined
72
+ * pAxisSearch: regex - (optional) the regex pattern of the name of the primary axis (column name in the input xsv); default undefined
73
+ * pAxisNameOverride: string - (optional) override primary axis header in the output; default undefined
74
+ * sAxisSearch: string - (optional) regex to filter secondary axis columns in the input table;
75
+ * sAxisName: string - (optional) the name of the secondary axis (column name in the output xsv); default "Metric"
76
+ * valueName: string - (optional) the name of the value column; default "Value"
77
+ * separatorOverride: string - (optional) specify separator in the output (optional)
78
+ * }
79
+ * }
64
80
  * @return map: reference - a reference to a map resource storing imported data.
65
81
  */
66
82
  importFile := func(xsvFile, xsvType, spec, ...ops) {
@@ -70,6 +86,58 @@ importFile := func(xsvFile, xsvType, spec, ...ops) {
70
86
 
71
87
  xsvFileName := "file." + xsvType
72
88
 
89
+ ops := renderOps({ dataOnly: false }, ops...)
90
+
91
+ if ops.transpose != undefined {
92
+
93
+ tops := ops.transpose
94
+
95
+ transposedFileName := "fileTransposed." + xsvType
96
+
97
+ // convert csv to p-frame and read resulting data
98
+ transposeXsv := exec.builder().
99
+ software(transposeXsvSw).
100
+ printErrStreamToStdout().
101
+ inLightQueue()
102
+
103
+ if (tops.separator != undefined) {
104
+ transposeXsv = transposeXsv.arg("-input-separator").arg(tops.separator)
105
+ }
106
+ if (tops.pAxisIdx != undefined) {
107
+ transposeXsv = transposeXsv.arg("-sample-column-i").arg("" + tops.pAxisIdx) // always convert to string
108
+ }
109
+ if (tops.pAxisName != undefined) {
110
+ transposeXsv = transposeXsv.arg("-sample-column-name").arg(tops.pAxisName)
111
+ }
112
+ if (tops.pAxisSearch != undefined) {
113
+ transposeXsv = transposeXsv.arg("-sample-column-search").arg(tops.pAxisSearch)
114
+ }
115
+ if (tops.pAxisNameOverride != undefined) {
116
+ transposeXsv = transposeXsv.arg("-sample-label").arg(tops.pAxisNameOverride)
117
+ }
118
+ if (tops.sAxisSearch != undefined) {
119
+ transposeXsv = transposeXsv.arg("-metric-columns-search").arg(tops.sAxisSearch)
120
+ }
121
+ if (tops.sAxisName != undefined) {
122
+ transposeXsv = transposeXsv.arg("-metric-label").arg(tops.sAxisName)
123
+ }
124
+ if (tops.valueName != undefined) {
125
+ transposeXsv = transposeXsv.arg("-value-label").arg(tops.valueName)
126
+ }
127
+ if (tops.separatorOverride != undefined) {
128
+ transposeXsv = transposeXsv.arg("-separator").arg(tops.separatorOverride)
129
+ }
130
+
131
+ transposeXsv = transposeXsv.
132
+ arg(xsvFileName).
133
+ arg(transposedFileName).
134
+ addFile(xsvFileName, xsvFile).
135
+ saveFile(transposedFileName).
136
+ run()
137
+
138
+ xsvFile = transposeXsv.getFile(transposedFileName)
139
+ }
140
+
73
141
  // import p-frame from directory tpl
74
142
  importDirTpl := assets.importTemplate("@platforma-sdk/workflow-tengo:pframes.import-dir")
75
143
 
@@ -90,8 +158,6 @@ importFile := func(xsvFile, xsvType, spec, ...ops) {
90
158
  processWorkdir("pf", importDirTpl, pureSpec).
91
159
  run()
92
160
 
93
- ops := renderOps({ dataOnly: false }, ops...)
94
-
95
161
  // p-columns data
96
162
  pf := pfconv.getProcessorResult("pf")
97
163
  if ops.dataOnly {
@@ -125,6 +191,18 @@ importFile := func(xsvFile, xsvType, spec, ...ops) {
125
191
  * with "spec" + "data" fields in nested maps
126
192
  * additionalAxesSpec: AxisSpec[] - array of additional axes spec to prepend to
127
193
  * each column spec
194
+ * transpose: object - if specified, then the input table will be transposed
195
+ * {
196
+ * separator: string - (optional) use separator instead of inferring from the file extension
197
+ * pAxisIdx: index - (optional) the index of the primary axis (column in the input xsv); default 0
198
+ * pAxisName: string - (optional) the name of the primary axis (column name in the input xsv); default undefined
199
+ * pAxisSearch: regex - (optional) the regex pattern of the name of the primary axis (column name in the input xsv); default undefined
200
+ * pAxisNameOverride: string - (optional) override primary axis header in the output; default undefined
201
+ * sAxisSearch: string - (optional) regex to filter secondary axis columns in the input table;
202
+ * sAxisName: string - (optional) the name of the secondary axis (column name in the output xsv); default "Metric"
203
+ * valueName: string - (optional) the name of the value column; default "Value"
204
+ * separatorOverride: string - (optional) specify separator in the output (optional)
205
+ * }
128
206
  * }
129
207
  * @return map: reference - a reference to a map resource storing imported data.
130
208
  */
@@ -135,7 +213,8 @@ importFileMap := func(xsvMap, xsvType, spec, ...ops) {
135
213
  ops := renderOps({
136
214
  dataOnly: false,
137
215
  splitDataAndSpec: false,
138
- additionalAxesSpec: []
216
+ additionalAxesSpec: [],
217
+ transpose: undefined
139
218
  }, ops...)
140
219
 
141
220
  // spec without any metadata (for caching purposes)
@@ -147,7 +226,7 @@ importFileMap := func(xsvMap, xsvType, spec, ...ops) {
147
226
  xsvMap: xsvMap,
148
227
  xsvType: xsvType,
149
228
  spec: pureSpec,
150
- ops: { dataOnly: true }
229
+ ops: { dataOnly: true, transpose: ops.transpose }
151
230
  })
152
231
 
153
232
  if ops.dataOnly && ops.splitDataAndSpec {
@@ -170,7 +249,7 @@ importFileMap := func(xsvMap, xsvType, spec, ...ops) {
170
249
  result[id + ".spec"] = columnsSpec[id]
171
250
  }
172
251
  }
173
-
252
+
174
253
  return result
175
254
  }
176
255
 
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/workflow-tengo",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -16,7 +16,8 @@
16
16
  "./dist/**/*"
17
17
  ],
18
18
  "dependencies": {
19
- "@milaboratories/software-pframes-conv": "^1.5.10"
19
+ "@milaboratories/software-pframes-conv": "^1.6.0",
20
+ "@milaboratories/software-small-binaries": "^1.11.2"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@platforma-sdk/tengo-builder": "^1.14.13"