unitypredict 1.1.44__tar.gz → 1.1.46__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unitypredict
3
- Version: 1.1.44
3
+ Version: 1.1.46
4
4
  Summary:
5
5
  Home-page: https://unitypredict.com
6
6
  Author: UnityPredict
@@ -19,7 +19,7 @@ pip install unitypredict
19
19
 
20
20
  ## Usage
21
21
 
22
- TFor detailed instructions on how to use the SDK, please refer to [Unitypredict API SDK](https://docs.unitypredict.com/sdk).
22
+ TFor detailed instructions on how to use the SDK, please refer to [UnityPredict API Documentation](https://docs.unitypredict.com/sdk).
23
23
 
24
24
 
25
25
 
@@ -9,7 +9,7 @@ pip install unitypredict
9
9
 
10
10
  ## Usage
11
11
 
12
- TFor detailed instructions on how to use the SDK, please refer to [Unitypredict API SDK](https://docs.unitypredict.com/sdk).
12
+ TFor detailed instructions on how to use the SDK, please refer to [UnityPredict API Documentation](https://docs.unitypredict.com/sdk).
13
13
 
14
14
 
15
15
 
@@ -183,6 +183,7 @@ class UnityPredictClient:
183
183
 
184
184
 
185
185
  try:
186
+ results.Status = finalResponseJson.get('status')
186
187
  results.ComputeCost = finalResponseJson.get('computeCost')
187
188
  results.OutcomeValues = outcomeValues
188
189
  results.Outcomes = outcomes
@@ -268,61 +269,69 @@ class UnityPredictClient:
268
269
 
269
270
  results, finalResponseJson = self._uploadFileAndStartPredict(modelId=modelId, request=request)
270
271
 
271
- self._asyncResult = results
272
- self._asyncResponseJson = finalResponseJson
272
+ results.Status = finalResponseJson.get("status", None)
273
+
274
+ if (results.Status == None):
275
+
276
+ return results
277
+
278
+ if (results.Status != "Processing"):
279
+
280
+ results = self._processPredictedInference(responseJson=finalResponseJson, outputFolderPath=request.OutputFolderPath)
281
+
282
+ else:
283
+ results.Status = finalResponseJson.get('status')
284
+ results.RequestId = finalResponseJson.get('requestId')
285
+ results.ErrorMessages = finalResponseJson.get('errorMessages')
286
+
287
+ return results
273
288
 
274
289
  except Exception as e:
275
290
 
276
- self._asyncResult.ErrorMessages = f"Predict Exception Occured: {e}"
291
+ results = UnityPredictResponse()
292
+ results.ErrorMessages = f"Predict Exception Occured: {e}"
293
+
294
+ return results
277
295
 
278
296
 
279
- def AsyncInference(self, outputFolderPath: str = ""):
280
-
281
- self._asyncResult.Status = self._asyncResponseJson.get("status", None)
282
- statusUrl = self._asyncResponseJson.get('statusUrl', None)
297
+ def GetRequestStatus(self, requestId: str, outputFolderPath: str = ""):
283
298
 
284
299
  apiKey = self.ApiKey
285
-
286
- inferStatus = self._asyncResult.Status
287
- if inferStatus == 'Processing':
300
+ apiBaseUrl = self.ApiBaseUrl
301
+ statusUrl: str = "{}/predict/status/{}".format(apiBaseUrl, requestId)
288
302
 
289
- if statusUrl == None:
290
- self._asyncResult.Status = None
291
- return self._asyncResult
303
+ results: UnityPredictResponse = UnityPredictResponse()
292
304
 
293
- response = requests.get(url = statusUrl, headers={"Authorization": "Bearer {}".format(apiKey)})
294
- finalResponseJson = response.json()
305
+ response = requests.get(url = statusUrl, headers={"Authorization": "Bearer {}".format(apiKey)})
306
+ if response.status_code != 200:
307
+ results.RequestId = requestId
308
+ results.ErrorMessages = 'Error from server: {}'.format(response.status_code)
309
+ return results
310
+
311
+ finalResponseJson = response.json()
295
312
 
296
- inferStatus = finalResponseJson.get('status', None)
297
- self._asyncResult.Status = inferStatus
298
-
299
- if (inferStatus == None):
300
- return self._asyncResult
301
-
302
- if (inferStatus == 'Processing'):
303
- return self._asyncResult
313
+ inferStatus = finalResponseJson.get('status', None)
314
+ results.Status = inferStatus
304
315
 
305
- elif inferStatus == None:
306
- return self._asyncResult
316
+ if (inferStatus == None):
317
+ results.RequestId = requestId
318
+ return results
307
319
 
308
- else:
309
- finalResponseJson = self._asyncResponseJson
320
+ if (inferStatus == 'Processing'):
321
+ results.RequestId = requestId
322
+ return results
310
323
 
311
324
 
312
325
  # Once the processing is done
313
326
 
314
327
  try:
315
- self._asyncResult = self._processPredictedInference(responseJson=finalResponseJson, outputFolderPath=outputFolderPath)
316
- self._asyncResult.Status = inferStatus
328
+ results = self._processPredictedInference(responseJson=finalResponseJson, outputFolderPath=outputFolderPath)
317
329
  except Exception as e:
318
- self._asyncResult = UnityPredictResponse()
319
- self._asyncResult.ErrorMessages = f"Exception Occured while processing Inference: {e}"
330
+ results = UnityPredictResponse()
331
+ results.RequestId = requestId
332
+ results.ErrorMessages = f"Exception Occured while processing Inference: {e}"
320
333
 
321
- return self._asyncResult
322
-
323
- def AsyncResponse(self):
324
-
325
- return self._asyncResponseJson
334
+ return results
326
335
 
327
336
 
328
337
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unitypredict
3
- Version: 1.1.44
3
+ Version: 1.1.46
4
4
  Summary:
5
5
  Home-page: https://unitypredict.com
6
6
  Author: UnityPredict
@@ -19,7 +19,7 @@ pip install unitypredict
19
19
 
20
20
  ## Usage
21
21
 
22
- TFor detailed instructions on how to use the SDK, please refer to [Unitypredict API SDK](https://docs.unitypredict.com/sdk).
22
+ TFor detailed instructions on how to use the SDK, please refer to [UnityPredict API Documentation](https://docs.unitypredict.com/sdk).
23
23
 
24
24
 
25
25
 
File without changes
File without changes