Skip to content

Add POST /tasks/tag#350

Open
PGijsbers wants to merge 7 commits into
mainfrom
post-tag
Open

Add POST /tasks/tag#350
PGijsbers wants to merge 7 commits into
mainfrom
post-tag

Conversation

@PGijsbers

Copy link
Copy Markdown
Contributor

Closes #26.

Description

Adds an endpoint for tagging a task.
Also refactors the /datasets/tag endpoint tests to be less dependent on database state.

Checklist

Please check all that apply. You can mark items as N/A if they don't apply to your change.

Always:

  • I have performed a self-review of my own pull request to ensure it contains all relevant information, and the proposed changes are minimal but sufficient to accomplish their task.

Required for code changes:

  • Tests pass locally
  • I have commented my code in hard-to-understand areas, and provided or updated docstrings as needed
  • Changes are already covered under existing tests
  • I have added tests that cover the changes (only required if not already under coverage)

If applicable:

  • I have made corresponding changes to the documentation pages (/docs)

Extra context:

  • This PR and the commits have been created autonomously by a bot/agent.

nb. If tests pass locally but fail on CI, please try to investigate the cause. If you are unable to resolve the issue, please share your findings.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@PGijsbers, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 48 minutes and 21 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bcff988a-7142-4170-90ce-d1776ca70370

📥 Commits

Reviewing files that changed from the base of the PR and between 25992b2 and 0396bca.

📒 Files selected for processing (3)
  • tests/constants.py
  • tests/routers/openml/dataset_tag_test.py
  • tests/routers/openml/task_tag_test.py

Walkthrough

Adds task-tag persistence and error mapping in the database layer, exposes a POST /tasks/tag route that returns updated task tags, and expands shared test fixtures plus tag behavior tests for tasks and datasets.

Possibly related PRs

  • openml/server-api#290: Shares the dataset-tag test area; this PR only adds mut markers, while the current PR rewrites tagging tests and adds task-tag behavior.

Suggested labels

tests, POST

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Title check ✅ Passed The title clearly names the main change: adding the POST /tasks/tag endpoint.
Description check ✅ Passed The description matches the PR by stating it adds a task-tagging endpoint and refactors dataset tag tests.
Linked Issues check ✅ Passed The PR implements the directly linked #26 objective by adding the task-tagging POST endpoint.
Out of Scope Changes check ✅ Passed The extra test and fixture changes align with the stated task-tag endpoint and tag-test refactor scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch post-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 left some high level feedback:

  • The new TaskFactory/DatasetFactory fixtures always insert with a fixed default ID (42_000), which can easily lead to primary key collisions if they are called more than once per test; consider generating unique IDs (e.g. via a counter or random range) to make the fixture safer to reuse.
  • The TaskNotFoundError mapping in tag_task uses a hard-coded numeric error code (472) which is then duplicated in tests; centralizing this code in a shared constant would reduce the risk of future mismatches.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new TaskFactory/DatasetFactory fixtures always insert with a fixed default ID (42_000), which can easily lead to primary key collisions if they are called more than once per test; consider generating unique IDs (e.g. via a counter or random range) to make the fixture safer to reuse.
- The `TaskNotFoundError` mapping in `tag_task` uses a hard-coded numeric error code (472) which is then duplicated in tests; centralizing this code in a shared constant would reduce the risk of future mismatches.

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.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.06173% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.09%. Comparing base (c88d9fc) to head (0396bca).

Files with missing lines Patch % Lines
tests/routers/openml/tag_test_helper.py 84.21% 4 Missing and 2 partials ⚠️
src/database/tasks.py 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #350      +/-   ##
==========================================
+ Coverage   95.00%   95.09%   +0.09%     
==========================================
  Files          72       74       +2     
  Lines        3580     3693     +113     
  Branches      243      245       +2     
==========================================
+ Hits         3401     3512     +111     
- Misses        115      116       +1     
- Partials       64       65       +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 (3)
tests/routers/openml/tag_test_helper.py (2)

50-51: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Redundant status check.

