@coherentglobal/spark-execute-sdk 0.7.3 → 0.8.1

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 CHANGED
@@ -117,6 +117,42 @@ const response = await Spark.execute(input, version_id).catch((err) => {
117
117
  });
118
118
  ```
119
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
+
120
156
  Note: The second parameter (version_id) is optional if version_id is already included on request_meta
121
157
 
122
158
  ### Sample Input