unitypredict 1.1.43__tar.gz → 1.1.45__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.43
3
+ Version: 1.1.45
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
 
@@ -47,6 +47,7 @@ class UnityPredictResponse:
47
47
  class UnityPredictClient:
48
48
  ApiKey: str = ''
49
49
  ApiBaseUrl: str = 'https://api.prod.unitypredict.com/api'
50
+ ApiBaseUrl: str = "https://api.dev.unitypredict.net/api"
50
51
  ApiMaxTimeout: int = 12 * 60 * 60
51
52
 
52
53
  # Async Variables
@@ -183,6 +184,7 @@ class UnityPredictClient:
183
184
 
184
185
 
185
186
  try:
187
+ results.Status = finalResponseJson.get('status')
186
188
  results.ComputeCost = finalResponseJson.get('computeCost')
187
189
  results.OutcomeValues = outcomeValues
188
190
  results.Outcomes = outcomes
@@ -268,61 +270,69 @@ class UnityPredictClient:
268
270
 
269
271
  results, finalResponseJson = self._uploadFileAndStartPredict(modelId=modelId, request=request)
270
272
 
271
- self._asyncResult = results
272
- self._asyncResponseJson = finalResponseJson
273
+ results.Status = finalResponseJson.get("status", None)
274
+
275
+ if (results.Status == None):
276
+
277
+ return results
278
+
279
+ if (results.Status != "Processing"):
280
+
281
+ results = self._processPredictedInference(responseJson=finalResponseJson, outputFolderPath=request.OutputFolderPath)
282
+
283
+ else:
284
+ results.Status = finalResponseJson.get('status')
285
+ results.RequestId = finalResponseJson.get('requestId')
286
+ results.ErrorMessages = finalResponseJson.get('errorMessages')
287
+
288
+ return results
273
289
 
274
290
  except Exception as e:
275
291
 
276
- self._asyncResult.ErrorMessages = f"Predict Exception Occured: {e}"
292
+ results = UnityPredictResponse()
293
+ results.ErrorMessages = f"Predict Exception Occured: {e}"
294
+
295
+ return results
277
296
 
278
297
 
279
- def AsyncInference(self, outputFolderPath: str = ""):
280
-
281
- self._asyncResult.Status = self._asyncResponseJson.get("status", None)
282
- statusUrl = self._asyncResponseJson.get('statusUrl', None)
298
+ def GetRequestStatus(self, requestId: str, outputFolderPath: str = ""):
283
299
 
284
300
  apiKey = self.ApiKey
285
-
286
- inferStatus = self._asyncResult.Status
287
- if inferStatus == 'Processing':
301
+ apiBaseUrl = self.ApiBaseUrl
302
+ statusUrl: str = "{}/predict/status/{}".format(apiBaseUrl, requestId)
288
303
 
289
- if statusUrl == None:
290
- self._asyncResult.Status = None
291
- return self._asyncResult
304
+ results: UnityPredictResponse = UnityPredictResponse()
292
305
 
293
- response = requests.get(url = statusUrl, headers={"Authorization": "Bearer {}".format(apiKey)})
294
- finalResponseJson = response.json()
306
+ response = requests.get(url = statusUrl, headers={"Authorization": "Bearer {}".format(apiKey)})
307
+ if response.status_code != 200:
308
+ results.RequestId = requestId
309
+ results.ErrorMessages = 'Error from server: {}'.format(response.status_code)
310
+ return results
311
+
312
+ finalResponseJson = response.json()
295
313
 
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
314
+ inferStatus = finalResponseJson.get('status', None)
315
+ results.Status = inferStatus
304
316
 
305
- elif inferStatus == None:
306
- return self._asyncResult
317
+ if (inferStatus == None):
318
+ results.RequestId = requestId
319
+ return results
307
320
 
308
- else:
309
- finalResponseJson = self._asyncResponseJson
321
+ if (inferStatus == 'Processing'):
322
+ results.RequestId = requestId
323
+ return results
310
324
 
311
325
 
312
326
  # Once the processing is done
313
327
 
314
328
  try:
315
- self._asyncResult = self._processPredictedInference(responseJson=finalResponseJson, outputFolderPath=outputFolderPath)
316
- self._asyncResult.Status = inferStatus
329
+ results = self._processPredictedInference(responseJson=finalResponseJson, outputFolderPath=outputFolderPath)
317
330
  except Exception as e:
318
- self._asyncResult = UnityPredictResponse()
319
- self._asyncResult.ErrorMessages = f"Exception Occured while processing Inference: {e}"
331
+ results = UnityPredictResponse()
332
+ results.RequestId = requestId
333
+ results.ErrorMessages = f"Exception Occured while processing Inference: {e}"
320
334
 
321
- return self._asyncResult
322
-
323
- def AsyncResponse(self):
324
-
325
- return self._asyncResponseJson
335
+ return results
326
336
 
327
337
 
328
338
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unitypredict
3
- Version: 1.1.43
3
+ Version: 1.1.45
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