Conversation
NVergunst-ROBO
previously approved these changes
May 2, 2026
|
|
||
| def list_devices(api_key: str, workspace: str) -> Dict[str, Any]: | ||
| """``GET /:workspace/devices/v2`` — returns the parsed JSON response.""" | ||
| response = requests.get(_build_url(workspace, "", api_key)) |
There was a problem hiding this comment.
These requests calls do not pass timeout=, so a slow or stuck API can hang the CLI and any SDK caller forever. A default connect/read timeout would make behaviour better
Contributor
Author
There was a problem hiding this comment.
Addressed in 7ce03eb by adding a shared DEFAULT_TIMEOUT=(10, 60) to every devicesapi requests.get/post call, plus a unit test that exercises all adapter request paths and asserts the timeout is passed.
…ice config Address @NVergunst-ROBO's review on PR #469. 1. Tighten `_sanitize_credentials` regex in roboflow/cli/_output.py to match `api_key=` values containing dashes / non-word URL-safe chars. The old pattern `[A-Za-z0-9_]+` would leak keys like `my-key-123`. Stops `requests` exceptions whose `str(exc)` echoes the request URL from leaking the api_key to stderr. 2. Cap raw response bodies at 1024 chars in `_raise_for_status` so a multi-KB HTML 500 stack trace doesn't land in `str(DeviceApiError)`. The Express default 500 handler we hit on `/events` returned ~1KB; without the cap a real backend trace could be much larger. 3. `roboflow device config` now writes a stderr advisory in interactive (text, non-quiet) mode reminding the user the config can contain env vars and integration credentials. JSON mode is intentionally untouched: the API contract is a passthrough of the Firestore config doc, and silently redacting in the SDK would corrupt round-trip use cases (backup/restore, diff, migration). Server-side parity (sanitize uniformly across UI / SDK / raw curl) is the right place for any actual redaction. Also adds three regression tests covering the redaction, the truncation, and the warning behavior in both text and JSON modes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds Python SDK + CLI bindings for the new external Deployments / Device Management API (added to the platform in roboflow/roboflow#11350 and hardened in #11441). Closes ENT-1179.
The SDK wraps every route documented in
docs/api/deployments/overview.mdon roboflow/roboflow master — 1:1, no invented surface. PATCH/config, stream commands, device delete, and fleet-groups CRUD are explicitly out of scope per the doc's "Versioning and scope" section.New surface:
Workspace.devices(),Workspace.device(id),Workspace.create_device(...)Deviceclass withconfig(),config_history(),streams(),stream(id),logs(...),telemetry(...),events(...),refresh()roboflow device {list, get, create, config, config-history, streams, stream, logs, telemetry, events}with--json, exit codes 0/1/2/3, rate-limit hintsroboflow/adapters/devicesapi.py:DeviceBadRequestError(400),DeviceAuthError(401/403),DeviceNotFoundError(404),DeviceRateLimitedError(429),DeviceApiError(5xx)Files:
roboflow/adapters/devicesapi.py(new) — HTTP layer for all 10 routesroboflow/core/device.py(new) —Devicemodelroboflow/core/workspace.py— wired indevices()/device(id)/create_device(...)roboflow/cli/handlers/device.py(new) + registration inroboflow/cli/__init__.pytests/test_device.py(new),tests/cli/test_device_handler.py(new)CLI-COMMANDS.md— quickstart entriesDependencies: none new — uses
requestsandtyperalready required by the SDK.Type of change
How has this change been tested, please provide a testcase or example of how you tested the change?
Unit tests — 33 new tests pass (
python -m unittest tests.test_device tests.cli.test_device_handler). Full repo suite: 545/545 pass. Coverage:service/severity; opaque cursor round-trip for eventsDevicemethod dispatch;Workspace.devices()/device(id)/create_deviceintegration--jsonand text output, exit-code mapping (404→3, 401→2, 429→1)Lint / type:
ruff check roboflow testsclean,ruff format --check roboflowclean,mypy roboflowclean (no new issues).Live staging validation against
api.roboflow.oneworkspacedevice-manager-demo-workspaceGET /:ws/devices/v2mappers.jsPOST /:ws/devices/v2GET /:ws/devices/v2/:idGET .../configenvironment_variables,servicesGET .../config/historyGET .../streamsGET .../streams/:sidGET .../logsGET .../telemetry?time_period=1hGET .../eventsentity_type=stream. Not an SDK bug — flagged separately.Negative cases against staging — every one mapped to the correct typed exception with the correct status code: bad
time_period(400), bad eventscursor(400), bad logsstart_time(400), unknown deviceId (404), invalid api_key (401).CLI parity verified end-to-end:
roboflow device list --json→ 96 entries;roboflow device get <id>→ human-readable text;roboflow device telemetry <id> --time-period 1h --json→ 31 buckets; 404 → exit 3; 401 → exit 2 with thedevice:readscope hint.Will the change affect Universe? If so was this change tested in universe?
No. Pure-Python SDK and CLI changes only; no Universe surface touched.
Any specific deployment considerations
Nope
Infrastructure impact
Docs
CLI-COMMANDS.md— added device commands to the quickstart and the command-groups tableDeviceclass call out thatconfig()is sensitive (may includeenvironment_variablesand integration credentials)roboflow-product-docsper the repo's CLI documentation policy