@coherentglobal/spark-execute-sdk 0.6.0 → 0.8.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.
- package/README.md +40 -0
- package/dist/browser.js +1945 -408
- package/package.json +2 -2
- package/src/browser.js +159 -24
- package/src/config.js +5 -0
- package/src/constants.js +5 -0
- package/src/error.js +11 -0
- package/src/findModels.js +4 -21
- package/src/helpers/utils.js +68 -10
- package/src/node.js +242 -53
- package/src/resolver/externalResolver.js +43 -10
- package/src/validate.js +4 -1
- package/src/xcallTracker.js +100 -0
- package/types/browser.d.ts +21 -2
- package/types/browser.d.ts.map +1 -1
- package/types/config.d.ts +5 -0
- package/types/config.d.ts.map +1 -0
- package/types/constants.d.ts +2 -0
- package/types/constants.d.ts.map +1 -0
- package/types/error.d.ts +5 -0
- package/types/error.d.ts.map +1 -1
- package/types/findModels.d.ts.map +1 -1
- package/types/helpers/utils.d.ts +6 -0
- package/types/helpers/utils.d.ts.map +1 -1
- package/types/node.d.ts +31 -3
- package/types/node.d.ts.map +1 -1
- package/types/resolver/externalResolver.d.ts.map +1 -1
- package/types/services/entityStore.d.ts +2 -2
- package/types/services/entityStore.d.ts.map +1 -1
- package/types/validate.d.ts.map +1 -1
- package/types/xcallTracker.d.ts +7 -0
- package/types/xcallTracker.d.ts.map +1 -0
- package/tsconfig.json +0 -107
package/README.md
CHANGED
|
@@ -41,6 +41,8 @@ const config = {
|
|
|
41
41
|
versionId: "uuid",
|
|
42
42
|
type: "base64",
|
|
43
43
|
binary: Blob | Base64 | BinaryUnit | Func(versionId), // a binary zipped file or a function the will get the zipped file
|
|
44
|
+
preventCleanup: true | false, // prevent model from being unload (default: false)
|
|
45
|
+
instance: int, // number of model instance (default: 1)
|
|
44
46
|
metadata: {
|
|
45
47
|
// Spark Model Metadata
|
|
46
48
|
}
|
|
@@ -75,6 +77,8 @@ const config = {
|
|
|
75
77
|
versionId: "uuid",
|
|
76
78
|
type: "base64",
|
|
77
79
|
binary: Blob | Base64 | BinaryUnit | Func(versionId), // a binary zipped file or a function the will get the zipped file
|
|
80
|
+
preventCleanup: true | false, // prevent model from being unload (default: false)
|
|
81
|
+
replica: int, // number of model instance (default: 1)
|
|
78
82
|
metadata: {
|
|
79
83
|
// Spark Model Metadata
|
|
80
84
|
},
|
|
@@ -113,6 +117,42 @@ const response = await Spark.execute(input, version_id).catch((err) => {
|
|
|
113
117
|
});
|
|
114
118
|
```
|
|
115
119
|
|
|
120
|
+
### executeWithCancellationToken(input)
|
|
121
|
+
|
|
122
|
+
Perform the calculation with cancellationToken. The sdk will use the request_meta.version_uuid of input argument to locate the model
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
const execute = Spark.executeWithCancellationToken(input)
|
|
126
|
+
|
|
127
|
+
// Cancel the execution (best effort)
|
|
128
|
+
execute.cancellationToken.cancel()
|
|
129
|
+
|
|
130
|
+
execute.response.then((result) => {
|
|
131
|
+
// Do something here
|
|
132
|
+
})
|
|
133
|
+
.catch((err) => {
|
|
134
|
+
// Do something here
|
|
135
|
+
// If error is instance of Spark.WasmRunnerErrors.ExecuteCancelled, meaning the request has been cancelled
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
or
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
const execute = Spark.executeWithCancellationToken(input)
|
|
143
|
+
|
|
144
|
+
// Cancel the execution (best effort)
|
|
145
|
+
execute.cancellationToken.cancel()
|
|
146
|
+
|
|
147
|
+
execute.response.then((result) => {
|
|
148
|
+
// Do something here
|
|
149
|
+
})
|
|
150
|
+
.catch((err) => {
|
|
151
|
+
// Do something here
|
|
152
|
+
// If error is instance of Spark.WasmRunnerErrors.ExecuteCancelled, meaning the request has been cancelled
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
116
156
|
Note: The second parameter (version_id) is optional if version_id is already included on request_meta
|
|
117
157
|
|
|
118
158
|
### Sample Input
|