@coherentglobal/spark-execute-sdk 0.4.3 → 0.4.5

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/dist/browser.js CHANGED
@@ -958,7 +958,7 @@ var safeJsonParser = function safeJsonParser(data) {
958
958
  var result = JSON.parse(data);
959
959
  return result;
960
960
  } catch (err) {
961
- console.log('SAFE JSON PARSER FAILED: ', err);
961
+ console.log("SAFE JSON PARSER FAILED: ", err);
962
962
  return undefined;
963
963
  }
964
964
  };
@@ -1133,7 +1133,7 @@ var WasmRunner = /*#__PURE__*/function () {
1133
1133
  case 13:
1134
1134
  _context13.prev = 13;
1135
1135
  _context13.t0 = _context13["catch"](0);
1136
- console.log('CHILD MODEL ERROR:', _context13.t0);
1136
+ console.log("CHILD MODEL ERROR:", _context13.t0);
1137
1137
  reject(_context13.t0);
1138
1138
  case 17:
1139
1139
  case "end":
@@ -1354,7 +1354,8 @@ var WasmRunner = /*#__PURE__*/function () {
1354
1354
  model.results[callid] = undefined;
1355
1355
  resolve(tryParsingResult);
1356
1356
  } else {
1357
- if (counter < 100) {
1357
+ if (counter < 6000) {
1358
+ // Increase timeout into 60s
1358
1359
  counter++;
1359
1360
  getResult();
1360
1361
  } else {
@@ -1362,7 +1363,8 @@ var WasmRunner = /*#__PURE__*/function () {
1362
1363
  }
1363
1364
  }
1364
1365
  } else {
1365
- if (counter < 100) {
1366
+ if (counter < 6000) {
1367
+ // Increase timeout into 60s
1366
1368
  counter++;
1367
1369
  getResult();
1368
1370
  } else {
@@ -6438,20 +6440,20 @@ var Spark = /*#__PURE__*/function () {
6438
6440
  key: "offlineModel",
6439
6441
  value: function () {
6440
6442
  var _offlineModel = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(input, versionID, ds) {
6441
- var _input$request_meta3;
6442
- var modelVersionId, callback, _model4$metaData$Engi, _model4$metaData, _model4$metaData$Engi2, _model4$metaData$Engi3, _model4$metaData2, _model4$metaData2$Eng, _model4, result;
6443
+ var model, modelVersionId, callback, _model2$metaData$Engi, _model2$metaData, _model2$metaData$Engi2, _model2$metaData$Engi3, _model2$metaData2, _model2$metaData2$Eng, _model2, result;
6443
6444
  return _regenerator["default"].wrap(function _callee3$(_context3) {
6444
6445
  while (1) {
6445
6446
  switch (_context3.prev = _context3.next) {
6446
6447
  case 0:
6447
- modelVersionId = (input === null || input === void 0 ? void 0 : (_input$request_meta3 = input.request_meta) === null || _input$request_meta3 === void 0 ? void 0 : _input$request_meta3.version_id) || versionID;
6448
+ model = ds._findModel(input.request_meta);
6449
+ modelVersionId = versionID || model && (model === null || model === void 0 ? void 0 : model.versionId); // const modelVersionId = input?.request_meta?.version_id || versionID;
6448
6450
  if (!(input !== null && input !== void 0 && input.request_meta)) {
6449
6451
  input.request_meta = {};
6450
6452
  }
6451
6453
  if (versionID) {
6452
6454
  input.request_meta.version_id = modelVersionId;
6453
6455
  }
6454
- _context3.prev = 3;
6456
+ _context3.prev = 4;
6455
6457
  if (!(registry instanceof WasmRunner)) {
6456
6458
  /**
6457
6459
  * Options is the request data the the runner dispatch
@@ -6461,7 +6463,7 @@ var Spark = /*#__PURE__*/function () {
6461
6463
  */
6462
6464
  callback = /*#__PURE__*/function () {
6463
6465
  var _ref8 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(options) {
6464
- var hasFolderName, hasServiceName, hasVersionId, _model$metaData$Engin, _model, _model$metaData, _model$metaData$Engin2, _model$metaData$Engin3, _model2, _model2$metaData, _model2$metaData$Engi, _model3$metaData$Engi, _model3$metaData, _model3$metaData$Engi2, _model3$metaData$Engi3, _model3$metaData2, _model3$metaData2$Eng, _model3;
6466
+ var hasFolderName, hasServiceName, hasVersionId, _model$metaData$Engin, _model$metaData, _model$metaData$Engin2, _model$metaData$Engin3, _model$metaData2, _model$metaData2$Engi, _model$metaData$Engin4, _model$metaData3, _model$metaData3$Engi, _model$metaData$Engin5, _model$metaData4, _model$metaData4$Engi, _model;
6465
6467
  return _regenerator["default"].wrap(function _callee2$(_context2) {
6466
6468
  while (1) {
6467
6469
  switch (_context2.prev = _context2.next) {
@@ -6478,23 +6480,23 @@ var Spark = /*#__PURE__*/function () {
6478
6480
  id: hasVersionId,
6479
6481
  url: model.binary,
6480
6482
  meta: {
6481
- folder_name: (_model$metaData$Engin = (_model = model) === null || _model === void 0 ? void 0 : (_model$metaData = _model.metaData) === null || _model$metaData === void 0 ? void 0 : (_model$metaData$Engin2 = _model$metaData.EngineInformation) === null || _model$metaData$Engin2 === void 0 ? void 0 : _model$metaData$Engin2.ProductName) !== null && _model$metaData$Engin !== void 0 ? _model$metaData$Engin : "",
6482
- service_name: (_model$metaData$Engin3 = (_model2 = model) === null || _model2 === void 0 ? void 0 : (_model2$metaData = _model2.metaData) === null || _model2$metaData === void 0 ? void 0 : (_model2$metaData$Engi = _model2$metaData.EngineInformation) === null || _model2$metaData$Engi === void 0 ? void 0 : _model2$metaData$Engi.ServiceName) !== null && _model$metaData$Engin3 !== void 0 ? _model$metaData$Engin3 : ""
6483
+ folder_name: (_model$metaData$Engin = model === null || model === void 0 ? void 0 : (_model$metaData = model.metaData) === null || _model$metaData === void 0 ? void 0 : (_model$metaData$Engin2 = _model$metaData.EngineInformation) === null || _model$metaData$Engin2 === void 0 ? void 0 : _model$metaData$Engin2.ProductName) !== null && _model$metaData$Engin !== void 0 ? _model$metaData$Engin : "",
6484
+ service_name: (_model$metaData$Engin3 = model === null || model === void 0 ? void 0 : (_model$metaData2 = model.metaData) === null || _model$metaData2 === void 0 ? void 0 : (_model$metaData2$Engi = _model$metaData2.EngineInformation) === null || _model$metaData2$Engi === void 0 ? void 0 : _model$metaData2$Engi.ServiceName) !== null && _model$metaData$Engin3 !== void 0 ? _model$metaData$Engin3 : ""
6483
6485
  }
6484
6486
  });
6485
6487
  case 6:
6486
6488
  _context2.next = 12;
6487
6489
  break;
6488
6490
  case 8:
6489
- _model3 = ds._getModelByMeta(hasFolderName, hasServiceName);
6490
- hasVersionId = _model3 === null || _model3 === void 0 ? void 0 : _model3.versionId;
6491
+ _model = ds._getModelByMeta(hasFolderName, hasServiceName);
6492
+ hasVersionId = _model === null || _model === void 0 ? void 0 : _model.versionId;
6491
6493
  _context2.next = 12;
6492
6494
  return registry.append({
6493
6495
  id: hasVersionId,
6494
- url: _model3.binary,
6496
+ url: _model.binary,
6495
6497
  meta: {
6496
- folder_name: (_model3$metaData$Engi = _model3 === null || _model3 === void 0 ? void 0 : (_model3$metaData = _model3.metaData) === null || _model3$metaData === void 0 ? void 0 : (_model3$metaData$Engi2 = _model3$metaData.EngineInformation) === null || _model3$metaData$Engi2 === void 0 ? void 0 : _model3$metaData$Engi2.ProductName) !== null && _model3$metaData$Engi !== void 0 ? _model3$metaData$Engi : "",
6497
- service_name: (_model3$metaData$Engi3 = _model3 === null || _model3 === void 0 ? void 0 : (_model3$metaData2 = _model3.metaData) === null || _model3$metaData2 === void 0 ? void 0 : (_model3$metaData2$Eng = _model3$metaData2.EngineInformation) === null || _model3$metaData2$Eng === void 0 ? void 0 : _model3$metaData2$Eng.ServiceName) !== null && _model3$metaData$Engi3 !== void 0 ? _model3$metaData$Engi3 : ""
6498
+ folder_name: (_model$metaData$Engin4 = _model === null || _model === void 0 ? void 0 : (_model$metaData3 = _model.metaData) === null || _model$metaData3 === void 0 ? void 0 : (_model$metaData3$Engi = _model$metaData3.EngineInformation) === null || _model$metaData3$Engi === void 0 ? void 0 : _model$metaData3$Engi.ProductName) !== null && _model$metaData$Engin4 !== void 0 ? _model$metaData$Engin4 : "",
6499
+ service_name: (_model$metaData$Engin5 = _model === null || _model === void 0 ? void 0 : (_model$metaData4 = _model.metaData) === null || _model$metaData4 === void 0 ? void 0 : (_model$metaData4$Engi = _model$metaData4.EngineInformation) === null || _model$metaData4$Engi === void 0 ? void 0 : _model$metaData4$Engi.ServiceName) !== null && _model$metaData$Engin5 !== void 0 ? _model$metaData$Engin5 : ""
6498
6500
  }
6499
6501
  });
6500
6502
  case 12:
@@ -6513,35 +6515,35 @@ var Spark = /*#__PURE__*/function () {
6513
6515
  registry = new WasmRunner("", callback);
6514
6516
  }
6515
6517
  if (registry.isExist(modelVersionId)) {
6516
- _context3.next = 9;
6518
+ _context3.next = 10;
6517
6519
  break;
6518
6520
  }
6519
- _model4 = ds._findModel(input.request_meta);
6520
- _context3.next = 9;
6521
+ _model2 = ds._findModel(input.request_meta);
6522
+ _context3.next = 10;
6521
6523
  return registry.append({
6522
6524
  id: modelVersionId,
6523
- url: _model4.binary,
6525
+ url: _model2.binary,
6524
6526
  meta: {
6525
- folder_name: (_model4$metaData$Engi = _model4 === null || _model4 === void 0 ? void 0 : (_model4$metaData = _model4.metaData) === null || _model4$metaData === void 0 ? void 0 : (_model4$metaData$Engi2 = _model4$metaData.EngineInformation) === null || _model4$metaData$Engi2 === void 0 ? void 0 : _model4$metaData$Engi2.ProductName) !== null && _model4$metaData$Engi !== void 0 ? _model4$metaData$Engi : "",
6526
- service_name: (_model4$metaData$Engi3 = _model4 === null || _model4 === void 0 ? void 0 : (_model4$metaData2 = _model4.metaData) === null || _model4$metaData2 === void 0 ? void 0 : (_model4$metaData2$Eng = _model4$metaData2.EngineInformation) === null || _model4$metaData2$Eng === void 0 ? void 0 : _model4$metaData2$Eng.ServiceName) !== null && _model4$metaData$Engi3 !== void 0 ? _model4$metaData$Engi3 : ""
6527
+ folder_name: (_model2$metaData$Engi = _model2 === null || _model2 === void 0 ? void 0 : (_model2$metaData = _model2.metaData) === null || _model2$metaData === void 0 ? void 0 : (_model2$metaData$Engi2 = _model2$metaData.EngineInformation) === null || _model2$metaData$Engi2 === void 0 ? void 0 : _model2$metaData$Engi2.ProductName) !== null && _model2$metaData$Engi !== void 0 ? _model2$metaData$Engi : "",
6528
+ service_name: (_model2$metaData$Engi3 = _model2 === null || _model2 === void 0 ? void 0 : (_model2$metaData2 = _model2.metaData) === null || _model2$metaData2 === void 0 ? void 0 : (_model2$metaData2$Eng = _model2$metaData2.EngineInformation) === null || _model2$metaData2$Eng === void 0 ? void 0 : _model2$metaData2$Eng.ServiceName) !== null && _model2$metaData$Engi3 !== void 0 ? _model2$metaData$Engi3 : ""
6527
6529
  }
6528
6530
  });
6529
- case 9:
6530
- _context3.next = 11;
6531
+ case 10:
6532
+ _context3.next = 12;
6531
6533
  return registry.execute(input, modelVersionId, function () {});
6532
- case 11:
6534
+ case 12:
6533
6535
  result = _context3.sent;
6534
6536
  return _context3.abrupt("return", result);
6535
- case 15:
6536
- _context3.prev = 15;
6537
- _context3.t0 = _context3["catch"](3);
6537
+ case 16:
6538
+ _context3.prev = 16;
6539
+ _context3.t0 = _context3["catch"](4);
6538
6540
  return _context3.abrupt("return", _context3.t0);
6539
- case 18:
6541
+ case 19:
6540
6542
  case "end":
6541
6543
  return _context3.stop();
6542
6544
  }
6543
6545
  }
6544
- }, _callee3, null, [[3, 15]]);
6546
+ }, _callee3, null, [[4, 16]]);
6545
6547
  }));
6546
6548
  function offlineModel(_x3, _x4, _x5) {
6547
6549
  return _offlineModel.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coherentglobal/spark-execute-sdk",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "",
5
5
  "main": "src/node.js",
6
6
  "browser": "dist/browser.js",
@@ -21,7 +21,7 @@
21
21
  "author": "",
22
22
  "license": "ISC",
23
23
  "dependencies": {
24
- "@coherentglobal/wasm-runner": "^0.0.56",
24
+ "@coherentglobal/wasm-runner": "^0.0.57",
25
25
  "@types/node": "^18.7.18",
26
26
  "axios": "^0.27.2",
27
27
  "chai": "^4.3.6",
package/src/browser.js CHANGED
@@ -250,13 +250,17 @@ class Spark {
250
250
  }
251
251
 
252
252
  async offlineModel(input, versionID, ds) {
253
- const modelVersionId = input?.request_meta?.version_id || versionID
254
- if(!input?.request_meta){
255
- input.request_meta = {}
253
+ const model = ds._findModel(input.request_meta);
254
+
255
+ const modelVersionId = versionID || (model && model?.versionId);
256
+ // const modelVersionId = input?.request_meta?.version_id || versionID;
257
+ if (!input?.request_meta) {
258
+ input.request_meta = {};
256
259
  }
257
- if(versionID) {
258
- input.request_meta.version_id = modelVersionId
260
+ if (versionID) {
261
+ input.request_meta.version_id = modelVersionId;
259
262
  }
263
+
260
264
  try {
261
265
  if (!(registry instanceof WasmRunner)) {
262
266
  /**
@@ -269,6 +273,7 @@ class Spark {
269
273
  const hasFolderName = options?.folder_name;
270
274
  const hasServiceName = options?.service_name;
271
275
  let hasVersionId = options?.version_id;
276
+
272
277
  if (hasVersionId && !registry.isExist(hasVersionId)) {
273
278
  await registry.append({
274
279
  id: hasVersionId,