Conversation
NVergunst-ROBO
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
| else: | ||
| message = response.text | ||
| except Exception: # noqa: BLE001 | ||
| message = response.text |
There was a problem hiding this comment.
response.text can be huge, maybe add a truncate for max length?
| try: | ||
| result = devicesapi.list_devices(api_key, ws) | ||
| except Exception as exc: # noqa: BLE001 | ||
| output_error(args, str(exc), hint=_hint_for(exc), exit_code=_exit_code_for(exc)) |
There was a problem hiding this comment.
str(exc) on some requests failures can include the request URL, and the key is in the query string. Perhaps a secrets redaction would avoid accidentally printing the key in the terminal.
| output_error(args, str(exc), hint=_hint_for(exc), exit_code=_exit_code_for(exc)) | ||
| return | ||
|
|
||
| output(args, config) |
There was a problem hiding this comment.
Same as above, config can include env vars and integration secrets, maybe redact
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