-
Notifications
You must be signed in to change notification settings - Fork 9
feat: batch-processing skill (ETL staging + jobs via inference-cli and MCP tools) #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4f6ccec
feat: batch-processing skill (ETL staging + jobs via inference-cli an…
japrescott 740c850
docs: batch-processing skill covers the master tool and webhook relay
japrescott 211fa89
Merge main into batch-processing-skill
japrescott 382c84f
docs: cover the full inference-cli lifecycle and drop the webhook relay
japrescott 9b255d1
fix: correct the job_start example and the multipart results recipe
japrescott bb2764e
docs: spell out both inference-cli auth routes
japrescott 340e8fa
docs: add a cpu-vs-gpu decision recipe for machine_type
japrescott ab852c7
Update Batch Processing skill for Asset Library jobs
stellasphere b2ff406
Clarify Batch Processing resume semantics
stellasphere 9d8d453
docs: address review feedback from Mike
japrescott 638da31
docs: fold Asset Library into one batch-processing model
japrescott 61c3b78
docs: bridge the who-stages model back to ETL/ELT terms
japrescott File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| --- | ||
| name: roboflow-batch-processing | ||
| description: Use when processing a huge number of images or videos with a Roboflow Workflow WITHOUT importing them into Roboflow — staging local or cloud files with the inference-cli, starting and monitoring batch processing jobs, downloading results, and choosing between batch processing (ETL) and datasource bucket mirroring (ELT). | ||
| --- | ||
|
|
||
| > **For agents — source-of-truth:** This skill is authored in [`roboflow/computer-vision-skills`](https://github.com/roboflow/computer-vision-skills) and shipped with the Roboflow plugin. If your client has loaded the plugin (you'll see `roboflow:<name>` skills in your available skills list), use those local skills — they're read fresh from disk every session. The same content served as MCP resources at `roboflow://skills/<name>/...` is a fallback for clients without the plugin and may lag this repo. **Don't call `ReadMcpResourceTool` for `roboflow://skills/...` URIs when a local `roboflow:<name>` skill is available.** | ||
|
|
||
| # Batch Processing | ||
|
|
||
| Run a Roboflow Workflow over a very large set of images or videos on | ||
| Roboflow's autoscaling compute, without importing anything into the | ||
| workspace. Files are staged into temporary Data Staging batches, a job | ||
| processes them, and results are exported back to staging for download. | ||
|
|
||
| ## Batch processing vs datasources (ETL vs ELT) | ||
|
|
||
| Two pipelines exist for "I have a ton of files in a bucket/on disk". Pick by | ||
| what the user wants to end up with: | ||
|
|
||
| - **Batch processing (this skill, ETL):** run a model/Workflow over the | ||
| files and get the results out. Nothing lands in the Roboflow workspace; | ||
| staged data expires after ~7 days. Best for one-off or recurring bulk | ||
| inference over local disks or cloud buckets. | ||
| - **Datasources / bucket mirror (ELT, see the `cloud-storage` skill):** | ||
| import the files INTO the workspace first for labeling, curation, and | ||
| training, then work on them inside Roboflow. | ||
|
|
||
| Rule of thumb: "process and give me the outputs" → batch processing; | ||
| "get these into Roboflow" → datasources (`connect_cloud_storage`). | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - The workspace needs the batch-processing feature. Gated calls fail with a | ||
| 402 "Batch processing is not enabled for this workspace. Upgrade your plan | ||
| or contact sales at https://roboflow.com/sales." | ||
| - Jobs consume credits; the workspace must have a positive balance. | ||
| - The Workflow must already exist in the workspace (`workflows_list`, | ||
| `workflows_create`). Jobs reference it by `workflow_id`; there is no | ||
| inline-spec option. | ||
| - API key: set `ROBOFLOW_API_KEY` in the environment (mint one with the | ||
| `api_keys_create` MCP tool). Never have the user paste a private key into | ||
| chat. | ||
|
|
||
| ## Where each step runs | ||
|
|
||
| Staging uploads run client-side with the inference-cli, on the machine that | ||
| can reach the files (local disk) or with the user's cloud credentials | ||
| (bucket sources). The MCP server cannot read the user's filesystem or cloud | ||
| credentials. Everything after staging is server-side via MCP tools: | ||
| `batch_processing_job_start`, `_job_get`, `_job_logs`, `_job_abort`, | ||
| `_job_restart`, `batch_processing_staging_*`. | ||
|
|
||
| The `batch_processing_guide` MCP tool returns this recipe plus an echo of | ||
| the arguments you pass it; it never touches files or the network. | ||
|
|
||
| ## The master tool: `batch_processing_run` | ||
|
|
||
| Prefer `batch_processing_run(batch_id, workflow_id, ...)` to drive the whole | ||
| flow. Each call inspects the current state, advances what it can, waits up | ||
| to `wait_seconds` (bounded) and returns a status: | ||
|
|
||
| - `staging_required` — no batch yet; the response contains the exact CLI | ||
| commands (already wired to a webhook relay via `--notifications-url`) and | ||
| cloud-credential env-var guidance. Run them, then call again. | ||
| - `ingest_in_progress` — files still registering; call again. | ||
| - `running` — the job was started (with the relay as its notifications URL) | ||
| or is still working; includes stage progress and relayed events. | ||
| - `completed` — includes the export batch id and the first result files with | ||
| signed download URLs. | ||
| - `failed` — includes logs and a restart hint. | ||
|
|
||
| Pass the returned `job_id` and `relay_id` back on every follow-up call to | ||
| resume; the server holds no state between calls. | ||
|
|
||
| ## Webhook events | ||
|
|
||
| Jobs and ingests can notify a webhook. `batch_processing_run` wires this | ||
| automatically to the MCP server's relay | ||
| (`/webhooks/batch-processing/<relay_id>`); the platform POSTs job | ||
| success/failure (`roboflow-batch-job-notification-v1`) and ingest-status | ||
| events there. Read them with `batch_processing_events_poll(relay_id)` | ||
| between calls, or just re-call `batch_processing_run`. Events are advisory: | ||
| confirm real state with `batch_processing_job_get`. Users with their own | ||
| webhook receiver can instead pass `notifications_url` to | ||
| `batch_processing_job_start` or `--notifications-url` on CLI commands. | ||
|
|
||
| ## 1. Install the CLI | ||
|
|
||
| ```bash | ||
| pip install inference-cli | ||
| # For s3:// gs:// az:// sources: | ||
| pip install 'inference-cli[cloud-storage]' | ||
| ``` | ||
|
|
||
| Cloud credentials are picked up from the standard env chains on the machine | ||
| running the CLI: AWS via the default credential chain (`AWS_PROFILE`, | ||
| `AWS_REGION`, `AWS_ENDPOINT_URL` honored; R2/MinIO work via | ||
| `AWS_ENDPOINT_URL`), GCS via `GOOGLE_APPLICATION_CREDENTIALS`, Azure via | ||
| `AZURE_STORAGE_ACCOUNT_NAME` plus `AZURE_STORAGE_ACCOUNT_KEY` or | ||
| `AZURE_STORAGE_SAS_TOKEN`. The CLI generates presigned URLs (24h expiry) | ||
| and hands those to Roboflow; bucket secrets never leave the machine. | ||
|
|
||
| ## 2. Stage a batch | ||
|
|
||
| Batch ids: lowercase letters, digits, `-` or `_`. Staged batches expire | ||
| after ~7 days. | ||
|
|
||
| ```bash | ||
| # Local images (>32 images are packed into tar shards automatically) | ||
| inference rf-cloud data-staging create-batch-of-images \ | ||
| --batch-id my-batch --images-dir ./images | ||
|
|
||
| # Local videos (uploaded one by one via signed URLs) | ||
| inference rf-cloud data-staging create-batch-of-videos \ | ||
| --batch-id my-batch --videos-dir ./videos | ||
|
|
||
| # Cloud bucket (S3/GCS/Azure; glob over object paths) | ||
| inference rf-cloud data-staging create-batch-of-images \ | ||
| --batch-id my-batch --data-source cloud-storage \ | ||
| --bucket-path 's3://my-bucket/images/**/*.jpg' | ||
|
|
||
| # References file: JSONL lines of {"name": ..., "url": "https://..."} | ||
| inference rf-cloud data-staging create-batch-of-images \ | ||
| --batch-id my-batch --data-source references-file --references refs.jsonl | ||
| ``` | ||
|
|
||
| Sharded, cloud-storage, and references ingests are asynchronous. Wait until | ||
| the batch is fully ingested before starting a job: poll the | ||
| `batch_processing_staging_batch_get` MCP tool (file count plus per-shard | ||
| ingest statuses), or `inference rf-cloud data-staging show-batch-details -b | ||
| my-batch` / `list-ingest-details` from the CLI. | ||
|
|
||
| Practical limits: up to 20,000 references per ingest request (auto-chunked), | ||
| ~1,000 videos per batch suggested, image formats jpg/png/webp/bmp/jp2, | ||
| video formats mp4/mov/avi/mkv/flv/wmv/m4v. | ||
|
|
||
| ## 3. Start the job | ||
|
|
||
| Prefer the MCP tool: | ||
|
|
||
| ``` | ||
| batch_processing_job_start( | ||
| batch_id="my-batch", workflow_id="my-workflow", | ||
| content_type="images", # or "videos" | ||
| machine_type="gpu", # cpu|gpu, optional | ||
| workers_per_machine=4, # 1/2/4/8, optional | ||
| aggregation_format="jsonl", # or "csv" | ||
| save_image_outputs=True, # persist crops/visualizations | ||
| max_video_fps=5, # videos only: prediction subsampling | ||
| ) | ||
| ``` | ||
|
|
||
| CLI equivalent: `inference rf-cloud batch-processing | ||
| process-images-with-workflow -b my-batch -w my-workflow -mt gpu` (or | ||
| `process-videos-with-workflow`). Same job_id + identical definition is | ||
| idempotent; a divergent definition is rejected with a 409. | ||
|
|
||
| ## 4. Monitor | ||
|
|
||
| - `batch_processing_job_get(job_id)` — status, current/planned stages, | ||
| per-stage progress, output batches; `job.isTerminal` + `job.error` are the | ||
| end states. | ||
| - `batch_processing_job_logs(job_id)` — info/error logs for diagnosis. | ||
| - `batch_processing_job_abort(job_id)` / `batch_processing_job_restart(job_id)` | ||
| — stop a run, or retry a failed one (optionally overriding machine type, | ||
| workers, timeout). | ||
|
|
||
| ## 5. Download results | ||
|
|
||
| Results land in Data Staging as platform-generated batches: | ||
| `<job-id>-processing` (raw per-shard outputs) and `<job-id>-export` | ||
| (packaged, downloadable archives). | ||
|
|
||
| - List with `batch_processing_staging_batch_files_list(batch_id="<job-id>-export")`; | ||
| entries carry signed `downloadURL`s (~24h expiry). Archives (`.tar` / | ||
| `.tar.gz`) must be unpacked after download. | ||
| - Listings are capped at 10,000 entries per call. Past that scale, download | ||
| with the CLI instead (`inference rf-cloud data-staging export-batch -b | ||
| <job-id>-export -t ./results`, resumable), or import the source data into | ||
| the workspace with datasources (ELT) and work inside Roboflow. | ||
| - Do this within 7 days: staged inputs and results expire. | ||
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.
Uh oh!
There was an error while loading. Please reload this page.