feat: add PUT /{file_id}/replace endpoint for clearing file tags#479
Merged
feat: add PUT /{file_id}/replace endpoint for clearing file tags#479
Conversation
Add new API endpoint to fully replace (not merge) file annotation tags. - Empty tag list now clears all tags (partial update kept them) - Supports both simplified and full tag formats with auto-conversion - Addresses bug where tags couldn't be deleted via empty list
There was a problem hiding this comment.
Pull request overview
This PR adds a new FastAPI endpoint to support full replacement of a dataset file’s annotation tags (including clearing tags by submitting an empty list), complementing the existing partial-merge update behavior.
Changes:
- Added
DatasetManagementService.replace_file_tags()to overwriteDatasetFiles.tagsand updatetags_updated_at. - Added
PUT /api/annotation/task/{file_id}/replaceendpoint to perform full tag replacement (supports template-based simplified→full tag conversion).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
runtime/datamate-python/app/module/dataset/service/service.py |
Adds service method to fully replace a file’s tags (with optional template-driven conversion). |
runtime/datamate-python/app/module/annotation/interface/task.py |
Adds new PUT /{file_id}/replace route that calls the service method and returns updated tags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+354
to
+356
| result = await db.execute( | ||
| select(DatasetFiles).where(DatasetFiles.id == file_id) | ||
| ) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
PUT /api/annotation/task/{file_id}/replaceto fully replace file annotation tagsProblem
The existing
PUT /{file_id}endpoint performs a partial update (merge), so passing an empty tag list[]would not clear the tags - it would just keep the existing tags unchanged.Solution
Added a new
PUT /{file_id}/replaceendpoint that performs full replacement:{"tags": []}→ clears all tagsChanges
service.pyreplace_file_tags()methodtask.pyPUT /{file_id}/replaceendpointAPI Usage