orca-sdk 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- orca_sdk/__init__.py +1 -1
- orca_sdk/_utils/auth.py +12 -8
- orca_sdk/async_client.py +3942 -0
- orca_sdk/classification_model.py +218 -20
- orca_sdk/classification_model_test.py +96 -28
- orca_sdk/client.py +899 -712
- orca_sdk/conftest.py +37 -36
- orca_sdk/credentials.py +54 -14
- orca_sdk/credentials_test.py +92 -28
- orca_sdk/datasource.py +64 -12
- orca_sdk/datasource_test.py +144 -18
- orca_sdk/embedding_model.py +54 -37
- orca_sdk/embedding_model_test.py +27 -20
- orca_sdk/job.py +27 -21
- orca_sdk/memoryset.py +823 -205
- orca_sdk/memoryset_test.py +315 -33
- orca_sdk/regression_model.py +59 -15
- orca_sdk/regression_model_test.py +35 -26
- orca_sdk/telemetry.py +76 -26
- {orca_sdk-0.1.2.dist-info → orca_sdk-0.1.4.dist-info}/METADATA +1 -1
- orca_sdk-0.1.4.dist-info/RECORD +41 -0
- orca_sdk-0.1.2.dist-info/RECORD +0 -40
- {orca_sdk-0.1.2.dist-info → orca_sdk-0.1.4.dist-info}/WHEEL +0 -0
orca_sdk/job.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing import Callable, Generic, TypedDict, TypeVar, cast
|
|
|
7
7
|
|
|
8
8
|
from tqdm.auto import tqdm
|
|
9
9
|
|
|
10
|
-
from .client import
|
|
10
|
+
from .client import OrcaClient
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class JobConfig(TypedDict):
|
|
@@ -17,7 +17,7 @@ class JobConfig(TypedDict):
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class Status(Enum):
|
|
20
|
-
"""Status of a cloud job in the
|
|
20
|
+
"""Status of a cloud job in the job queue"""
|
|
21
21
|
|
|
22
22
|
# the INITIALIZED state should never be returned by the API
|
|
23
23
|
INITIALIZED = "INITIALIZED"
|
|
@@ -140,8 +140,9 @@ class Job(Generic[TResult]):
|
|
|
140
140
|
Returns:
|
|
141
141
|
List of jobs matching the given filters
|
|
142
142
|
"""
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
client = OrcaClient._resolve_client()
|
|
144
|
+
paginated_jobs = client.GET(
|
|
145
|
+
"/job",
|
|
145
146
|
params={
|
|
146
147
|
"status": (
|
|
147
148
|
[s.value for s in status]
|
|
@@ -174,7 +175,7 @@ class Job(Generic[TResult]):
|
|
|
174
175
|
obj,
|
|
175
176
|
)[-1]
|
|
176
177
|
)(t)
|
|
177
|
-
for t in
|
|
178
|
+
for t in paginated_jobs["items"]
|
|
178
179
|
]
|
|
179
180
|
|
|
180
181
|
def __init__(self, id: str, get_value: Callable[[], TResult | None] | None = None):
|
|
@@ -186,27 +187,30 @@ class Job(Generic[TResult]):
|
|
|
186
187
|
get_value: Optional function to customize how the value is resolved, if not provided the result will be a dict
|
|
187
188
|
"""
|
|
188
189
|
self.id = id
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
self.
|
|
197
|
-
self.
|
|
198
|
-
self.
|
|
190
|
+
client = OrcaClient._resolve_client()
|
|
191
|
+
job = client.GET("/job/{job_id}", params={"job_id": id})
|
|
192
|
+
|
|
193
|
+
def default_get_value():
|
|
194
|
+
client = OrcaClient._resolve_client()
|
|
195
|
+
return cast(TResult | None, client.GET("/job/{job_id}", params={"job_id": id})["result"])
|
|
196
|
+
|
|
197
|
+
self._get_value = get_value or default_get_value
|
|
198
|
+
self.type = job["type"]
|
|
199
|
+
self.status = Status(job["status"])
|
|
200
|
+
self.steps_total = job["steps_total"]
|
|
201
|
+
self.steps_completed = job["steps_completed"]
|
|
202
|
+
self.exception = job["exception"]
|
|
199
203
|
self.value = (
|
|
200
204
|
None
|
|
201
|
-
if
|
|
205
|
+
if job["status"] != "COMPLETED"
|
|
202
206
|
else (
|
|
203
207
|
get_value()
|
|
204
208
|
if get_value is not None
|
|
205
|
-
else cast(TResult,
|
|
209
|
+
else cast(TResult, job["result"]) if job["result"] is not None else None
|
|
206
210
|
)
|
|
207
211
|
)
|
|
208
|
-
self.updated_at = datetime.fromisoformat(
|
|
209
|
-
self.created_at = datetime.fromisoformat(
|
|
212
|
+
self.updated_at = datetime.fromisoformat(job["updated_at"])
|
|
213
|
+
self.created_at = datetime.fromisoformat(job["created_at"])
|
|
210
214
|
self.refreshed_at = datetime.now()
|
|
211
215
|
|
|
212
216
|
def refresh(self, throttle: float = 0):
|
|
@@ -222,7 +226,8 @@ class Job(Generic[TResult]):
|
|
|
222
226
|
return
|
|
223
227
|
self.refreshed_at = current_time
|
|
224
228
|
|
|
225
|
-
|
|
229
|
+
client = OrcaClient._resolve_client()
|
|
230
|
+
status_info = client.GET("/job/{job_id}/status", params={"job_id": self.id})
|
|
226
231
|
self.status = Status(status_info["status"])
|
|
227
232
|
if status_info["steps_total"] is not None:
|
|
228
233
|
self.steps_total = status_info["steps_total"]
|
|
@@ -333,5 +338,6 @@ def abort(self, show_progress: bool = False, refresh_interval: int = 1, max_wait
|
|
|
333
338
|
refresh_interval: Polling interval in seconds while waiting for the job to abort
|
|
334
339
|
max_wait: Maximum time to wait for the job to abort in seconds
|
|
335
340
|
"""
|
|
336
|
-
|
|
341
|
+
client = OrcaClient._resolve_client()
|
|
342
|
+
client.DELETE("/job/{job_id}/abort", params={"job_id": self.id})
|
|
337
343
|
self.wait(show_progress, refresh_interval, max_wait)
|