wherobots-python-sdk 0.1.0__tar.gz → 0.2.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.1.0 → wherobots_python_sdk-0.2.0}/PKG-INFO +4 -4
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/README.md +3 -3
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_api.py +15 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_client.py +31 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_models.py +10 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/__version__.py +1 -1
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/api/runs.py +7 -5
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/client.py +17 -4
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/models.py +5 -3
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots_python_sdk.egg-info/PKG-INFO +4 -4
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/LICENSE +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/pyproject.toml +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/setup.cfg +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_base_client.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_config.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_enums.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_exceptions.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_files_api.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_init_exports.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_integration.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_logger.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_regressions.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_security.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/tests/test_utils.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/__init__.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/api/__init__.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/api/base.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/api/files.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/config.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/enums.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/exceptions.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/py.typed +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/utils/__init__.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/utils/logger.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots/utils/validation.py +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots_python_sdk.egg-info/SOURCES.txt +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots_python_sdk.egg-info/dependency_links.txt +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots_python_sdk.egg-info/requires.txt +0 -0
- {wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots_python_sdk.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wherobots-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.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
|
|
@@ -130,7 +130,7 @@ The API key can also be set via the `WHEROBOTS_API_KEY` environment variable.
|
|
|
130
130
|
| Variable | Description | Default |
|
|
131
131
|
|------------------------------------|---------------------------------|--------------------------------------|
|
|
132
132
|
| `WHEROBOTS_API_KEY` | API key | *(required)* |
|
|
133
|
-
| `WHEROBOTS_REGION` |
|
|
133
|
+
| `WHEROBOTS_REGION` | Region override (else org default) | *(none — org default)* |
|
|
134
134
|
| `WHEROBOTS_API_BASE_URL` | API base URL | `https://api.cloud.wherobots.com` |
|
|
135
135
|
| `WHEROBOTS_VERSION` | Wherobots version | `latest` |
|
|
136
136
|
| `WHEROBOTS_REQUEST_TIMEOUT_SECONDS`| HTTP request timeout (seconds) | `30` |
|
|
@@ -176,8 +176,8 @@ The primary class for managing job runs.
|
|
|
176
176
|
WherobotsJob(
|
|
177
177
|
script: str, # Path or S3 URI to .py or .jar
|
|
178
178
|
name: str, # Job name (8-255 chars, [a-zA-Z0-9_\-.]+)
|
|
179
|
-
runtime: str | Runtime =
|
|
180
|
-
region: str | Region | None = None, #
|
|
179
|
+
runtime: str | Runtime | None = None, # Compute size (None -> org default)
|
|
180
|
+
region: str | Region | None = None, # Region; str passed as-is (None -> org default)
|
|
181
181
|
api_key: str | None = None, # API key (or env var)
|
|
182
182
|
version: str | None = None, # "latest" | "preview"
|
|
183
183
|
timeout_seconds: int = 3600, # Job timeout
|
|
@@ -97,7 +97,7 @@ The API key can also be set via the `WHEROBOTS_API_KEY` environment variable.
|
|
|
97
97
|
| Variable | Description | Default |
|
|
98
98
|
|------------------------------------|---------------------------------|--------------------------------------|
|
|
99
99
|
| `WHEROBOTS_API_KEY` | API key | *(required)* |
|
|
100
|
-
| `WHEROBOTS_REGION` |
|
|
100
|
+
| `WHEROBOTS_REGION` | Region override (else org default) | *(none — org default)* |
|
|
101
101
|
| `WHEROBOTS_API_BASE_URL` | API base URL | `https://api.cloud.wherobots.com` |
|
|
102
102
|
| `WHEROBOTS_VERSION` | Wherobots version | `latest` |
|
|
103
103
|
| `WHEROBOTS_REQUEST_TIMEOUT_SECONDS`| HTTP request timeout (seconds) | `30` |
|
|
@@ -143,8 +143,8 @@ The primary class for managing job runs.
|
|
|
143
143
|
WherobotsJob(
|
|
144
144
|
script: str, # Path or S3 URI to .py or .jar
|
|
145
145
|
name: str, # Job name (8-255 chars, [a-zA-Z0-9_\-.]+)
|
|
146
|
-
runtime: str | Runtime =
|
|
147
|
-
region: str | Region | None = None, #
|
|
146
|
+
runtime: str | Runtime | None = None, # Compute size (None -> org default)
|
|
147
|
+
region: str | Region | None = None, # Region; str passed as-is (None -> org default)
|
|
148
148
|
api_key: str | None = None, # API key (or env var)
|
|
149
149
|
version: str | None = None, # "latest" | "preview"
|
|
150
150
|
timeout_seconds: int = 3600, # Job timeout
|
|
@@ -145,6 +145,21 @@ class TestCreate:
|
|
|
145
145
|
assert "/runs" in call_args[0][1]
|
|
146
146
|
assert call_args[1]["params"]["region"] == "aws-us-east-1"
|
|
147
147
|
|
|
148
|
+
def test_omits_region_when_not_provided(self, api, mock_session):
|
|
149
|
+
mock_session.request.return_value = _make_response(
|
|
150
|
+
{"id": "r2", "name": "t", "status": "PENDING"}
|
|
151
|
+
)
|
|
152
|
+
payload = CreateRunPayload(
|
|
153
|
+
name="default-region-job",
|
|
154
|
+
run_python=RunPythonPayload(uri="s3://b/s.py"),
|
|
155
|
+
)
|
|
156
|
+
api.create(payload) # no region -> API applies org default
|
|
157
|
+
|
|
158
|
+
call_kwargs = mock_session.request.call_args[1]
|
|
159
|
+
assert "region" not in call_kwargs["params"]
|
|
160
|
+
# runtime omitted from the body too -> org default applies
|
|
161
|
+
assert "runtime" not in call_kwargs["json"]
|
|
162
|
+
|
|
148
163
|
def test_sends_payload_as_json(self, api, mock_session):
|
|
149
164
|
mock_session.request.return_value = _make_response(
|
|
150
165
|
{"id": "r1", "name": "test", "status": "PENDING"}
|
|
@@ -69,6 +69,37 @@ def test_build_payload_jar_job(mock_env):
|
|
|
69
69
|
assert payload.run_python is None
|
|
70
70
|
|
|
71
71
|
|
|
72
|
+
def test_no_region_or_runtime_uses_no_default(monkeypatch, mock_api_key):
|
|
73
|
+
"""When neither arg, config, nor env supplies region/runtime, they stay
|
|
74
|
+
unset so the API applies the organization's configured defaults."""
|
|
75
|
+
monkeypatch.setenv("WHEROBOTS_API_KEY", mock_api_key)
|
|
76
|
+
monkeypatch.delenv("WHEROBOTS_REGION", raising=False)
|
|
77
|
+
|
|
78
|
+
job = WherobotsJob(script="s3://test-bucket/test-script.py", name="defaults-job")
|
|
79
|
+
|
|
80
|
+
assert job.region is None
|
|
81
|
+
assert job.runtime is None
|
|
82
|
+
payload = job._build_payload()
|
|
83
|
+
assert payload.runtime is None
|
|
84
|
+
assert "runtime" not in payload.to_dict()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_string_region_runtime_passthrough(monkeypatch, mock_api_key):
|
|
88
|
+
"""Raw region/runtime strings (e.g. BYOC regions) are kept as-is."""
|
|
89
|
+
monkeypatch.setenv("WHEROBOTS_API_KEY", mock_api_key)
|
|
90
|
+
monkeypatch.delenv("WHEROBOTS_REGION", raising=False)
|
|
91
|
+
|
|
92
|
+
job = WherobotsJob(
|
|
93
|
+
script="s3://test-bucket/test-script.py",
|
|
94
|
+
name="byoc-job",
|
|
95
|
+
runtime="x-large",
|
|
96
|
+
region="byoc-acme-us-east-1",
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
assert job.region == "byoc-acme-us-east-1"
|
|
100
|
+
assert job.runtime == "x-large"
|
|
101
|
+
|
|
102
|
+
|
|
72
103
|
def test_submit_sets_run_id(mock_env, sample_job_config):
|
|
73
104
|
job = WherobotsJob(**sample_job_config)
|
|
74
105
|
|
|
@@ -196,6 +196,16 @@ class TestCreateRunPayload:
|
|
|
196
196
|
out = payload.to_dict()
|
|
197
197
|
assert "environment" not in out
|
|
198
198
|
|
|
199
|
+
def test_runtime_omitted_when_none(self):
|
|
200
|
+
payload = CreateRunPayload(name="no-runtime")
|
|
201
|
+
out = payload.to_dict()
|
|
202
|
+
assert "runtime" not in out
|
|
203
|
+
|
|
204
|
+
def test_runtime_included_when_set(self):
|
|
205
|
+
payload = CreateRunPayload(name="with-runtime", runtime="large")
|
|
206
|
+
out = payload.to_dict()
|
|
207
|
+
assert out["runtime"] == "large"
|
|
208
|
+
|
|
199
209
|
|
|
200
210
|
# ---------------------------------------------------------------------------
|
|
201
211
|
# RunView
|
|
@@ -101,15 +101,15 @@ class RunsAPI:
|
|
|
101
101
|
def create(
|
|
102
102
|
self,
|
|
103
103
|
payload: CreateRunPayload,
|
|
104
|
-
region: str =
|
|
104
|
+
region: str | None = None,
|
|
105
105
|
) -> RunView:
|
|
106
106
|
"""Submit a new job run (``POST /runs``).
|
|
107
107
|
|
|
108
108
|
Args:
|
|
109
109
|
payload: The run configuration including script/JAR
|
|
110
110
|
details, runtime, and resource settings.
|
|
111
|
-
region: Wherobots deployment region
|
|
112
|
-
|
|
111
|
+
region: Wherobots deployment region. When omitted, the API
|
|
112
|
+
applies the organization's configured default region.
|
|
113
113
|
|
|
114
114
|
Returns:
|
|
115
115
|
A ``RunView`` representing the created run.
|
|
@@ -117,9 +117,11 @@ class RunsAPI:
|
|
|
117
117
|
Raises:
|
|
118
118
|
WherobotsAPIError: On HTTP or JSON-parsing failures.
|
|
119
119
|
"""
|
|
120
|
-
params = {
|
|
120
|
+
params = {}
|
|
121
|
+
if region:
|
|
122
|
+
params["region"] = region
|
|
121
123
|
body = payload.to_dict()
|
|
122
|
-
logger.info("Creating run '%s' in %s", payload.name, region)
|
|
124
|
+
logger.info("Creating run '%s' in %s", payload.name, region or "org default")
|
|
123
125
|
response = self._client.post("/runs", params=params, json_body=body)
|
|
124
126
|
return RunView.from_dict(self._parse_json(response))
|
|
125
127
|
|
|
@@ -58,7 +58,7 @@ class WherobotsJob:
|
|
|
58
58
|
self,
|
|
59
59
|
script: str,
|
|
60
60
|
name: str,
|
|
61
|
-
runtime: str | Runtime =
|
|
61
|
+
runtime: str | Runtime | None = None,
|
|
62
62
|
region: str | Region | None = None,
|
|
63
63
|
api_key: str | None = None,
|
|
64
64
|
version: str | None = None,
|
|
@@ -82,8 +82,19 @@ class WherobotsJob:
|
|
|
82
82
|
script: Path to Python script (.py) or JAR file (.jar).
|
|
83
83
|
Can be local path or S3 URI (s3://bucket/key)
|
|
84
84
|
name: Job name (8-255 chars, alphanumeric, _, -, .)
|
|
85
|
-
runtime:
|
|
86
|
-
|
|
85
|
+
runtime: The compute runtime to use. Accepts a ``Runtime`` enum
|
|
86
|
+
value or a raw string; strings are passed to the API as-is.
|
|
87
|
+
Override the default runtime set for your organization — only
|
|
88
|
+
set this if you need a specific runtime instead of the one your
|
|
89
|
+
administrator has configured. When omitted, your organization's
|
|
90
|
+
default runtime is used.
|
|
91
|
+
region: The compute region to run in. Accepts a ``Region`` enum
|
|
92
|
+
value or a raw string (e.g. a BYOC region such as
|
|
93
|
+
``byoc-acme-us-east-1``); strings are passed to the API as-is.
|
|
94
|
+
Override the default region set for your organization — only set
|
|
95
|
+
this if you intend to use a specific region instead of the one
|
|
96
|
+
your administrator has configured. When omitted, your
|
|
97
|
+
organization's default region is used.
|
|
87
98
|
api_key: Wherobots API key (or set WHEROBOTS_API_KEY env var)
|
|
88
99
|
version: Wherobots version ("latest" or "preview")
|
|
89
100
|
timeout_seconds: Job timeout in seconds (default: 3600)
|
|
@@ -138,7 +149,9 @@ class WherobotsJob:
|
|
|
138
149
|
request_timeout_seconds=request_timeout_seconds,
|
|
139
150
|
)
|
|
140
151
|
|
|
141
|
-
|
|
152
|
+
# No hardcoded fallback: when neither the argument nor the config
|
|
153
|
+
# supplies a region, leave it unset so the API applies the org default.
|
|
154
|
+
self.region = region_value or self._config.region
|
|
142
155
|
self.version = version or self._config.version
|
|
143
156
|
self.timeout_seconds = timeout_seconds
|
|
144
157
|
self.args = args or []
|
|
@@ -244,8 +244,8 @@ class RunJarPayload:
|
|
|
244
244
|
class CreateRunPayload:
|
|
245
245
|
"""Full payload for ``POST /runs``."""
|
|
246
246
|
|
|
247
|
-
runtime: str
|
|
248
247
|
name: str
|
|
248
|
+
runtime: str | None = None
|
|
249
249
|
version: str = "latest"
|
|
250
250
|
timeout_seconds: int = 3600
|
|
251
251
|
run_python: RunPythonPayload | None = None
|
|
@@ -259,11 +259,13 @@ class CreateRunPayload:
|
|
|
259
259
|
Dict suitable for ``POST /runs`` request body.
|
|
260
260
|
"""
|
|
261
261
|
d: dict[str, Any] = {
|
|
262
|
-
"runtime": self.runtime,
|
|
263
262
|
"name": self.name,
|
|
264
263
|
"version": self.version,
|
|
265
264
|
"timeoutSeconds": self.timeout_seconds,
|
|
266
265
|
}
|
|
266
|
+
# Omit runtime when unset so the API applies the org default.
|
|
267
|
+
if self.runtime is not None:
|
|
268
|
+
d["runtime"] = self.runtime
|
|
267
269
|
if self.run_python is not None:
|
|
268
270
|
d["runPython"] = self.run_python.to_dict()
|
|
269
271
|
if self.run_jar is not None:
|
|
@@ -296,7 +298,7 @@ class CreateRunPayload:
|
|
|
296
298
|
if "environment" in data and data["environment"] is not None:
|
|
297
299
|
environment = RunEnvironment.from_dict(data["environment"])
|
|
298
300
|
return cls(
|
|
299
|
-
runtime=data.get("runtime"
|
|
301
|
+
runtime=data.get("runtime"),
|
|
300
302
|
name=data.get("name", ""),
|
|
301
303
|
version=data.get("version", "latest"),
|
|
302
304
|
timeout_seconds=data.get("timeoutSeconds", 3600),
|
{wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots_python_sdk.egg-info/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.2.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
|
|
@@ -130,7 +130,7 @@ The API key can also be set via the `WHEROBOTS_API_KEY` environment variable.
|
|
|
130
130
|
| Variable | Description | Default |
|
|
131
131
|
|------------------------------------|---------------------------------|--------------------------------------|
|
|
132
132
|
| `WHEROBOTS_API_KEY` | API key | *(required)* |
|
|
133
|
-
| `WHEROBOTS_REGION` |
|
|
133
|
+
| `WHEROBOTS_REGION` | Region override (else org default) | *(none — org default)* |
|
|
134
134
|
| `WHEROBOTS_API_BASE_URL` | API base URL | `https://api.cloud.wherobots.com` |
|
|
135
135
|
| `WHEROBOTS_VERSION` | Wherobots version | `latest` |
|
|
136
136
|
| `WHEROBOTS_REQUEST_TIMEOUT_SECONDS`| HTTP request timeout (seconds) | `30` |
|
|
@@ -176,8 +176,8 @@ The primary class for managing job runs.
|
|
|
176
176
|
WherobotsJob(
|
|
177
177
|
script: str, # Path or S3 URI to .py or .jar
|
|
178
178
|
name: str, # Job name (8-255 chars, [a-zA-Z0-9_\-.]+)
|
|
179
|
-
runtime: str | Runtime =
|
|
180
|
-
region: str | Region | None = None, #
|
|
179
|
+
runtime: str | Runtime | None = None, # Compute size (None -> org default)
|
|
180
|
+
region: str | Region | None = None, # Region; str passed as-is (None -> org default)
|
|
181
181
|
api_key: str | None = None, # API key (or env var)
|
|
182
182
|
version: str | None = None, # "latest" | "preview"
|
|
183
183
|
timeout_seconds: int = 3600, # Job timeout
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots_python_sdk.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{wherobots_python_sdk-0.1.0 → wherobots_python_sdk-0.2.0}/wherobots_python_sdk.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|