already_tagged (lines 27-30) is only True when php_response.status_code == INTERNAL_SERVER_ERROR, so the extra status comparison on line 51 is always satisfied and can be dropped for clarity.

♻️ Simplify the condition
-    if php_response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR and already_tagged:
+    if already_tagged:
🤖 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 `@tests/routers/openml/tag_test_helper.py` around lines 50 - 51, The condition
in the tag conflict handling helper is redundant because already_tagged is only
true when php_response.status_code is INTERNAL_SERVER_ERROR. Simplify the check
in the tag_test_helper flow by removing the extra status comparison and relying
on already_tagged alone, keeping the logic around the php_response handling and
the helper’s conflict detection clear and easier to read.

32-33: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Comment typo: "taskbase".

These comments read "persist this change to the taskbase" / "committed to the taskbase", which looks like a stray word (likely "database").

📝 Suggested wording
-        # undo the tag, because we don't want to persist this change to the taskbase
-        # Sometimes a change is already committed to the taskbase even if an error occurs.
+        # undo the tag, because we don't want to persist this change to the database
+        # Sometimes a change is already committed to the database even if an error occurs.
🤖 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 `@tests/routers/openml/tag_test_helper.py` around lines 32 - 33, The comments
in tag_test_helper.py use the stray word “taskbase” in the undo/persistence
note. Update those nearby comments to use the intended term consistently, likely
“database,” and keep the wording aligned with the surrounding logic in the tag
helper comments.
tests/routers/openml/task_tag_test.py (1)

90-98: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Parity test parametrizes task_id with dataset-specific constants.

constants.SOME_DEACTIVATED_DATASET_ID and constants.DATASET_ID_THAT_DOES_NOT_EXIST are dataset identifiers used here as task_id values. They function as arbitrary integers for PHP/Python parity, but the names imply dataset semantics and obscure the intent (existing vs. non-existing task). Consider task-oriented constants or inline literals with explanatory ids.

🤖 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 `@tests/routers/openml/task_tag_test.py` around lines 90 - 98, The parity test
in task_tag_test.py is using dataset-named constants as task_id inputs, which
obscures the intent of the parametrization. Update the task_id cases in the
parametrized test near the task_id fixture to use task-oriented identifiers or
explicit integer literals with clear naming/comments, so it is obvious which
values represent existing versus non-existing tasks. Keep the change localized
to the test data setup around the pytest.mark.parametrize block.
🤖 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 `@tests/routers/openml/tag_test_helper.py`:
- Around line 50-51: The condition in the tag conflict handling helper is
redundant because already_tagged is only true when php_response.status_code is
INTERNAL_SERVER_ERROR. Simplify the check in the tag_test_helper flow by
removing the extra status comparison and relying on already_tagged alone,
keeping the logic around the php_response handling and the helper’s conflict
detection clear and easier to read.
- Around line 32-33: The comments in tag_test_helper.py use the stray word
“taskbase” in the undo/persistence note. Update those nearby comments to use the
intended term consistently, likely “database,” and keep the wording aligned with
the surrounding logic in the tag helper comments.

In `@tests/routers/openml/task_tag_test.py`:
- Around line 90-98: The parity test in task_tag_test.py is using dataset-named
constants as task_id inputs, which obscures the intent of the parametrization.
Update the task_id cases in the parametrized test near the task_id fixture to
use task-oriented identifiers or explicit integer literals with clear
naming/comments, so it is obvious which values represent existing versus
non-existing tasks. Keep the change localized to the test data setup around the
pytest.mark.parametrize block.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ad0693cf-3d9d-4aaf-b625-05ed55d0c9eb

📥 Commits

Reviewing files that changed from the base of the PR and between c88d9fc and 25992b2.

📒 Files selected for processing (6)
  • src/database/tasks.py
  • src/routers/openml/tasks.py
  • tests/conftest.py
  • tests/routers/openml/dataset_tag_test.py
  • tests/routers/openml/tag_test_helper.py
  • tests/routers/openml/task_tag_test.py

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.

POST /task/tag

1 participant