unitypredict 1.1.47__tar.gz → 1.1.48__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.47
3
+ Version: 1.1.48
4
4
  Summary:
5
5
  Home-page: https://unitypredict.com
6
6
  Author: UnityPredict
@@ -7,6 +7,15 @@ import time
7
7
  import requests
8
8
 
9
9
  class UnityPredictFileTransmitDto:
10
+
11
+ """
12
+ Represents a file to be transmitted to the UnityPredict API.
13
+
14
+ Attributes:
15
+ FileName (str): The name of the file.
16
+ FileHandle (IOBase): The IOBase is a byte stream representation for the file content. This is commonly created by using the python io library's 'open' function.
17
+ """
18
+
10
19
  FileName: str = ''
11
20
  FileHandle: IOBase = None
12
21
 
@@ -15,6 +24,15 @@ class UnityPredictFileTransmitDto:
15
24
  self.FileHandle = fileHandle
16
25
 
17
26
  class UnityPredictFileReceivedDto:
27
+
28
+ """
29
+ Represents a file received from the UnityPredict API.
30
+
31
+ Attributes:
32
+ FileName (str): The name of the file.
33
+ LocalFilePath (str): The local path where the file was saved.
34
+ """
35
+
18
36
  FileName: str = ''
19
37
  LocalFilePath: str = ''
20
38
 
@@ -23,6 +41,17 @@ class UnityPredictFileReceivedDto:
23
41
  self.LocalFilePath = localFilePath
24
42
 
25
43
  class UnityPredictRequest:
44
+
45
+ """
46
+ Represents a UnityPredict request.
47
+
48
+ Attributes:
49
+ ContextId (str): An optional context ID for the request.
50
+ InputValues (dict): A dictionary of input values for the model, where the key is the input variable name and the value of the variable's value.
51
+ DesiredOutcomes (list): A list of desired output variable names.
52
+ OutputFolderPath (str): The target path for saving model's output files (this is optional/not used if the model doesn't produce any output files).
53
+ """
54
+
26
55
  ContextId: str = ''
27
56
  InputValues: dict
28
57
  DesiredOutcomes: list
@@ -36,6 +65,19 @@ class UnityPredictRequest:
36
65
 
37
66
 
38
67
  class UnityPredictResponse:
68
+
69
+ """
70
+ Represents a response from the UnityPredict API.
71
+
72
+ Attributes:
73
+ ContextId (str): The ID of the request context.
74
+ RequestId (str): The ID of the request.
75
+ ErrorMessages (str): Error messages, if any.
76
+ ComputeCost (float): The estimated compute cost of the request.
77
+ Outcomes (dict): A dictionary containing the processed output values, including file details if applicable.
78
+ Status (str|None): The current status of the request (e.g., "Processing", "Completed", "Error" or None).
79
+ """
80
+
39
81
  ContextId: str = ''
40
82
  RequestId: str = ''
41
83
  ErrorMessages: str = ''
@@ -45,18 +87,31 @@ class UnityPredictResponse:
45
87
  Status: str|None = None
46
88
 
47
89
  class UnityPredictClient:
90
+
91
+ """
92
+ A client class for interacting with the UnityPredict API.
93
+
94
+ Attributes:
95
+ ApiKey (str): The API key for authentication.
96
+ ApiBaseUrl (str): The base URL of the UnityPredict API.
97
+ ApiMaxTimeout (int): The maximum wait time (in seconds) for synchronous responses.
98
+ """
99
+
48
100
  ApiKey: str = ''
49
101
  ApiBaseUrl: str = 'https://api.prod.unitypredict.com/api'
50
102
  ApiMaxTimeout: int = 12 * 60 * 60
51
103
 
52
- # Async Variables
53
- _asyncResult: UnityPredictResponse = None
54
- _asyncResponseJson: any = {}
55
-
56
104
  def __init__(self, apiKey, apiMaxTimeoutInSec = 12 * 60 * 60):
105
+
106
+ """
107
+ Initializes a UnityPredictClient instance.
108
+
109
+ Args:
110
+ apiKey (str): The UnityPredict API key for authentication.
111
+ apiMaxTimeoutInSec (int, optional): The maximum wait time (in seconds) for synchronous responses. Defaults to 12 hours.
112
+ """
57
113
  self.ApiKey = f"APIKEY@{apiKey}"
58
114
  self.ApiMaxTimeout = apiMaxTimeoutInSec
59
- self._asyncResult = UnityPredictResponse()
60
115
 
61
116
 
62
117
 
@@ -198,6 +253,18 @@ class UnityPredictClient:
198
253
 
199
254
 
200
255
  def Predict(self, modelId: str, request: UnityPredictRequest) -> UnityPredictResponse:
256
+
257
+ """
258
+ Sends a synchronous prediction request to the UnityPredict API.
259
+
260
+ Args:
261
+ modelId (str): The ID of the model to use for prediction.
262
+ request (UnityPredictRequest): The prediction request object, containing input values, desired outcomes, and output folder path.
263
+
264
+ Returns:
265
+ UnityPredictResponse: The response from the UnityPredict API, containing the results and status.
266
+ """
267
+
201
268
  results = UnityPredictResponse()
202
269
 
203
270
  apiKey = self.ApiKey
@@ -258,12 +325,18 @@ class UnityPredictClient:
258
325
 
259
326
  return results
260
327
 
261
- def AsyncPredict(self, modelId: str, request: UnityPredictRequest):
328
+ def AsyncPredict(self, modelId: str, request: UnityPredictRequest) -> UnityPredictResponse:
262
329
 
263
- #####
264
- # The request can contain file objects so we need to change those to file names before sending out
265
- #####
266
- # first get a list of file that we'll need to upload later & update the POST obj
330
+ """
331
+ Initiates an asynchronous inference for the specified model. The function will return the response with a RequestId and Status = 'Processing'. Use the 'GetRequestStatus' function with the returned RequestId to check on the status of the run and retrieve the results.
332
+
333
+ Args:
334
+ modelId (str): The Model Id of the specific model you want to invoke.
335
+ request (UnityPredictRequest): The inference request of type UnityPredictRequest, containing input values, desired outputs variables, and an (optional) OutputFolderPath for use with models that generate output files.
336
+
337
+ Returns:
338
+ UnityPredictResponse: The initial response from the API, containing the request ID and status.
339
+ """
267
340
 
268
341
  try:
269
342
 
@@ -294,7 +367,19 @@ class UnityPredictClient:
294
367
  return results
295
368
 
296
369
 
297
- def GetRequestStatus(self, requestId: str, outputFolderPath: str = ""):
370
+ def GetRequestStatus(self, requestId: str, outputFolderPath: str = "") -> UnityPredictResponse:
371
+
372
+
373
+ """
374
+ Retrieves the status of an asynchronous prediction request.
375
+
376
+ Args:
377
+ requestId (str): The ID of the asynchronous request.
378
+ outputFolderPath (str, optional): The output folder path for saving results. Defaults to an empty string.
379
+
380
+ Returns:
381
+ UnityPredictResponse: The updated response with the current status and results, if available.
382
+ """
298
383
 
299
384
  apiKey = self.ApiKey
300
385
  apiBaseUrl = self.ApiBaseUrl
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unitypredict
3
- Version: 1.1.47
3
+ Version: 1.1.48
4
4
  Summary:
5
5
  Home-page: https://unitypredict.com
6
6
  Author: UnityPredict
File without changes
File without changes
File without changes