Skip to content

feat: add vision events SDK and CLI support#451

Open
rvirani1 wants to merge 10 commits intomainfrom
ENT-1082
Open

feat: add vision events SDK and CLI support#451
rvirani1 wants to merge 10 commits intomainfrom
ENT-1082

Conversation

@rvirani1
Copy link
Copy Markdown

@rvirani1 rvirani1 commented Apr 10, 2026

Description

  • Adds SDK support for the vision events API: write single/batch events, query with pagination, list use cases, and upload images
  • Adds roboflow vision-events CLI command group with subcommands: write, write-batch, query, use-cases, upload-image
  • Thin-client design with no client-side validation, so new event types and fields work without an SDK release
  • 21 unit tests covering all endpoints, pagination, passthrough integrity, filter forwarding, and error handling

Fixes ENT-1082

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

Locally. 21 new unit tests + full suite (396 tests), ruff, mypy all pass.

Will the change affect Universe? If so was this change tested in universe?

N/A

Any specific deployment considerations

None

Docs

  • Docs updated? What were the changes:

CLI commands and SDK methods need to be documented in roboflow-product-docs (docs.roboflow.com).

rvirani1 and others added 3 commits April 9, 2026 22:42
Adds a thin-client adapter for the vision events API with no client-side
validation, so new event types and fields work without SDK releases.
Includes SDK methods on Workspace, typer CLI commands, and 21 tests.

Endpoints: write, write-batch, query, list use cases, upload image.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds get_custom_metadata_schema to the adapter, get_vision_event_metadata_schema
to Workspace, and "roboflow vision-events metadata-schema" CLI command.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
renzon
renzon previously approved these changes Apr 10, 2026
Copy link
Copy Markdown

@renzon renzon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual E2E Test Results — Vision Events SDK & CLI

Tested against local dev server (localapi.roboflow.one) with workspace renzo-sandbox and a manually created use case (jEYfHQY5Ib1EjW4imyBT).

SDK Results (all pass ✅)

Method Result
write_vision_event Created event, created: true, no warnings
write_vision_events_batch Created 5 events in one call (minor eventData warnings on non-quality_check types)
upload_vision_event_image Got sourceId + GCS URL; with --name and --metadata
Write event with uploaded image Created event referencing sourceId from upload
query_vision_events Found 7 events across 4 types
query_vision_events (filtered) Correctly filtered to 1 safety_alert event
get_vision_event_metadata_schema Discovered 3 custom fields: camera_id, line, shift
list_vision_event_use_cases Listed the use case with correct id, name, status

CLI Results (all pass ✅)

Command Exit Code Result
vision-events write '{...}' 0 Created event
vision-events write-batch '[...]' 0 Created 2 events
vision-events query <use-case> (text mode) 0 Listed all 10 events with types
vision-events query <use-case> -t quality_check -l 2 --json 0 Filtered + paginated correctly (hasMore: true, nextCursor present)
vision-events use-cases --json 0 Listed the use case
vision-events metadata-schema <use-case> --json 0 Showed 4 discovered fields
vision-events upload-image <path> --json 0 Uploaded real JPEG, got sourceId

Result on UI:

image

Caveat: Use Case (Solution) must be created manually

To run these tests, I had to create the use case (Solution) through the Vision Events UI (/renzo-sandbox/vision-events → "+ Create Use Case"). The SDK and CLI don't expose Solution CRUD — the create/update/archive/unarchive endpoints exist on the server (/query/vision-events/{workspace}/solutions) and are used by the frontend, but they're not included in this PR.

Question: Is this intentional — i.e., use cases are meant to be managed only through the UI? Or should we also add Solution CRUD to the SDK/CLI (create-use-case, update-use-case, archive-use-case, etc.) so users can fully manage the lifecycle programmatically?

Publishes a second PyPI package "roboflow-slim" from the same codebase
with only lightweight dependencies (no opencv, numpy, matplotlib, Pillow).
Supports vision events, workspace management, auth, and CLI.

- Guard heavy imports (Project, Workspace, models) with try/except
- Make image_utils a lazy import in rfapi.upload_image
- Move PIL import into two_stage/two_stage_ocr methods
- Add requirements-slim.txt, setup_slim.py, publish-slim CI job
- Add test-slim CI job and slim compat tests

pip install roboflow is completely unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rvirani1 and others added 6 commits April 14, 2026 14:08
The test-slim CI job fails because test_vision_events.py imports
Workspace which pulls in PIL via its import chain. Fix by catching
ImportError in _make_workspace() and skipping, plus adding adapter-level
tests that work without Workspace for slim coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move all heavy imports in workspace.py (Project, folderparser, PIL,
active_learning_utils, image_utils, model_processor, two_stage_utils)
to lazy imports inside the methods that use them. Workspace now imports
cleanly without PIL/opencv, so vision events, search, folders, and
workflows all work in slim installs.

Update test mock paths to match the new import locations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Addresses CodeQL warning about unrestricted GITHUB_TOKEN permissions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants