@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 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