wherobots-python-sdk 0.7.0__tar.gz → 0.8.0__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.
- {wherobots_python_sdk-0.7.0/wherobots_python_sdk.egg-info → wherobots_python_sdk-0.8.0}/PKG-INFO +62 -61
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/README.md +61 -60
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/pyproject.toml +10 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_api.py +72 -42
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_base_client.py +91 -160
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_client.py +241 -75
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_config.py +2 -2
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_enums.py +3 -2
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_files_api.py +46 -54
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_files_drive.py +62 -59
- wherobots_python_sdk-0.8.0/tests/test_live_contract.py +64 -0
- wherobots_python_sdk-0.8.0/tests/test_models.py +271 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_regressions.py +12 -75
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_security.py +48 -129
- wherobots_python_sdk-0.8.0/tests/test_spec_contract.py +80 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_tasks.py +31 -24
- wherobots_python_sdk-0.8.0/tests/test_wire.py +149 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/__version__.py +1 -1
- wherobots_python_sdk-0.8.0/wherobots/_wire.py +212 -0
- wherobots_python_sdk-0.8.0/wherobots/api/_operations.py +317 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/api/base.py +49 -79
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/api/drive.py +59 -53
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/api/files.py +17 -37
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/api/runs.py +55 -93
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/api/tasks.py +27 -48
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/client.py +157 -168
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/config.py +13 -12
- wherobots_python_sdk-0.8.0/wherobots/enums/__init__.py +43 -0
- wherobots_python_sdk-0.8.0/wherobots/enums/_generated.py +154 -0
- wherobots_python_sdk-0.8.0/wherobots/enums/_handwritten.py +103 -0
- wherobots_python_sdk-0.8.0/wherobots/models/__init__.py +106 -0
- wherobots_python_sdk-0.8.0/wherobots/models/_generated.py +790 -0
- wherobots_python_sdk-0.8.0/wherobots/models/_handwritten.py +355 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0/wherobots_python_sdk.egg-info}/PKG-INFO +62 -61
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots_python_sdk.egg-info/SOURCES.txt +11 -2
- wherobots_python_sdk-0.7.0/tests/test_models.py +0 -1043
- wherobots_python_sdk-0.7.0/wherobots/enums.py +0 -183
- wherobots_python_sdk-0.7.0/wherobots/models.py +0 -1820
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/LICENSE +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/setup.cfg +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_client_header.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_exceptions.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_init_exports.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_integration.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_logger.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_utils.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/tests/test_workload_auth.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/__init__.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/api/__init__.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/api/workload_auth.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/exceptions.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/py.typed +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/sdk.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/utils/__init__.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/utils/client_header.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/utils/logger.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots/utils/validation.py +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots_python_sdk.egg-info/dependency_links.txt +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots_python_sdk.egg-info/requires.txt +0 -0
- {wherobots_python_sdk-0.7.0 → wherobots_python_sdk-0.8.0}/wherobots_python_sdk.egg-info/top_level.txt +0 -0
{wherobots_python_sdk-0.7.0/wherobots_python_sdk.egg-info → wherobots_python_sdk-0.8.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wherobots-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Python SDK for Wherobots (currently covers the Jobs REST API)
|
|
5
5
|
Author-email: Wherobots <support@wherobots.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -39,7 +39,7 @@ Additional Wherobots surfaces will be added over time.
|
|
|
39
39
|
## Features
|
|
40
40
|
|
|
41
41
|
- Submit Python scripts or JARs as Wherobots jobs
|
|
42
|
-
- Auto-upload local scripts
|
|
42
|
+
- Auto-upload local scripts to Wherobots managed storage (only needs an API key)
|
|
43
43
|
- Stream or iterate logs with pagination
|
|
44
44
|
- List runs with status, name, and date filters
|
|
45
45
|
- Typed dataclass models for all API responses (no pydantic dependency)
|
|
@@ -61,7 +61,7 @@ The simplest way to run a local script — only an API key is needed:
|
|
|
61
61
|
from wherobots import WherobotsJob
|
|
62
62
|
|
|
63
63
|
job = WherobotsJob(
|
|
64
|
-
script="my_analysis.py", # local file — auto-uploaded
|
|
64
|
+
script="my_analysis.py", # local file — auto-uploaded to managed storage
|
|
65
65
|
name="analysis-job-001",
|
|
66
66
|
runtime="tiny",
|
|
67
67
|
region="aws-us-west-2",
|
|
@@ -88,8 +88,7 @@ job = WherobotsJob(
|
|
|
88
88
|
### Script Upload Behavior
|
|
89
89
|
|
|
90
90
|
When `script` is a local file path (not an `s3://` URI) and `auto_upload=True`
|
|
91
|
-
(the default), the SDK uploads your script
|
|
92
|
-
managed storage. Only needs a valid API key — no AWS credentials required.
|
|
91
|
+
(the default), the SDK uploads your script to Wherobots managed storage. Only needs a valid API key — no AWS credentials required.
|
|
93
92
|
|
|
94
93
|
You can also reference scripts already in a
|
|
95
94
|
[Storage Integration](https://docs.wherobots.com/latest/develop/storage-management/storage/)
|
|
@@ -135,7 +134,7 @@ job = WherobotsJob(script="s3://bucket/script.py", name="my-job-001")
|
|
|
135
134
|
| `WHEROBOTS_API_KEY` | API key | *(required outside Wherobots)* |
|
|
136
135
|
| `WHEROBOTS_REGION` | Region override (else org default) | *(none — org default)* |
|
|
137
136
|
| `WHEROBOTS_API_BASE_URL` | API base URL | `https://api.cloud.wherobots.com` |
|
|
138
|
-
| `WHEROBOTS_VERSION` |
|
|
137
|
+
| `WHEROBOTS_VERSION` | Runtime version | *(none, the org preset decides)* |
|
|
139
138
|
| `WHEROBOTS_REQUEST_TIMEOUT_SECONDS`| HTTP request timeout (seconds) | `30` |
|
|
140
139
|
| `WHEROBOTS_CLIENT_CHAIN` | Upstream client-attribution chain (see below) | *(none)* |
|
|
141
140
|
| `WHEROBOTS_ID_TOKEN_PATH` | Workload identity token, set by Wherobots notebooks and jobs | *(none)* |
|
|
@@ -166,7 +165,7 @@ config = WherobotsConfig(
|
|
|
166
165
|
| `api_key` | `str \| None` | `None` (read from env) |
|
|
167
166
|
| `region` | `str \| None` | `None` |
|
|
168
167
|
| `base_url` | `str` | `"https://api.cloud.wherobots.com"` |
|
|
169
|
-
| `version` | `str`
|
|
168
|
+
| `version` | `str \| None` | `None` (org preset) |
|
|
170
169
|
| `request_timeout_seconds` | `int` | `30` |
|
|
171
170
|
| `client_chain` | `str \| None` | `None` |
|
|
172
171
|
|
|
@@ -213,11 +212,11 @@ WherobotsJob(
|
|
|
213
212
|
runtime: str | Runtime | None = None, # Compute size (None -> org default)
|
|
214
213
|
region: str | Region | None = None, # Region; str passed as-is (None -> org default)
|
|
215
214
|
api_key: str | None = None, # API key (or env var)
|
|
216
|
-
version: str | None = None, # "latest" | "preview"
|
|
215
|
+
version: str | None = None, # "latest" | "preview" (None -> org preset)
|
|
217
216
|
timeout_seconds: int = 3600, # Job timeout
|
|
218
217
|
args: list[str] | None = None, # Script arguments
|
|
219
218
|
spark_configs: dict[str, str] | None = None, # Spark config overrides
|
|
220
|
-
dependencies: list[
|
|
219
|
+
dependencies: list[PyPiDependency | FileDependency] | None = None,
|
|
221
220
|
spark_driver_disk_gb: int | None = None, # Driver disk size (GB)
|
|
222
221
|
spark_executor_disk_gb: int | None = None, # Executor disk size (GB)
|
|
223
222
|
jar_main_class: str | None = None, # Main class (required for JARs)
|
|
@@ -235,14 +234,14 @@ WherobotsJob(
|
|
|
235
234
|
|--------|---------|-------------|
|
|
236
235
|
| `submit()` | `str` | Submit the job. Returns the run ID. Idempotent (returns existing ID if already submitted). |
|
|
237
236
|
| `get_status()` | `RunView` | Get current job status and full details. |
|
|
238
|
-
| `get_logs(cursor=
|
|
237
|
+
| `get_logs(cursor=None, size=100)` | `LogsResponse` | Fetch a page of log entries. The cursor is an opaque string from `next_page`. |
|
|
239
238
|
| `get_metrics()` | `RunMetricsResponse` | Fetch CPU/memory metrics for the run. |
|
|
240
239
|
| `get_cpu_utilization()` | `UtilizationStats` | Aggregated CPU utilization (`latest`, `max`, `avg`, `series`). |
|
|
241
240
|
| `get_mem_utilization()` | `UtilizationStats` | Aggregated memory utilization (`latest`, `max`, `avg`, `series`). |
|
|
242
241
|
| `get_cost()` | `float \| None` | Total run cost in USD, or `None` if not yet billed. |
|
|
243
242
|
| `get_consumed_spatial_units()` | `float \| None` | Spatial Units (SUs) consumed by the run. |
|
|
244
243
|
| `refresh()` | `RunView` | Re-fetch from the API and update `status`/`name`/`runtime`/`region`/`version` in place. |
|
|
245
|
-
| `iter_logs(cursor=
|
|
244
|
+
| `iter_logs(cursor=None, size=100)` | `Iterator[dict]` | Iterate over all log entries, handling pagination automatically. |
|
|
246
245
|
| `poll_for_logs(follow=True, interval=2.0, log_handler=None, max_errors=10)` | `None` | Poll and print logs. If `follow=True`, continues until job completes. `max_errors` sets the max consecutive transient errors before giving up. |
|
|
247
246
|
| `cancel()` | `bool` | Request cancellation. Returns `True` on success. |
|
|
248
247
|
| `wait_for_completion(poll_interval=5.0, stream_logs=True, log_interval=2.0, max_wait_seconds=None)` | `JobStatus` | Block until the job reaches a terminal state. Set `max_wait_seconds` to limit wait time (raises `WherobotsTimeoutError`). |
|
|
@@ -269,8 +268,8 @@ with WherobotsJob(script="s3://bucket/script.py", name="my-job") as job:
|
|
|
269
268
|
|--------|---------|-------------|
|
|
270
269
|
| `from_run_id(run_id, api_key=None, ...)` | `WherobotsJob` | Attach to an existing run for read-only log/metric access. No script required. `submit()` is disabled on the returned instance. |
|
|
271
270
|
| `list_runs(...)` | `RunListPage` | List runs with optional filters. No instance required. |
|
|
272
|
-
| `add_pypi_dependency(
|
|
273
|
-
| `add_file_dependency(file_path)` | `
|
|
271
|
+
| `add_pypi_dependency(library_name, library_version=None)` | `PyPiDependency` | Create a PyPI dependency for the `dependencies` parameter. |
|
|
272
|
+
| `add_file_dependency(file_path)` | `FileDependency` | Create a file dependency (`.jar`, `.whl`, `.zip`, `.json`). Accepts an `s3://` URI or a local path — local paths are auto-uploaded to **managed storage** at `submit()` time. For non-managed destinations, upload via `FilesAPI` first and pass the resulting `s3://` URI. |
|
|
274
273
|
|
|
275
274
|
#### Attaching to an Existing Run
|
|
276
275
|
|
|
@@ -598,77 +597,79 @@ job = WherobotsJob(
|
|
|
598
597
|
|
|
599
598
|
## Models
|
|
600
599
|
|
|
601
|
-
|
|
602
|
-
for JSON
|
|
600
|
+
Models are generated from the Wherobots OpenAPI spec. They are frozen dataclasses built with
|
|
601
|
+
keyword arguments, with `from_dict()` and `to_dict()` for the API's JSON. A missing required field
|
|
602
|
+
or a wrong type raises `WherobotsAPIError`. Unknown fields are ignored, and an enum value newer than
|
|
603
|
+
the SDK still decodes, so `status.value` works for it.
|
|
603
604
|
|
|
604
605
|
### RunView
|
|
605
606
|
|
|
606
607
|
Returned by `get_status()` and `list_runs()`. Represents a single job run.
|
|
607
608
|
|
|
608
|
-
| Field
|
|
609
|
-
|
|
610
|
-
| `id`
|
|
611
|
-
| `name`
|
|
612
|
-
| `status`
|
|
613
|
-
| `
|
|
614
|
-
| `
|
|
615
|
-
| `
|
|
616
|
-
| `
|
|
617
|
-
| `
|
|
618
|
-
| `
|
|
619
|
-
| `
|
|
620
|
-
| `
|
|
621
|
-
| `
|
|
622
|
-
| `
|
|
623
|
-
| `
|
|
624
|
-
| `
|
|
625
|
-
| `
|
|
626
|
-
| `
|
|
627
|
-
| `
|
|
628
|
-
| `
|
|
609
|
+
| Field | Type | Description |
|
|
610
|
+
|-------------------|----------------------------|--------------------------------------------|
|
|
611
|
+
| `id` | `str` | Run ID |
|
|
612
|
+
| `name` | `str` | Job name |
|
|
613
|
+
| `status` | `JobStatus` | Current status |
|
|
614
|
+
| `is_terminal` | `bool` | The run has finished |
|
|
615
|
+
| `create_time` | `datetime` | Creation time |
|
|
616
|
+
| `update_time` | `datetime` | Last update time |
|
|
617
|
+
| `start_time` | `datetime \| None` | Start time |
|
|
618
|
+
| `complete_time` | `datetime \| None` | Completion time |
|
|
619
|
+
| `triggered_by` | `OrganizationCustomer` | User who triggered the run |
|
|
620
|
+
| `kube_app` | `RunKubeApp \| None` | Kubernetes app details |
|
|
621
|
+
| `payload` | `RunPayload` | What the run was created with |
|
|
622
|
+
| `runtime` | `str \| None` | From `payload` |
|
|
623
|
+
| `version` | `str \| None` | From `payload` |
|
|
624
|
+
| `timeout_seconds` | `int` | From `payload` |
|
|
625
|
+
| `run_python` | `RunPythonPayload \| None` | From `payload` |
|
|
626
|
+
| `run_jar` | `RunJarPayload \| None` | From `payload` |
|
|
627
|
+
| `environment` | `ResolvedRunEnvironment \| None` | From `payload` |
|
|
628
|
+
| `region` | `str \| None` | From `kube_app` |
|
|
629
|
+
| `app_meta` | `RunAppMeta \| None` | Spark and Sedona UI URLs, from `kube_app` |
|
|
630
|
+
| `raw` | `dict` | The response body as the server sent it |
|
|
629
631
|
|
|
630
632
|
### LogsResponse
|
|
631
633
|
|
|
632
634
|
Returned by `get_logs()`.
|
|
633
635
|
|
|
634
|
-
| Field | Type
|
|
635
|
-
|
|
636
|
-
| `items` | `list[LogItem]`
|
|
637
|
-
| `next_page` | `
|
|
638
|
-
| `current_page` | `
|
|
636
|
+
| Field | Type | Description |
|
|
637
|
+
|----------------|-----------------|-----------------------------------------------|
|
|
638
|
+
| `items` | `list[LogItem]` | Log entries |
|
|
639
|
+
| `next_page` | `str \| None` | Next page cursor. `None` on a tail page |
|
|
640
|
+
| `current_page` | `str` | Current page cursor |
|
|
641
|
+
| `raw` | `dict` | The response body as the server sent it |
|
|
639
642
|
|
|
640
643
|
### LogItem
|
|
641
644
|
|
|
642
|
-
| Field | Type
|
|
643
|
-
|
|
644
|
-
| `raw` | `str`
|
|
645
|
-
| `timestamp` | `
|
|
646
|
-
| `level` | `str \| None` | Log level (INFO, ERROR, etc.) |
|
|
647
|
-
| `message` | `str \| None` | Parsed message |
|
|
648
|
-
| `extra` | `dict` | Additional fields |
|
|
645
|
+
| Field | Type | Description |
|
|
646
|
+
|-------------|-------|-----------------------------------|
|
|
647
|
+
| `raw` | `str` | Raw log line text |
|
|
648
|
+
| `timestamp` | `str` | Epoch nanoseconds, as a string |
|
|
649
649
|
|
|
650
650
|
### RunListPage
|
|
651
651
|
|
|
652
652
|
Returned by `list_runs()`.
|
|
653
653
|
|
|
654
|
-
| Field | Type
|
|
655
|
-
|
|
656
|
-
| `items` | `list[RunView]`
|
|
657
|
-
| `total` | `int`
|
|
658
|
-
| `next_page` | `str \| None`
|
|
659
|
-
| `previous_page` | `str \| None`
|
|
660
|
-
| `current_page` | `str \| None`
|
|
661
|
-
| `current_page_backwards` | `str \| None`
|
|
654
|
+
| Field | Type | Description |
|
|
655
|
+
|--------------------------|-----------------|-----------------------------------------|
|
|
656
|
+
| `items` | `list[RunView]` | Runs on this page |
|
|
657
|
+
| `total` | `int` | Total matching runs |
|
|
658
|
+
| `next_page` | `str \| None` | Next page cursor |
|
|
659
|
+
| `previous_page` | `str \| None` | Previous page cursor |
|
|
660
|
+
| `current_page` | `str \| None` | Current page cursor |
|
|
661
|
+
| `current_page_backwards` | `str \| None` | Backward pagination cursor |
|
|
662
|
+
| `raw` | `dict` | The response body as the server sent it |
|
|
662
663
|
|
|
663
664
|
### RunMetricsResponse
|
|
664
665
|
|
|
665
666
|
Returned by `get_metrics()`.
|
|
666
667
|
|
|
667
|
-
| Field | Type
|
|
668
|
-
|
|
669
|
-
| `series_metrics` | `dict`
|
|
670
|
-
| `instant_metrics` | `dict` | Point-in-time metrics
|
|
671
|
-
| `
|
|
668
|
+
| Field | Type | Description |
|
|
669
|
+
|-------------------|----------------------------------|-----------------------------------------|
|
|
670
|
+
| `series_metrics` | `dict[str, SeriesMetricDetails]` | Time-series metrics |
|
|
671
|
+
| `instant_metrics` | `dict[str, InstantMetricDetails]` | Point-in-time metrics |
|
|
672
|
+
| `raw` | `dict` | The response body as the server sent it |
|
|
672
673
|
|
|
673
674
|
## Exceptions
|
|
674
675
|
|
|
@@ -13,7 +13,7 @@ Additional Wherobots surfaces will be added over time.
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
15
|
- Submit Python scripts or JARs as Wherobots jobs
|
|
16
|
-
- Auto-upload local scripts
|
|
16
|
+
- Auto-upload local scripts to Wherobots managed storage (only needs an API key)
|
|
17
17
|
- Stream or iterate logs with pagination
|
|
18
18
|
- List runs with status, name, and date filters
|
|
19
19
|
- Typed dataclass models for all API responses (no pydantic dependency)
|
|
@@ -35,7 +35,7 @@ The simplest way to run a local script — only an API key is needed:
|
|
|
35
35
|
from wherobots import WherobotsJob
|
|
36
36
|
|
|
37
37
|
job = WherobotsJob(
|
|
38
|
-
script="my_analysis.py", # local file — auto-uploaded
|
|
38
|
+
script="my_analysis.py", # local file — auto-uploaded to managed storage
|
|
39
39
|
name="analysis-job-001",
|
|
40
40
|
runtime="tiny",
|
|
41
41
|
region="aws-us-west-2",
|
|
@@ -62,8 +62,7 @@ job = WherobotsJob(
|
|
|
62
62
|
### Script Upload Behavior
|
|
63
63
|
|
|
64
64
|
When `script` is a local file path (not an `s3://` URI) and `auto_upload=True`
|
|
65
|
-
(the default), the SDK uploads your script
|
|
66
|
-
managed storage. Only needs a valid API key — no AWS credentials required.
|
|
65
|
+
(the default), the SDK uploads your script to Wherobots managed storage. Only needs a valid API key — no AWS credentials required.
|
|
67
66
|
|
|
68
67
|
You can also reference scripts already in a
|
|
69
68
|
[Storage Integration](https://docs.wherobots.com/latest/develop/storage-management/storage/)
|
|
@@ -109,7 +108,7 @@ job = WherobotsJob(script="s3://bucket/script.py", name="my-job-001")
|
|
|
109
108
|
| `WHEROBOTS_API_KEY` | API key | *(required outside Wherobots)* |
|
|
110
109
|
| `WHEROBOTS_REGION` | Region override (else org default) | *(none — org default)* |
|
|
111
110
|
| `WHEROBOTS_API_BASE_URL` | API base URL | `https://api.cloud.wherobots.com` |
|
|
112
|
-
| `WHEROBOTS_VERSION` |
|
|
111
|
+
| `WHEROBOTS_VERSION` | Runtime version | *(none, the org preset decides)* |
|
|
113
112
|
| `WHEROBOTS_REQUEST_TIMEOUT_SECONDS`| HTTP request timeout (seconds) | `30` |
|
|
114
113
|
| `WHEROBOTS_CLIENT_CHAIN` | Upstream client-attribution chain (see below) | *(none)* |
|
|
115
114
|
| `WHEROBOTS_ID_TOKEN_PATH` | Workload identity token, set by Wherobots notebooks and jobs | *(none)* |
|
|
@@ -140,7 +139,7 @@ config = WherobotsConfig(
|
|
|
140
139
|
| `api_key` | `str \| None` | `None` (read from env) |
|
|
141
140
|
| `region` | `str \| None` | `None` |
|
|
142
141
|
| `base_url` | `str` | `"https://api.cloud.wherobots.com"` |
|
|
143
|
-
| `version` | `str`
|
|
142
|
+
| `version` | `str \| None` | `None` (org preset) |
|
|
144
143
|
| `request_timeout_seconds` | `int` | `30` |
|
|
145
144
|
| `client_chain` | `str \| None` | `None` |
|
|
146
145
|
|
|
@@ -187,11 +186,11 @@ WherobotsJob(
|
|
|
187
186
|
runtime: str | Runtime | None = None, # Compute size (None -> org default)
|
|
188
187
|
region: str | Region | None = None, # Region; str passed as-is (None -> org default)
|
|
189
188
|
api_key: str | None = None, # API key (or env var)
|
|
190
|
-
version: str | None = None, # "latest" | "preview"
|
|
189
|
+
version: str | None = None, # "latest" | "preview" (None -> org preset)
|
|
191
190
|
timeout_seconds: int = 3600, # Job timeout
|
|
192
191
|
args: list[str] | None = None, # Script arguments
|
|
193
192
|
spark_configs: dict[str, str] | None = None, # Spark config overrides
|
|
194
|
-
dependencies: list[
|
|
193
|
+
dependencies: list[PyPiDependency | FileDependency] | None = None,
|
|
195
194
|
spark_driver_disk_gb: int | None = None, # Driver disk size (GB)
|
|
196
195
|
spark_executor_disk_gb: int | None = None, # Executor disk size (GB)
|
|
197
196
|
jar_main_class: str | None = None, # Main class (required for JARs)
|
|
@@ -209,14 +208,14 @@ WherobotsJob(
|
|
|
209
208
|
|--------|---------|-------------|
|
|
210
209
|
| `submit()` | `str` | Submit the job. Returns the run ID. Idempotent (returns existing ID if already submitted). |
|
|
211
210
|
| `get_status()` | `RunView` | Get current job status and full details. |
|
|
212
|
-
| `get_logs(cursor=
|
|
211
|
+
| `get_logs(cursor=None, size=100)` | `LogsResponse` | Fetch a page of log entries. The cursor is an opaque string from `next_page`. |
|
|
213
212
|
| `get_metrics()` | `RunMetricsResponse` | Fetch CPU/memory metrics for the run. |
|
|
214
213
|
| `get_cpu_utilization()` | `UtilizationStats` | Aggregated CPU utilization (`latest`, `max`, `avg`, `series`). |
|
|
215
214
|
| `get_mem_utilization()` | `UtilizationStats` | Aggregated memory utilization (`latest`, `max`, `avg`, `series`). |
|
|
216
215
|
| `get_cost()` | `float \| None` | Total run cost in USD, or `None` if not yet billed. |
|
|
217
216
|
| `get_consumed_spatial_units()` | `float \| None` | Spatial Units (SUs) consumed by the run. |
|
|
218
217
|
| `refresh()` | `RunView` | Re-fetch from the API and update `status`/`name`/`runtime`/`region`/`version` in place. |
|
|
219
|
-
| `iter_logs(cursor=
|
|
218
|
+
| `iter_logs(cursor=None, size=100)` | `Iterator[dict]` | Iterate over all log entries, handling pagination automatically. |
|
|
220
219
|
| `poll_for_logs(follow=True, interval=2.0, log_handler=None, max_errors=10)` | `None` | Poll and print logs. If `follow=True`, continues until job completes. `max_errors` sets the max consecutive transient errors before giving up. |
|
|
221
220
|
| `cancel()` | `bool` | Request cancellation. Returns `True` on success. |
|
|
222
221
|
| `wait_for_completion(poll_interval=5.0, stream_logs=True, log_interval=2.0, max_wait_seconds=None)` | `JobStatus` | Block until the job reaches a terminal state. Set `max_wait_seconds` to limit wait time (raises `WherobotsTimeoutError`). |
|
|
@@ -243,8 +242,8 @@ with WherobotsJob(script="s3://bucket/script.py", name="my-job") as job:
|
|
|
243
242
|
|--------|---------|-------------|
|
|
244
243
|
| `from_run_id(run_id, api_key=None, ...)` | `WherobotsJob` | Attach to an existing run for read-only log/metric access. No script required. `submit()` is disabled on the returned instance. |
|
|
245
244
|
| `list_runs(...)` | `RunListPage` | List runs with optional filters. No instance required. |
|
|
246
|
-
| `add_pypi_dependency(
|
|
247
|
-
| `add_file_dependency(file_path)` | `
|
|
245
|
+
| `add_pypi_dependency(library_name, library_version=None)` | `PyPiDependency` | Create a PyPI dependency for the `dependencies` parameter. |
|
|
246
|
+
| `add_file_dependency(file_path)` | `FileDependency` | Create a file dependency (`.jar`, `.whl`, `.zip`, `.json`). Accepts an `s3://` URI or a local path — local paths are auto-uploaded to **managed storage** at `submit()` time. For non-managed destinations, upload via `FilesAPI` first and pass the resulting `s3://` URI. |
|
|
248
247
|
|
|
249
248
|
#### Attaching to an Existing Run
|
|
250
249
|
|
|
@@ -572,77 +571,79 @@ job = WherobotsJob(
|
|
|
572
571
|
|
|
573
572
|
## Models
|
|
574
573
|
|
|
575
|
-
|
|
576
|
-
for JSON
|
|
574
|
+
Models are generated from the Wherobots OpenAPI spec. They are frozen dataclasses built with
|
|
575
|
+
keyword arguments, with `from_dict()` and `to_dict()` for the API's JSON. A missing required field
|
|
576
|
+
or a wrong type raises `WherobotsAPIError`. Unknown fields are ignored, and an enum value newer than
|
|
577
|
+
the SDK still decodes, so `status.value` works for it.
|
|
577
578
|
|
|
578
579
|
### RunView
|
|
579
580
|
|
|
580
581
|
Returned by `get_status()` and `list_runs()`. Represents a single job run.
|
|
581
582
|
|
|
582
|
-
| Field
|
|
583
|
-
|
|
584
|
-
| `id`
|
|
585
|
-
| `name`
|
|
586
|
-
| `status`
|
|
587
|
-
| `
|
|
588
|
-
| `
|
|
589
|
-
| `
|
|
590
|
-
| `
|
|
591
|
-
| `
|
|
592
|
-
| `
|
|
593
|
-
| `
|
|
594
|
-
| `
|
|
595
|
-
| `
|
|
596
|
-
| `
|
|
597
|
-
| `
|
|
598
|
-
| `
|
|
599
|
-
| `
|
|
600
|
-
| `
|
|
601
|
-
| `
|
|
602
|
-
| `
|
|
583
|
+
| Field | Type | Description |
|
|
584
|
+
|-------------------|----------------------------|--------------------------------------------|
|
|
585
|
+
| `id` | `str` | Run ID |
|
|
586
|
+
| `name` | `str` | Job name |
|
|
587
|
+
| `status` | `JobStatus` | Current status |
|
|
588
|
+
| `is_terminal` | `bool` | The run has finished |
|
|
589
|
+
| `create_time` | `datetime` | Creation time |
|
|
590
|
+
| `update_time` | `datetime` | Last update time |
|
|
591
|
+
| `start_time` | `datetime \| None` | Start time |
|
|
592
|
+
| `complete_time` | `datetime \| None` | Completion time |
|
|
593
|
+
| `triggered_by` | `OrganizationCustomer` | User who triggered the run |
|
|
594
|
+
| `kube_app` | `RunKubeApp \| None` | Kubernetes app details |
|
|
595
|
+
| `payload` | `RunPayload` | What the run was created with |
|
|
596
|
+
| `runtime` | `str \| None` | From `payload` |
|
|
597
|
+
| `version` | `str \| None` | From `payload` |
|
|
598
|
+
| `timeout_seconds` | `int` | From `payload` |
|
|
599
|
+
| `run_python` | `RunPythonPayload \| None` | From `payload` |
|
|
600
|
+
| `run_jar` | `RunJarPayload \| None` | From `payload` |
|
|
601
|
+
| `environment` | `ResolvedRunEnvironment \| None` | From `payload` |
|
|
602
|
+
| `region` | `str \| None` | From `kube_app` |
|
|
603
|
+
| `app_meta` | `RunAppMeta \| None` | Spark and Sedona UI URLs, from `kube_app` |
|
|
604
|
+
| `raw` | `dict` | The response body as the server sent it |
|
|
603
605
|
|
|
604
606
|
### LogsResponse
|
|
605
607
|
|
|
606
608
|
Returned by `get_logs()`.
|
|
607
609
|
|
|
608
|
-
| Field | Type
|
|
609
|
-
|
|
610
|
-
| `items` | `list[LogItem]`
|
|
611
|
-
| `next_page` | `
|
|
612
|
-
| `current_page` | `
|
|
610
|
+
| Field | Type | Description |
|
|
611
|
+
|----------------|-----------------|-----------------------------------------------|
|
|
612
|
+
| `items` | `list[LogItem]` | Log entries |
|
|
613
|
+
| `next_page` | `str \| None` | Next page cursor. `None` on a tail page |
|
|
614
|
+
| `current_page` | `str` | Current page cursor |
|
|
615
|
+
| `raw` | `dict` | The response body as the server sent it |
|
|
613
616
|
|
|
614
617
|
### LogItem
|
|
615
618
|
|
|
616
|
-
| Field | Type
|
|
617
|
-
|
|
618
|
-
| `raw` | `str`
|
|
619
|
-
| `timestamp` | `
|
|
620
|
-
| `level` | `str \| None` | Log level (INFO, ERROR, etc.) |
|
|
621
|
-
| `message` | `str \| None` | Parsed message |
|
|
622
|
-
| `extra` | `dict` | Additional fields |
|
|
619
|
+
| Field | Type | Description |
|
|
620
|
+
|-------------|-------|-----------------------------------|
|
|
621
|
+
| `raw` | `str` | Raw log line text |
|
|
622
|
+
| `timestamp` | `str` | Epoch nanoseconds, as a string |
|
|
623
623
|
|
|
624
624
|
### RunListPage
|
|
625
625
|
|
|
626
626
|
Returned by `list_runs()`.
|
|
627
627
|
|
|
628
|
-
| Field | Type
|
|
629
|
-
|
|
630
|
-
| `items` | `list[RunView]`
|
|
631
|
-
| `total` | `int`
|
|
632
|
-
| `next_page` | `str \| None`
|
|
633
|
-
| `previous_page` | `str \| None`
|
|
634
|
-
| `current_page` | `str \| None`
|
|
635
|
-
| `current_page_backwards` | `str \| None`
|
|
628
|
+
| Field | Type | Description |
|
|
629
|
+
|--------------------------|-----------------|-----------------------------------------|
|
|
630
|
+
| `items` | `list[RunView]` | Runs on this page |
|
|
631
|
+
| `total` | `int` | Total matching runs |
|
|
632
|
+
| `next_page` | `str \| None` | Next page cursor |
|
|
633
|
+
| `previous_page` | `str \| None` | Previous page cursor |
|
|
634
|
+
| `current_page` | `str \| None` | Current page cursor |
|
|
635
|
+
| `current_page_backwards` | `str \| None` | Backward pagination cursor |
|
|
636
|
+
| `raw` | `dict` | The response body as the server sent it |
|
|
636
637
|
|
|
637
638
|
### RunMetricsResponse
|
|
638
639
|
|
|
639
640
|
Returned by `get_metrics()`.
|
|
640
641
|
|
|
641
|
-
| Field | Type
|
|
642
|
-
|
|
643
|
-
| `series_metrics` | `dict`
|
|
644
|
-
| `instant_metrics` | `dict` | Point-in-time metrics
|
|
645
|
-
| `
|
|
642
|
+
| Field | Type | Description |
|
|
643
|
+
|-------------------|----------------------------------|-----------------------------------------|
|
|
644
|
+
| `series_metrics` | `dict[str, SeriesMetricDetails]` | Time-series metrics |
|
|
645
|
+
| `instant_metrics` | `dict[str, InstantMetricDetails]` | Point-in-time metrics |
|
|
646
|
+
| `raw` | `dict` | The response body as the server sent it |
|
|
646
647
|
|
|
647
648
|
## Exceptions
|
|
648
649
|
|
|
@@ -37,6 +37,7 @@ Documentation = "https://docs.wherobots.com"
|
|
|
37
37
|
# PEP 735 dev dependencies — installed with `uv sync --group dev`.
|
|
38
38
|
[dependency-groups]
|
|
39
39
|
dev = [
|
|
40
|
+
"jsonschema>=4.23",
|
|
40
41
|
"pytest==9.1.1",
|
|
41
42
|
"pytest-cov==7.1.0",
|
|
42
43
|
"pytest-mock==3.17.0",
|
|
@@ -97,6 +98,14 @@ extend-ignore = ["SIM117", "EM101", "EM102", "TRY003", "PLR0917"]
|
|
|
97
98
|
# Package __init__ groups exports by category with comment headers;
|
|
98
99
|
# don't let ruff re-sort them alphabetically.
|
|
99
100
|
"wherobots/__init__.py" = ["RUF022"]
|
|
101
|
+
# Generated from the spec: names and docstrings are the API's, and the annotations
|
|
102
|
+
# are evaluated at runtime by the wire decoder.
|
|
103
|
+
"wherobots/models/_generated.py" = ["A", "D", "E501", "FBT", "TC"]
|
|
104
|
+
"wherobots/enums/_generated.py" = ["D", "E501"]
|
|
105
|
+
"wherobots/api/_operations.py" = ["A", "D", "E501", "FBT", "PLR0913", "TC"]
|
|
106
|
+
"wherobots/{enums,models}/__init__.py" = ["D", "RUF022"]
|
|
107
|
+
# Dev tools rather than package code.
|
|
108
|
+
"scripts/*.py" = ["D", "INP001", "PLR0911", "S310", "S603", "S607", "T201"]
|
|
100
109
|
|
|
101
110
|
[tool.pyrefly]
|
|
102
111
|
project-includes = ["wherobots"]
|
|
@@ -112,4 +121,5 @@ python_functions = ["test_*"]
|
|
|
112
121
|
addopts = ["--cov=wherobots", "--cov-report=html", "--cov-report=term-missing", "-m", "not integration"]
|
|
113
122
|
markers = [
|
|
114
123
|
"integration: live API tests requiring WHEROBOTS_API_KEY (deselected by default)",
|
|
124
|
+
"off_contract: feeds a response the spec forbids, so skip the spec_contract fixture",
|
|
115
125
|
]
|