diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index d7811b1..8012ea1 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "drums", "description": "Isolated desktops for computer-use agents: start a computer from a template, act with GUI, shell and files, verify against a task checker, fork and reset, and read run results, all through the Drums MCP server.", - "version": "0.3.0", + "version": "0.4.0", "author": { "name": "Drums Labs" } } diff --git a/.github/scripts/pip-audit.sh b/.github/scripts/pip-audit.sh index 4c9156a..7f129c6 100755 --- a/.github/scripts/pip-audit.sh +++ b/.github/scripts/pip-audit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Dependency audit (A-40): install the package into a fresh venv the way CI does, freeze what got installed, and run +# Dependency audit: install the package into a fresh venv the way CI does, freeze what got installed, and run # pip-audit on exactly that set. Fails on any known vulnerability that is not in the allowlist (.pip-audit-ignore). # # .github/scripts/pip-audit.sh PIP_INSTALL_ARGS... e.g. .github/scripts/pip-audit.sh '.[test]' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbb0b18..711e395 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: python -m build python -m twine check --strict dist/* - # A-40: the SDK has no runtime dependencies; the audited set is what CI installs to build and check it (pip, build, + # the SDK has no runtime dependencies; the audited set is what CI installs to build and check it (pip, build, # twine and their dependencies). Fails on any advisory not in .pip-audit-ignore. audit: name: pip-audit diff --git a/.github/workflows/dependency-audit.yml b/.github/workflows/dependency-audit.yml index d62ccd9..5c74f9d 100644 --- a/.github/workflows/dependency-audit.yml +++ b/.github/workflows/dependency-audit.yml @@ -1,4 +1,4 @@ -# Weekly dependency audit (A-40): the same pip-audit as CI, on a schedule, against today's advisory database and today's +# Weekly dependency audit: the same pip-audit as CI, on a schedule, against today's advisory database and today's # resolution of the declared ranges. On failure it opens one issue labelled "dependencies", or comments on the one that # is already open; it never closes an issue (a person does, after the fix lands). name: dependency-audit diff --git a/.pip-audit-ignore b/.pip-audit-ignore index 480f35e..7236989 100644 --- a/.pip-audit-ignore +++ b/.pip-audit-ignore @@ -1,2 +1,2 @@ -# Accepted pip-audit advisories (A-40). One per line: +# Accepted pip-audit advisories. One per line: # An entry past its review date fails the audit. Empty: nothing is accepted today. diff --git a/CHANGELOG.md b/CHANGELOG.md index 58635c8..6abb255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ SDK version was built against is noted where it matters. ## 0.4.0 - 2026-11-18 -Post-D1 fixes for training clients (audit 2026-11-16), integrated in one release. Minor version: new API and one +Fixes for training clients, from our first 128-desktop training run, integrated in one release. Minor version: new API and one behaviour change (429 replies are retried, with an off switch); nothing is removed and no dependency is added. Every 0.3 call keeps its signature and meaning. Built against drumsd 0.4.2 and the gateway routes of Drums-Labs/drums #41 (trainer runs), #43 (desktop tokens), #46 (task-set tasks) and #49 (`GET /v1/limits`); against an older gateway each @@ -13,7 +13,7 @@ feature falls back as described below. ### Changed -- **429 replies are retried on every call** (A-29, #11). A 429 (the gateway's per-key rate limit, or no capacity +- **429 replies are retried on every call** (#11). A 429 (the gateway's per-key rate limit, or no capacity right now: nothing was started) is retried for every method, step, screenshot, verify, create and fork included, waiting at least the reply's `Retry-After` (seconds or an HTTP date), with jittered exponential backoff, for at most 60 s of waiting per call (or 20 retries). `drums.RetryPolicy(max_wait_s, max_attempts, base_s, cap_s, jitter)` @@ -23,7 +23,7 @@ feature falls back as described below. ### Added -- **Desktop tokens** (A-30, #14; design note "control plane out of the data path", 3.1). `drums.connect(url, key)` +- **Desktop tokens** (#14). `drums.connect(url, key)` keeps its signature. With a Drums API key (`drums_sk_...`) the client asks the gateway once how it authenticates (`GET /auth`, no credential). When the gateway says `token` or `both`, the key is sent once to the console's token URL (https, or loopback http; the same transport and redirect rules as every other request) and the gateway @@ -36,11 +36,11 @@ feature falls back as described below. gateway's mode was known (the discovery request got no answer) is retried once after a 401. A drumsd token, or a gateway in `api_key` mode, works exactly as before. Neither the key nor the token appears in a repr (`repr(client)` shows the auth kind only) or an error message. -- **macOS certificates** (A-07, #11). When the system store cannot verify the gateway or the console and `certifi` +- **macOS certificates** (#11). When the system store cannot verify the gateway or the console and `certifi` is installed, the client switches to certifi's CA bundle once (for both) and prints one line naming the server; without certifi it raises the new `CertificateError` (a `DaemonUnavailable`) with the fix (`Install Certificates.command` or `pip install certifi`). No new dependency. -- **Run object** (A-36, #12, matching the gateway's trainer runs). `with client.run(name, kind="training", +- **Run object** (#12, matching the gateway's trainer runs). `with client.run(name, kind="training", task_set=..., config=..., desktops_provisioned=N) as run:` opens a run (`POST /v1/runs`), `run.step(step, reward=, zero_advantage_share=, rollouts=, desktops_busy=, desktops_provisioned=)` buffers points sent at most once per 30 s (`PATCH /v1/runs/{id}`), and the block's end closes it (`POST /v1/runs/{id}/close`: @@ -55,22 +55,22 @@ feature falls back as described below. `client.run()` alone still returns the run's record; `get_run` and `open_run` are the explicit names. - **`drums preflight`** (#13). `drums preflight --desktops N --hours H [--model-gpus 2:6] [--task-set ID] [--json]` and `drums.preflight(...)`: gateway and console health, key validity, expiry and scopes, host capacity and - admission, rate limit (N x 0.5 requests/s, the D1 rule, `REQUESTS_PER_DESKTOP_S`), live-desktop quota, spend cap at + admission, rate limit (N x 0.5 requests/s, a rule of thumb from our training runs, `REQUESTS_PER_DESKTOP_S`), live-desktop quota, spend cap at the projected desktop-hour cost, and the task set's registration and validation. A pass/fail table with a fix and a console link per row; exit 1 on a failure (`--strict`: also on a warning or a row it could not check). Works in desktop-token mode: the exchange runs first, so a console that cannot issue a token is an auth failure (a `both` gateway on the key alone is a warning), and the console row defaults to the token URL's origin. Rate limit, quota, - spend cap, price and host admission come from `GET /v1/limits` (scope `usage:read`, Drums-Labs/drums#49); a + spend cap, price and host admission come from `GET /v1/limits` (scope `usage:read`); a gateway without it gets "not checked" on those rows. -- **MCP custom tasks** (A-08, A-09, #15). `create_computer` and `load_task` take `task_set_id` + `task_id` (a task of +- **MCP custom tasks** (#15). `create_computer` and `load_task` take `task_set_id` + `task_id` (a task of a registered set) besides `task` and `task_id`; a task document sent as a JSON string is accepted; new tools `list_task_sets` and `get_task_set` (36 tools, the gateway's tools.json); `verify` on a computer with no task says - so. Needs the gateway route `GET /v1/task-sets/{id}/tasks/{task_id}` (Drums-Labs/drums#46). + so. Needs the gateway route `GET /v1/task-sets/{id}/tasks/{task_id}`. ### CI - A `pip-audit` job on what CI installs, with an allowlist whose entries expire, and a weekly audit that opens an - issue on failure (A-40, #10). + issue on failure (#10). - The test matrix (3.9 to 3.13) runs on `ubuntu-24.04`: `ubuntu-latest` is 26.04, which has no Python 3.9 build. ## 0.3.0 - 2026-11-12 @@ -105,7 +105,7 @@ this release adds the local server and the client methods for the new gateway ro ## 0.2.5 - first release on PyPI -The first version published on PyPI, as `drums-sdk` (`pip install drums-sdk`; the import name stays `drums`). Versions 0.2.0 to 0.2.4 shipped as wheels sent with invites. +The first version published on PyPI, as `drums-sdk` (`pip install drums-sdk`; the import name stays `drums`). Versions 0.2.0 to 0.2.4 were not published. Everything below in the 0.2.x entries is included. Packaging and release: diff --git a/README.md b/README.md index b9dbc32..8b64277 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,8 @@ task's checker. Every episode carries a validity verdict, so a score from a brok This repository is the Python client for that runtime and the `drums` command. The package on PyPI is `drums-sdk`; the import name is `drums`. It uses only the standard library and supports Python 3.9 and later. It talks to Drums -Cloud (`https://beta.drums.run/gw`) or to a self-hosted `drumsd` over the same HTTP API. +Cloud (`https://beta.drums.run/gw`, the gateway for invited teams) or to a `drumsd` you run yourself, over the same HTTP +API. ## Install @@ -48,7 +49,11 @@ pip install drums-sdk ## Quickstart -Sign in at [console.drums.run](https://console.drums.run), open **API Keys** and create a key. It starts with +> **Drums Cloud is invite-only until January 2027.** [Request access](https://console.drums.run/request-access). Without an invite you can still install +> the SDK, read the API below and run the test suite (`python -m unittest`, no account needed); the tests run every +> call against a local fake server. + +With an invite, sign in at [console.drums.run](https://console.drums.run), open **API Keys** and create a key. It starts with `drums_sk_` and is shown once. Then, in a terminal: ```bash @@ -106,7 +111,7 @@ print(report.table()); assert report.ok | auth | the key is accepted, not revoked, and does not expire before the run ends; on a gateway in desktop-token mode, the console issued a token for it (`both` mode on the key alone is a warning) | | scopes | `computers:read` and `computers:write` (required; `computers:write` also opens runs); `usage:read` (warned: `GET /v1/limits` needs it) | | host capacity, admission | the bound host has N free desktops, drumsd is ok, the host takes creates and no image checkpoint is stale | -| rate limit | the per-key limit is at least N x 0.5 requests/s with a burst of N (the D1 rule: about 0.5 requests per second per active desktop, `drums._preflight.REQUESTS_PER_DESKTOP_S`) | +| rate limit | the per-key limit is at least N x 0.5 requests/s with a burst of N (a rule of thumb from our own training runs: about 0.5 requests per second per active desktop, `drums._preflight.REQUESTS_PER_DESKTOP_S`) | | quota | the workspace's live-desktop limit leaves room for N | | spend cap | spent + N x H x the desktop-hour price stays under the cap | | task set | registered for the workspace and validated on a host (oracle accepted, none rejected) | @@ -264,7 +269,7 @@ the run (task set, config hash, steps, reward, zero-advantage share, rollouts, d of anonymous computers: ```python -with client.run("qwen27b-d2", kind="training", task_set=task_set_id, config=cfg, desktops_provisioned=128) as run: +with client.run("my-grpo-run", kind="training", task_set=task_set_id, config=cfg, desktops_provisioned=128) as run: for step in range(num_steps): ... # your rollouts and optimizer step run.step(step, reward=mean_reward, zero_advantage_share=zero_adv, rollouts=n, desktops_busy=busy) diff --git a/SECURITY.md b/SECURITY.md index 0c68ad7..eb4e883 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,8 +4,8 @@ | Version | Supported | |---|---| -| 0.3.x | yes | -| 0.2.x | security fixes only, until 0.4.0 is released | +| 0.4.x | yes | +| 0.3.x | security fixes only | | earlier | no | The SDK uses only the Python standard library and has no runtime dependencies. Upgrade with `pip install -U drums-sdk`. diff --git a/drums/__init__.py b/drums/__init__.py index c6e4d30..a7bc08d 100644 --- a/drums/__init__.py +++ b/drums/__init__.py @@ -63,7 +63,11 @@ from .runs import Run, RunNotSupported __version__ = "0.4.0" -DEFAULT_URL = os.environ.get("DRUMS_URL") or os.environ.get("DRUMSD_URL") or "http://127.0.0.1:7070" +LOCAL_URL = "http://127.0.0.1:7070" +DEFAULT_URL = os.environ.get("DRUMS_URL") or os.environ.get("DRUMSD_URL") or LOCAL_URL +_NO_SERVER_HINT = ("no server answers at " + LOCAL_URL + " and DRUMS_URL is not set. Set DRUMS_URL to your gateway " + "(Drums Cloud: https://beta.drums.run/gw, invite-only until January 2027, request access at " + "https://console.drums.run/request-access) or start a drumsd on this machine") DEFAULT_IMAGE = "osworld-ubuntu" __all__ = ["ActionFailed", "connect", "Client", "Env", "Reward", "Observation", "StepResult", "State", "ForkResult", "env", "__version__", @@ -473,6 +477,10 @@ def __init__(self, url: str = DEFAULT_URL, token: str | None = None, timeout: fl self._cred = _Credentials(self.token) # API key -> desktop token exchange when the gateway asks for it self._owned: dict[str, None] = {} # ids of envs this client created and has not closed (insertion order) self._owned_lock = threading.Lock() + # Nobody chose a server: the URL is the loopback default and no env var named one. If nothing answers there on + # the very first request, say so at once instead of retrying a daemon the user may not have. + self._implicit_local = self.url == LOCAL_URL and not (os.environ.get("DRUMS_URL") or os.environ.get("DRUMSD_URL")) + self._answered = False self._runs: list = [] # open Run objects, innermost last: creates carry its label self.close_on_exit = close_on_exit if close_on_exit: @@ -591,8 +599,10 @@ def call(self, method: str, path: str, body=None, raw: bool = False, timeout: fl try: with self._opener.open(req, timeout=timeout or self.timeout) as r: b = r.read() + self._answered = True return b if raw else json.loads(b or b"null") except urllib.error.HTTPError as e: + self._answered = True text = e.read().decode(errors="replace") try: body_j = json.loads(text) @@ -637,6 +647,8 @@ def call(self, method: str, path: str, body=None, raw: bool = False, timeout: fl continue raise CertificateError(_origin_text(self.url), str(getattr(e, "reason", e)), "certifi's bundle could not verify it either" if self._certifi else _CERT_HINT) from None + if self._implicit_local and not self._answered and isinstance(getattr(e, "reason", e), ConnectionRefusedError): + raise DaemonUnavailable(0, _NO_SERVER_HINT) from None if time.monotonic() >= deadline: what = "the outcome is unknown; call env.refresh()" if method != "GET" else f"retried for {self.retry_s:.0f} s" raise DaemonUnavailable(0, f"drumsd at {self.url} unreachable on {method} {path} ({what}): {getattr(e, 'reason', e)}") from None diff --git a/drums/_preflight.py b/drums/_preflight.py index d6ff4ac..f725123 100644 --- a/drums/_preflight.py +++ b/drums/_preflight.py @@ -1,5 +1,5 @@ """`drums preflight` / `drums.preflight(...)`: before any GPU is paid for, check that the gateway, the key and the -workspace can carry N desktops for H hours. Every block of the D1 run (rate limit, spend cap, live-desktop quota, +workspace can carry N desktops for H hours. Every block we hit in our own 128-desktop training run (rate limit, spend cap, live-desktop quota, host capacity, control-plane health, a task set nobody had validated) would have shown up here. drums preflight --desktops 128 --hours 3 --task-set 0b5c2a52-... [--model-gpus 2:6] [--json] @@ -23,7 +23,7 @@ spend cap spent this period + N x H x the desktop-hour price <= the cap task set (with --task-set) registered for this workspace, and validated (oracle accepted, none rejected) -The rate limit, quota, spend cap and price come from `GET /v1/limits` (scope usage:read; Drums-Labs/drums#49, shape +The rate limit, quota, spend cap and price come from `GET /v1/limits` (scope usage:read; shape in `_limits_view`). On a gateway that does not serve it yet, those rows say "not checked" and why, and `--desktop-hour-usd` supplies the price for the projection. A row that could not be checked never fails the preflight; `--strict` does. @@ -40,7 +40,7 @@ from .errors import AuthError, DrumsError, NotFound -#: D1 rule of thumb (2026-11-16, 128 desktops on Qwen3.5-27B): each ACTIVE desktop costs about one action and one +#: Rule of thumb from our 128-desktop GRPO run on Qwen3.5-27B (2026-11-16): each ACTIVE desktop costs about one action and one #: screenshot per turn every few seconds through the gateway, about 0.5 requests per second (128 desktops needed about #: 60 req/s). A run of N desktops needs a per-key rate of at least N x this. REQUESTS_PER_DESKTOP_S = 0.5 @@ -50,7 +50,7 @@ #: The gateway's default per-key limit (RATE_LIMIT_PER_S / RATE_LIMIT_BURST unset): a pilot setting. DEFAULT_RATE_PER_S, DEFAULT_RATE_BURST = 20, 60 REQUIRED_SCOPES = ("computers:read", "computers:write") -#: runs:write is not wanted: the gateway opens trainer runs with computers:write too (Drums-Labs/drums#41) +#: runs:write is not wanted: the gateway opens trainer runs with computers:write too WANTED_SCOPES = {"usage:read": "usage and cost reads (and GET /v1/limits, so the quota and spend rows) are refused"} #: /v1/health slower than this is a warning, ten times slower a failure (the 2026-11-16 outage answered in 10 to 90 s) HEALTH_SLOW_S = 2.0 @@ -147,7 +147,7 @@ def _num(d, *keys): def _limits_view(doc) -> dict: - """The fields preflight reads from `GET /v1/limits` (served by Drums-Labs/drums#49; any of them may be missing, + """The fields preflight reads from `GET /v1/limits` (any of them may be missing, and the gateway's extra fields are ignored): {"workspace": {"max_live_computers", "live_computers", "max_spend_usd", "spent_usd", "period_end", @@ -272,7 +272,7 @@ def preflight(desktops: int, hours: float, *, model_gpus=None, task_set: str | N add(Check("gateway", PASS, f"{client.url} answers (auth mode {token_mode or 'token'})")) if isinstance(token_err, AuthError): add(Check("auth", FAIL, f"the console refused the key when asked for a desktop token: {token_err.message}", - "create a key (or check DRUMS_TOKEN has no stray space or newline)", links.page("api-keys", "API keys"))) + "create a key (or check DRUMS_TOKEN has no stray space or newline); no account? Drums Cloud is invite-only until January 2027: request access at https://console.drums.run/request-access", links.page("api-keys", "API keys"))) else: add(Check("auth", FAIL, f"no desktop token: {token_err.message}", "this gateway takes desktop tokens only; the console must answer to issue one: wait, or report it", @@ -295,7 +295,7 @@ def preflight(desktops: int, hours: float, *, model_gpus=None, task_set: str | N except AuthError as e: add(Check("gateway", PASS, f"{client.url} answers")) add(Check("auth", FAIL, f"the key was refused: {e.message}", - "create a key (or check DRUMS_TOKEN has no stray space or newline)", links.page("api-keys", "API keys"))) + "create a key (or check DRUMS_TOKEN has no stray space or newline); no account? Drums Cloud is invite-only until January 2027: request access at https://console.drums.run/request-access", links.page("api-keys", "API keys"))) return _finish(desktops, hours, checks, need, gpus, gpu_hour_usd, check_console, console, timeout) except DrumsError as e: if e.status == 403: @@ -518,7 +518,7 @@ def _finish(desktops, hours, checks, need, gpus, gpu_hour_usd, check_console, co gpu_usd = gpus["total"] * hours * float(gpu_hour_usd) need["projected_gpu_usd"] = round(gpu_usd, 2) detail += f"; projected {gpu_usd:,.2f} USD at {gpu_hour_usd:g} USD per GPU-hour" - detail += (". In D1 (Qwen3.5-27B, 2 inference + 6 trainer GPUs) the trainer kept 36 to 47 of 128 desktops in " + detail += (". In our 128-desktop run (Qwen3.5-27B, 2 inference + 6 trainer GPUs) the trainer kept 36 to 47 of 128 desktops in " "flight; size N to what your trainer keeps in flight") checks.append(Check("model GPUs", INFO, detail)) return PreflightReport(desktops, hours, checks, need) diff --git a/drums/errors.py b/drums/errors.py index c198eca..44e773b 100644 --- a/drums/errors.py +++ b/drums/errors.py @@ -9,13 +9,18 @@ class DrumsError(Exception): retry_after = None def __init__(self, status: int, message: str, body=None): - super().__init__(f"drumsd HTTP {status}: {message}" if status else message) + super().__init__(f"server HTTP {status}: {message}" if status else message) self.status, self.message, self.body = status, message, body class AuthError(DrumsError): """401: missing or wrong token.""" + HINT = "no key yet? Drums Cloud is invite-only until January 2027: request access at https://console.drums.run/request-access" + + def __str__(self) -> str: + return f"{super().__str__()} ({self.HINT})" + class InsecureTransport(DrumsError): """Refused before any request: a token would travel over plain HTTP to a host that is not loopback. The message diff --git a/drums/mcp.py b/drums/mcp.py index 4568e5e..ed08a2d 100644 --- a/drums/mcp.py +++ b/drums/mcp.py @@ -358,7 +358,7 @@ def verify(self, a): try: r = env.verify(strict=False) except BadRequest as e: - # drumsd answers 400 to a verify with no task (or a task without an OSWorld checker): say which (A-08) + # drumsd answers 400 to a verify with no task (or a task without an OSWorld checker): say which if e.status != 400: raise try: diff --git a/drums/runs.py b/drums/runs.py index 6870775..cd6e5a1 100644 --- a/drums/runs.py +++ b/drums/runs.py @@ -1,8 +1,8 @@ """The run object: a training (or evaluation) run the SDK opens, feeds and closes, so the console's Runs page can show it (task set, config hash, step counter, reward, zero-advantage share, rollouts, desktops busy, cost) instead of a -list of anonymous computers (audit A-36). +list of anonymous computers . - with client.run("qwen27b-d2", kind="training", task_set=task_set_id, config=cfg) as run: + with client.run("my-grpo-run", kind="training", task_set=task_set_id, config=cfg) as run: for step in range(steps): ... run.step(step, reward=mean_reward, zero_advantage_share=zero_adv, rollouts=n, desktops_busy=busy) diff --git a/tests/test_onboarding.py b/tests/test_onboarding.py new file mode 100644 index 0000000..b88e895 --- /dev/null +++ b/tests/test_onboarding.py @@ -0,0 +1,51 @@ +"""What a newcomer sees with no server configured and with no key. Localhost only, no network.""" +import os +import socket +import time +import unittest +from unittest import mock + +import drums +from drums.errors import AuthError, DaemonUnavailable + + +def closed_port_url() -> str: + s = socket.socket() + s.bind(("127.0.0.1", 0)) + port = s.getsockname()[1] + s.close() + return f"http://127.0.0.1:{port}" + + +class OnboardingTests(unittest.TestCase): + def test_no_server_configured_fails_fast_and_says_what_to_set(self): + url = closed_port_url() + env = {k: v for k, v in os.environ.items() if k not in ("DRUMS_URL", "DRUMSD_URL")} + with mock.patch.dict(os.environ, env, clear=True), mock.patch.object(drums, "LOCAL_URL", url): + c = drums.Client(url, None, retry_s=30) + t0 = time.monotonic() + with self.assertRaises(DaemonUnavailable) as cm: + c.health() + self.assertLess(time.monotonic() - t0, 5, "must not retry for retry_s when nobody chose a server") + self.assertIn("DRUMS_URL is not set", str(cm.exception)) + self.assertIn("request-access", str(cm.exception)) + + def test_a_server_named_in_env_is_still_retried(self): + url = closed_port_url() + with mock.patch.dict(os.environ, {"DRUMS_URL": url}), mock.patch.object(drums, "LOCAL_URL", url): + c = drums.Client(url, None, retry_s=0.6) + t0 = time.monotonic() + with self.assertRaises(DaemonUnavailable) as cm: + c.health() + self.assertGreaterEqual(time.monotonic() - t0, 0.5) + self.assertIn("unreachable", str(cm.exception)) + + def test_a_401_says_how_to_get_a_key(self): + e = AuthError(401, "missing, invalid, revoked or expired API key") + self.assertIn("server HTTP 401", str(e)) + self.assertIn("console.drums.run/request-access", str(e)) + self.assertEqual(e.message, "missing, invalid, revoked or expired API key") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_preflight.py b/tests/test_preflight.py index 5270e94..ae9c82d 100644 --- a/tests/test_preflight.py +++ b/tests/test_preflight.py @@ -259,13 +259,13 @@ def test_the_console_row_defaults_to_the_token_urls_origin(self): self.assertIn(self.url, self.row(rep, "console").detail) def test_the_limits_route_of_drums_49(self): - # the reply Drums-Labs/drums#49 serves, extra fields included + # the reply GET /v1/limits serves, extra fields included doc = {"workspace": {"id": "w", "max_live_computers": 128, "live_computers": 3, "max_spend_usd": 500, "spend_period": "month", "period_start": "2026-11-01T00:00:00.000Z", "period_end": "2026-12-01T00:00:00.000Z", "spent_usd": 41.23, "spent_age_s": 12, "used_pct": 8, "rate_limit_profile": "pilot"}, "rate_limit": {"per_s": 20, "burst": 60, "applies_to": "each API key, at this gateway"}, "price": {"desktop_hour_usd": 0.035, "source": "list_price"}, - "host": {"id": "h1", "name": "drums-rc1", "status": "active", "max_desktops": 128, "live": 3, "free": 125, + "host": {"id": "h1", "name": "host-1", "status": "active", "max_desktops": 128, "live": 3, "free": 125, "admission": "open", "creates_in_flight": 0, "max_creates_in_flight": 4, "host_mem_available_bytes": 123}, "hosts": [], "cached": True} v = pf._limits_view(doc) @@ -322,7 +322,7 @@ def test_task_set(self): c = self.row(self.pre(8, task_set="factory-v1"), "task set") # by name self.assertEqual(c.status, "pass") self.assertIn("could not be compared", c.detail) - Gw.state = {"task_set": VALID_SET, "limits": {**LIMITS, "host": {"id": "drums-rc1", "status": "active"}}} + Gw.state = {"task_set": VALID_SET, "limits": {**LIMITS, "host": {"id": "host-1", "status": "active"}}} self.assertEqual(self.row(self.pre(8, task_set=TS), "task set").status, "warn") def test_console_row(self): diff --git a/tests/test_retry_certs.py b/tests/test_retry_certs.py index 7e324bf..0dd00a0 100644 --- a/tests/test_retry_certs.py +++ b/tests/test_retry_certs.py @@ -1,5 +1,5 @@ """Retry-After on every call (429 from the gateway's rate limit or no capacity, for GET and POST alike), the retry -budget and its off switch, and the TLS fallback to certifi's CA bundle (A-07). Localhost fakes only.""" +budget and its off switch, and the TLS fallback to certifi's CA bundle. Localhost fakes only.""" import email.utils import io import json diff --git a/tests/test_runs.py b/tests/test_runs.py index 9a5b323..897bbde 100644 --- a/tests/test_runs.py +++ b/tests/test_runs.py @@ -1,4 +1,4 @@ -"""The run object (A-36): open on POST /v1/runs, buffered steps flushed at most once per flush_s by PATCH +"""The run object: open on POST /v1/runs, buffered steps flushed at most once per flush_s by PATCH /v1/runs/{id}, close on POST /v1/runs/{id}/close, the run label on creates while it is open, and a no-op with one warning against a gateway that does not have these routes yet (today's gateway answers 400 to a training body and 404 "method not allowed" to PATCH). Localhost fakes only.""" @@ -101,7 +101,7 @@ def calls(self, method, path_part): def run_obj(self, **kw): clock = Clock() - r = runs.Run(self.c, "qwen27b-d2", "training", task_set="0b5c2a52-77a0-4c0e-9a39-0a7a0f3c1d10", config={"lr": 1e-5, "k": 6}, + r = runs.Run(self.c, "my-grpo-run", "training", task_set="0b5c2a52-77a0-4c0e-9a39-0a7a0f3c1d10", config={"lr": 1e-5, "k": 6}, clock=clock, **kw) return r, clock