@coherentglobal/spark-execute-sdk 0.4.3 → 0.4.4

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 {
@@ -6412,17 +6414,18 @@ var Spark = /*#__PURE__*/function () {
6412
6414
  while (1) {
6413
6415
  switch (_context.prev = _context.next) {
6414
6416
  case 0:
6417
+ console.log("-------UOPD---");
6415
6418
  versionID = version_id || (input === null || input === void 0 ? void 0 : (_input$request_meta = input.request_meta) === null || _input$request_meta === void 0 ? void 0 : _input$request_meta.version_id) || (input === null || input === void 0 ? void 0 : (_input$request_meta2 = input.request_meta) === null || _input$request_meta2 === void 0 ? void 0 : _input$request_meta2.version_uuid);
6416
6419
  lookup = {
6417
6420
  model: this.offlineModel,
6418
6421
  onlineEndpoint: this.onlineModelEndpoint
6419
6422
  };
6420
- _context.next = 4;
6423
+ _context.next = 5;
6421
6424
  return lookup[this.priority[0]](input, versionID, this);
6422
- case 4:
6425
+ case 5:
6423
6426
  response = _context.sent;
6424
6427
  return _context.abrupt("return", response);
6425
- case 6:
6428
+ case 7:
6426
6429
  case "end":
6427
6430
  return _context.stop();
6428
6431
  }
@@ -6438,20 +6441,20 @@ var Spark = /*#__PURE__*/function () {
6438
6441
  key: "offlineModel",
6439
6442
  value: function () {
6440
6443
  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;
6444
+ var model, modelVersionId, callback, _model2$metaData$Engi, _model2$metaData, _model2$metaData$Engi2, _model2$metaData$Engi3, _model2$metaData2, _model2$metaData2$Eng, _model2, result;
6443
6445
  return _regenerator["default"].wrap(function _callee3$(_context3) {
6444
6446
  while (1) {
6445
6447
  switch (_context3.prev = _context3.next) {
6446
6448
  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;
6449
+ model = ds._findModel(input.request_meta);
6450
+ modelVersionId = versionID || model && (model === null || model === void 0 ? void 0 : model.versionId); // const modelVersionId = input?.request_meta?.version_id || versionID;
6448
6451
  if (!(input !== null && input !== void 0 && input.request_meta)) {
6449
6452
  input.request_meta = {};
6450
6453
  }
6451
6454
  if (versionID) {
6452
6455
  input.request_meta.version_id = modelVersionId;
6453
6456
  }
6454
- _context3.prev = 3;
6457
+ _context3.prev = 4;
6455
6458
  if (!(registry instanceof WasmRunner)) {
6456
6459
  /**
6457
6460
  * Options is the request data the the runner dispatch
@@ -6461,7 +6464,7 @@ var Spark = /*#__PURE__*/function () {
6461
6464
  */
6462
6465
  callback = /*#__PURE__*/function () {
6463
6466
  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;
6467
+ 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
6468
  return _regenerator["default"].wrap(function _callee2$(_context2) {
6466
6469
  while (1) {
6467
6470
  switch (_context2.prev = _context2.next) {
@@ -6478,23 +6481,23 @@ var Spark = /*#__PURE__*/function () {
6478
6481
  id: hasVersionId,
6479
6482
  url: model.binary,
6480
6483
  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 : ""
6484
+ 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 : "",
6485
+ 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
6486
  }
6484
6487
  });
6485
6488
  case 6:
6486
6489
  _context2.next = 12;
6487
6490
  break;
6488
6491
  case 8:
6489
- _model3 = ds._getModelByMeta(hasFolderName, hasServiceName);
6490
- hasVersionId = _model3 === null || _model3 === void 0 ? void 0 : _model3.versionId;
6492
+ _model = ds._getModelByMeta(hasFolderName, hasServiceName);
6493
+ hasVersionId = _model === null || _model === void 0 ? void 0 : _model.versionId;
6491
6494
  _context2.next = 12;
6492
6495
  return registry.append({
6493
6496
  id: hasVersionId,
6494
- url: _model3.binary,
6497
+ url: _model.binary,
6495
6498
  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 : ""
6499
+ 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 : "",
6500
+ 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
6501
  }
6499
6502
  });
6500
6503
  case 12:
@@ -6513,35 +6516,35 @@ var Spark = /*#__PURE__*/function () {
6513
6516
  registry = new WasmRunner("", callback);
6514
6517
  }
6515
6518
  if (registry.isExist(modelVersionId)) {
6516
- _context3.next = 9;
6519
+ _context3.next = 10;
6517
6520
  break;
6518
6521
  }
6519
- _model4 = ds._findModel(input.request_meta);
6520
- _context3.next = 9;
6522
+ _model2 = ds._findModel(input.request_meta);
6523
+ _context3.next = 10;
6521
6524
  return registry.append({
6522
6525
  id: modelVersionId,
6523
- url: _model4.binary,
6526
+ url: _model2.binary,
6524
6527
  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 : ""
6528
+ 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 : "",
6529
+ 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
6530
  }
6528
6531
  });
6529
- case 9:
6530
- _context3.next = 11;
6532
+ case 10:
6533
+ _context3.next = 12;
6531
6534
  return registry.execute(input, modelVersionId, function () {});
6532
- case 11:
6535
+ case 12:
6533
6536
  result = _context3.sent;
6534
6537
  return _context3.abrupt("return", result);
6535
- case 15:
6536
- _context3.prev = 15;
6537
- _context3.t0 = _context3["catch"](3);
6538
+ case 16:
6539
+ _context3.prev = 16;
6540
+ _context3.t0 = _context3["catch"](4);
6538
6541
  return _context3.abrupt("return", _context3.t0);
6539
- case 18:
6542
+ case 19:
6540
6543
  case "end":
6541
6544
  return _context3.stop();
6542
6545
  }
6543
6546
  }
6544
- }, _callee3, null, [[3, 15]]);
6547
+ }, _callee3, null, [[4, 16]]);
6545
6548
  }));
6546
6549
  function offlineModel(_x3, _x4, _x5) {
6547
6550
  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.4",
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
@@ -232,6 +232,7 @@ class Spark {
232
232
  * @returns {object}
233
233
  */
234
234
  async execute(input, version_id) {
235
+ console.log("-------UOPD---");
235
236
  const versionID =
236
237
  version_id ||
237
238
  input?.request_meta?.version_id ||
@@ -250,13 +251,17 @@ class Spark {
250
251
  }
251
252
 
252
253
  async offlineModel(input, versionID, ds) {
253
- const modelVersionId = input?.request_meta?.version_id || versionID
254
- if(!input?.request_meta){
255
- input.request_meta = {}
254
+ const model = ds._findModel(input.request_meta);
255
+
256
+ const modelVersionId = versionID || (model && model?.versionId);
257
+ // const modelVersionId = input?.request_meta?.version_id || versionID;
258
+ if (!input?.request_meta) {
259
+ input.request_meta = {};
256
260
  }
257
- if(versionID) {
258
- input.request_meta.version_id = modelVersionId
261
+ if (versionID) {
262
+ input.request_meta.version_id = modelVersionId;
259
263
  }
264
+
260
265
  try {
261
266
  if (!(registry instanceof WasmRunner)) {
262
267
  /**
@@ -269,6 +274,7 @@ class Spark {
269
274
  const hasFolderName = options?.folder_name;
270
275
  const hasServiceName = options?.service_name;
271
276
  let hasVersionId = options?.version_id;
277
+
272
278
  if (hasVersionId && !registry.isExist(hasVersionId)) {
273
279
  await registry.append({
274
280
  id: hasVersionId,