Skip to content

Conventional dataset tag - #359

Open
PGijsbers wants to merge 3 commits into
mainfrom
conventional-dataset-tag
Open

Conventional dataset tag#359
PGijsbers wants to merge 3 commits into
mainfrom
conventional-dataset-tag

Conversation

@PGijsbers

@PGijsbers PGijsbers commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Add a datasets/{identifiers}/tags endpoint as a modern alternative to /data/tag.

In case where we can easily already introduce a newer style API without much overhead in development, I think we probably should do so. This would be an example of that. I wouldn't go so far as to introduce changes with significant change in functionality (such as allow multiple tags at once) since those may require additional discussion (e.g., what happens is one of those multiple tags already exists?). In this case, only the response code and body is changed, but we don't generally expect people to use the response body anyway (it was likely included in the PHP API because it was "free" in their code path since they performed the duplication check in PHP instead of at the database, and so already had fetched all tags).

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds POST /datasets/{identifier}/tags with path-based dataset identification and embedded tag input. The deprecated POST /datasets/tag endpoint delegates to the new implementation while preserving its response format. Tests cover authorization, responses, direct calls, duplicate tags, and missing datasets. Documentation describes the deprecation, migration criteria, and API modernization.

Possibly related PRs

  • openml/server-api#322: Adds database-layer handling for the integrity and duplicate-key errors mapped by the new tagging endpoint.

Suggested labels: tests, documentation

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title identifies the dataset tagging change, but it does not mention the new endpoint or migration aspect.
Description check ✅ Passed The description directly explains the new dataset tags endpoint and the intended API modernization.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch conventional-dataset-tag

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider returning a more semantically appropriate status code (e.g., 204 No Content) from the new POST /datasets/{identifier}/tags endpoint instead of 200 with a null body, since no response payload is provided.
  • The deprecated tag_dataset handler now calls the new tag_dataset_new route function directly; it would be cleaner to extract the shared tagging logic into a separate helper/service function that both endpoints call to avoid coupling between router handlers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider returning a more semantically appropriate status code (e.g., 204 No Content) from the new `POST /datasets/{identifier}/tags` endpoint instead of `200` with a `null` body, since no response payload is provided.
- The deprecated `tag_dataset` handler now calls the new `tag_dataset_new` route function directly; it would be cleaner to extract the shared tagging logic into a separate helper/service function that both endpoints call to avoid coupling between router handlers.

## Individual Comments

### Comment 1
<location path="docs/migration.md" line_range="136" />
<code_context>
+???+ warning "This endpoint is deprecated"
+
+    The new tag endpoint is `POST` `/datasets/{identifier}/tags`.
+    The dataset identifier is provided as part of the path, the tag is still provided in the body.
+    This endpoint is provided for easier migration in case the response matters to you.
+
</code_context>
<issue_to_address>
**issue (typo):** Fix the comma splice between the two independent clauses.

You can fix this by replacing the comma with "and", using a semicolon, or splitting it into two sentences.

```suggestion
    The dataset identifier is provided as part of the path and the tag is still provided in the body.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread docs/migration.md
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.64%. Comparing base (a1367c0) to head (4b5914d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #359      +/-   ##
==========================================
- Coverage   94.65%   94.64%   -0.01%     
==========================================
  Files          77       77              
  Lines        3815     3827      +12     
  Branches      248      248              
==========================================
+ Hits         3611     3622      +11     
  Misses        137      137              
- Partials       67       68       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
docs/migration.md (1)

135-137: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the replacement request body explicitly.

The new endpoint requires an embedded payload such as {"tag": "foo"}; showing this example would prevent clients from carrying over the legacy data_id field during migration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/migration.md` around lines 135 - 137, Update the migration documentation
describing the POST /datasets/{identifier}/tags endpoint to explicitly show the
replacement request body, using a payload example with the tag field such as
{"tag": "foo"} and omitting the legacy data_id field.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/migration.md`:
- Around line 135-137: Update the migration documentation describing the POST
/datasets/{identifier}/tags endpoint to explicitly show the replacement request
body, using a payload example with the tag field such as {"tag": "foo"} and
omitting the legacy data_id field.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 412be693-b754-4414-adab-161cbc1fdad6

📥 Commits

Reviewing files that changed from the base of the PR and between a1367c0 and 68f603e.

📒 Files selected for processing (4)
  • docs/migration.md
  • docs/roadmap.md
  • src/routers/datasets.py
  • tests/routers/dataset_tag_test.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/routers/datasets.py`:
- Line 112: Update test_dataset_tag_new_json to expect HTTPStatus.NO_CONTENT for
the dataset tags endpoint and verify the response body is empty, removing the
response.json() assertion because a 204 response has no JSON payload.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a321a955-6235-48ba-8df3-c59bb324983b

📥 Commits

Reviewing files that changed from the base of the PR and between 68f603e and affb186.

📒 Files selected for processing (1)
  • src/routers/datasets.py

Comment thread src/routers/datasets.py
@PGijsbers
PGijsbers force-pushed the conventional-dataset-tag branch from affb186 to fc10705 Compare July 27, 2026 10:35
@PGijsbers
PGijsbers force-pushed the conventional-dataset-tag branch from fc10705 to 4b5914d Compare July 27, 2026 13:32
)
async def test_dataset_tag_rejects_unauthorized(key: ApiKey, py_api: httpx.AsyncClient) -> None:
apikey = "" if key is None else f"?api_key={key}"
async def test_dataset_tag_requires_authorization(py_api: httpx.AsyncClient) -> None:

@PGijsbers PGijsbers Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The various variants of not authenticating correctly should be delegated to tests for the get_user_or_raise dependency. Just including the unauthenticated case in the endpoint specific test is enough to ensure that the dependency is present.

Though even that I am not entirely sure if we should include a test for. It should be easy enough to detect changes of function signature in reviews.

@PGijsbers
PGijsbers requested a review from omosola August 11, 2026 08:24
Comment thread docs/migration.md

### Datasets

#### `GET /{dataset_id}`

@omosola omosola Aug 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this meant as /datasets/{dataset_id} rather than /{dataset_id}?

/data/list/filters is specified in full below, so I'm assuming anything listed in this doc is a full path.

If that's the case, shouldn't it be /datasets/{dataset_id} and data/list/filters should also be made /datasets/list/filters with all dataset-related endpoints being under /datasets?

@omosola

omosola commented Aug 11, 2026

Copy link
Copy Markdown

I agree that this is a change that doesn't require much overhead; however, I'm still hesitant about adhoc design migrations versus a systematic decision. I believe this is something which should be decided upfront. Then we can choose if all data-relevant endpoints are /datasets/{identifier} from the beginning and use that as the implementation starting point.

My suggestion is for us to have the design conversations first and agree on a path. Happy to do that.

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.

2 participants