Skip to content

Let callers keep an annotated image out of the Dataset - #531

Open
iurisilvio wants to merge 1 commit into
mainfrom
iuri/annotate-add-to-dataset
Open

iurisilvio wants to merge 1 commit into
mainfrom
iuri/annotate-add-to-dataset

Conversation

@iurisilvio

Copy link
Copy Markdown
Contributor

What this does

POST /dataset/:id/annotate/:image adds the image to the project's Dataset unless the
request sends addToDataset=false, and save_annotation builds its URL without ever
sending that parameter:

url = f"{API_URL}/dataset/{project_url}/annotate/{image_id}?api_key={api_key}&name={name}"

So uploading an annotation for an image that is still waiting to be labeled or reviewed in
a batch pulls it out of that flow and into the Dataset, where the next dataset version picks
it up. A user hit this last week: a script annotated a batch through the SDK and 160 images
turned up in the project's Dataset with nothing approved. The Roboflow MCP server avoids it
by sending addToDataset=false explicitly; SDK callers had no equivalent.

add_to_dataset is now threaded through single_uploadProject.save_annotation
rfapi.save_annotation_save_annotation_url:

project.single_upload(
    annotation_path="labels.json",
    image_id=image_id,
    add_to_dataset=False,   # store the annotation, leave the image in its batch
)

Nothing changes for existing callers. The default is None, which omits the parameter
entirely and leaves the API's own default (add the image) in charge. Only an explicit
False/True puts addToDataset on the query string.

The endpoint's parameters are being documented on the API side in
roboflow/roboflow#16018.

Testing

TestSaveAnnotationUrl in tests/test_rfapi.py:

  • omitting add_to_dataset leaves addToDataset off the URL, so existing callers upload
    exactly what they upload today;
  • False and True each produce the matching query value;
  • it composes with jobName, prediction and overwrite.

pytest tests/ --ignore=tests/manual — 1045 passed, 1 skipped. ruff format --check,
ruff check and mypy roboflow are clean (mypy reports the same 8 pre-existing
missing-stub errors as master).

🤖 Generated with Claude Code

`POST /dataset/:id/annotate/:image` adds the image to the project's Dataset
unless the request sends `addToDataset=false`, and `save_annotation` had no way
to send it. Uploading an annotation for an image that is still waiting to be
labeled or reviewed in a batch therefore pulled it out of that flow and into the
Dataset, where the next dataset version picked it up.

`add_to_dataset` is threaded through `single_upload`, `Project.save_annotation`
and `rfapi.save_annotation`. It defaults to `None`, which omits the parameter
and leaves today's behavior untouched; `False` opts out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@iurisilvio
iurisilvio requested a review from a team September 23, 2026 14:04
@iurisilvio iurisilvio self-assigned this Sep 23, 2026

This branch has not been deployed

No deployments
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.

1 participant