@platforma-sdk/workflow-tengo 1.6.1 → 1.6.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.
@@ -22,12 +22,13 @@ importTemplate := func(tplName) {
22
22
  /**
23
23
  * Returns software description suitable for 'exec' operations.
24
24
  *
25
- * @param swName: string - full name of the software description, including namespace (package name).
26
- * Local software definitions (within the same package) can omit namespace part and start the name with colon:
27
- * - "@company/package:some-oftware"
28
- * - ":my-local-software"
25
+ * @param swName: string - full name of the software entrypoint, including namespace (NPM package name).
26
+ * Local software entrypoints (within the same package) can omit namespace part
27
+ * and start the name with colon:
28
+ * - "@company/package:some-oftware"
29
+ * - ":my-local-software"
29
30
  *
30
- * @return softwareInfo: softwareInfo - structure with software info
31
+ * @return softwareInfo: softwareInfo - structure with software info.
31
32
  */
32
33
  importSoftware := func(swName) {
33
34
  sw := plapi.getSoftwareInfo(swName)
@@ -42,6 +43,29 @@ importSoftware := func(swName) {
42
43
  })
43
44
  }
44
45
 
46
+ /**
47
+ * Returns asset description suitable for 'exec' operations.
48
+ * Asset is the way to put static files into working directory before execution of the command.
49
+ *
50
+ * @param assetName: string - full name of asset entrypoint, including namespace (NPM package name).
51
+ * Local software entrypoints (within the same package) can omit namespace
52
+ * part and start the name with colon:
53
+ * - "@company/package:some-oftware"
54
+ * - ":my-local-software"
55
+ */
56
+ importAsset := func(swName) {
57
+ asset := plapi.getSoftwareInfo(swName)
58
+ return ll.toStrict({
59
+ _type: "assetDescriptor",
60
+
61
+ resource: smart.resource(asset.id),
62
+ name: asset.name,
63
+ version: asset.version,
64
+ blobRef: asset.blobRef,
65
+ descriptor: ll.toStrict(json.decode(asset.descriptor)) // raw sw.json data with asset entrypoint descriptor
66
+ })
67
+ }
68
+
45
69
  /**
46
70
  * Checks if given item is a software info
47
71
  *
@@ -89,7 +89,7 @@ _loadPythonRunEnvironment := func(descriptor, softName, softPkg) {
89
89
  }
90
90
 
91
91
  venv := venvBuilder.
92
- cache(7 * 24 * times.hour).
92
+ cacheDays(7).
93
93
  build().
94
94
  venv()
95
95
 
@@ -179,6 +179,7 @@ builder := func() {
179
179
  },
180
180
 
181
181
  /**
182
+ * @deprecated, use cacheMillis, cacheSeconds, cacheMinutes, cacheHours and cacheDays instead.
182
183
  * Sets the cache time.
183
184
  *
184
185
  * @param time: duration - the cache time from 'times' library.
@@ -192,6 +193,61 @@ builder := func() {
192
193
  return self
193
194
  },
194
195
 
196
+ /**
197
+ * Sets the cache time in milliseconds.
198
+ *
199
+ * @param millis: number
200
+ */
201
+ cacheMillis: func(millis) {
202
+ ll.assert(is_int(millis) && millis > 0, "cache time must be a number of milliseconds")
203
+ cache = millis * times.millisecond
204
+ return self
205
+ },
206
+
207
+ /**
208
+ * Sets the cache time in seconds.
209
+ *
210
+ * @param seconds: number
211
+ */
212
+ cacheSeconds: func(seconds) {
213
+ ll.assert(is_int(seconds) && seconds > 0, "cache time must be a number of seconds")
214
+ cache = seconds * times.second
215
+ return self
216
+ },
217
+
218
+ /**
219
+ * Sets the cache time in minutes.
220
+ *
221
+ * @param minutes: number
222
+ */
223
+ cacheMinutes: func(minutes) {
224
+ ll.assert(is_int(minutes) && minutes > 0, "cache time must be a number of minutes")
225
+ cache = minutes * times.minute
226
+ return self
227
+ },
228
+
229
+ /**
230
+ * Sets the cache time in hours.
231
+ *
232
+ * @param hours: number
233
+ */
234
+ cacheHours: func(hours) {
235
+ ll.assert(is_int(hours) && hours > 0, "cache time must be a number of hours")
236
+ cache = hours * times.hour
237
+ return self
238
+ },
239
+
240
+ /**
241
+ * Sets the cache time in days
242
+ *
243
+ * @param days: number
244
+ */
245
+ cacheDays: func(days) {
246
+ ll.assert(is_int(days) && days > 0, "cache time must be a number of days")
247
+ cache = days * times.hour * 24
248
+ return self
249
+ },
250
+
195
251
  /**
196
252
  * Sets the number of error lines to be captured.
197
253
  *
@@ -10,6 +10,7 @@ validation := import("@platforma-sdk/workflow-tengo:validation")
10
10
  pkg := import("@platforma-sdk/workflow-tengo:exec.package")
11
11
  assets := import("@platforma-sdk/workflow-tengo:assets")
12
12
  render := import("@platforma-sdk/workflow-tengo:render")
13
+ times := import("times")
13
14
 
14
15
  _RTYPE_SAVE_RUN_ENV := { Name: "SaveRunEnv/executor", Version: "1" }
15
16
  _INPUT_SETTINGS := "settings"
@@ -167,6 +168,62 @@ pythonVenv := func() {
167
168
  },
168
169
 
169
170
  /**
171
+ * Sets the cache time in milliseconds.
172
+ *
173
+ * @param millis: number
174
+ */
175
+ cacheMillis: func(millis) {
176
+ ll.assert(is_int(millis) && millis > 0, "cache time must be a number of milliseconds")
177
+ cache = millis * times.millisecond
178
+ return self
179
+ },
180
+
181
+ /**
182
+ * Sets the cache time in seconds.
183
+ *
184
+ * @param seconds: number
185
+ */
186
+ cacheSeconds: func(seconds) {
187
+ ll.assert(is_int(seconds) && seconds > 0, "cache time must be a number of seconds")
188
+ cache = seconds * times.second
189
+ return self
190
+ },
191
+
192
+ /**
193
+ * Sets the cache time in minutes.
194
+ *
195
+ * @param minutes: number
196
+ */
197
+ cacheMinutes: func(minutes) {
198
+ ll.assert(is_int(minutes) && minutes > 0, "cache time must be a number of minutes")
199
+ cache = minutes * times.minute
200
+ return self
201
+ },
202
+
203
+ /**
204
+ * Sets the cache time in hours.
205
+ *
206
+ * @param hours: number
207
+ */
208
+ cacheHours: func(hours) {
209
+ ll.assert(is_int(hours) && hours > 0, "cache time must be a number of hours")
210
+ cache = hours * times.hour
211
+ return self
212
+ },
213
+
214
+ /**
215
+ * Sets the cache time in days
216
+ *
217
+ * @param days: number
218
+ */
219
+ cacheDays: func(days) {
220
+ ll.assert(is_int(days) && days > 0, "cache time must be a number of days")
221
+ cache = days * times.hour * 24
222
+ return self
223
+ },
224
+
225
+ /**
226
+ * @deprecated, use cacheMillis, cacheSeconds, cacheMinutes, cacheHours and cacheDays instead.
170
227
  * Sets the cache time.
171
228
  *
172
229
  * @param time: duration - the cache time from 'times' library.
@@ -35,6 +35,9 @@ _SPEC_AXES_SCHEMA := {
35
35
  // Should the N/A values (or empty rows) be allowed;
36
36
  // default: false
37
37
  `allowNA,omitempty`: `bool`,
38
+ // Should the parsing error be interpreted as N/A
39
+ // default: false
40
+ `parseErrorToNA,omitempty`: `bool`,
38
41
  // Specification of the axis
39
42
  `spec`: {
40
43
  // Type of the axis value
@@ -66,6 +69,9 @@ _SPEC_COLUMN_SCHEMA := {
66
69
  // Should the N/A values (or empty rows) be allowed;
67
70
  // default: true
68
71
  `allowNA,omitempty`: `bool`,
72
+ // Should the parsing error be interpreted as N/A
73
+ // default: false
74
+ `parseErrorToNA,omitempty`: `bool`,
69
75
  // Specification of the column
70
76
  `spec,omitempty`: {
71
77
  // Type of column values;
@@ -10,6 +10,7 @@ constants := import("@platforma-sdk/workflow-tengo:constants")
10
10
  oop := import("@platforma-sdk/workflow-tengo:oop")
11
11
  validation := import("@platforma-sdk/workflow-tengo:validation")
12
12
  tx := import("tx")
13
+ times := import("times")
13
14
 
14
15
 
15
16
  _SUBSCRIPTION_FIELD := "subscription"
@@ -61,7 +62,7 @@ createUniversal := func(tpl, isEph, inputs) {
61
62
  out := renderer.getFutureOutputField(tplutil.TEMPLATE_OUTPUT_PREFIX + name)
62
63
  if len(cache) > 0 && cache[0] > 0 {
63
64
  cache = cache[0]
64
- tx.cacheSetToField(out.id, cache)
65
+ tx.cacheSetToField(out.id, cache * times.millisecond)
65
66
  }
66
67
 
67
68
  return out
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/workflow-tengo",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -16,11 +16,11 @@
16
16
  "./dist/**/*"
17
17
  ],
18
18
  "dependencies": {
19
- "@milaboratories/software-pframes-conv": "^1.6.0",
20
- "@platforma-open/milaboratories.software-small-binaries": "^1.13.2"
19
+ "@milaboratories/software-pframes-conv": "^1.6.3",
20
+ "@platforma-open/milaboratories.software-small-binaries": "^1.14.4"
21
21
  },
22
22
  "devDependencies": {
23
- "@platforma-sdk/tengo-builder": "^1.14.13"
23
+ "@platforma-sdk/tengo-builder": "^1.15.0"
24
24
  },
25
25
  "scripts": {
26
26
  "type-check": "pl-tengo check",