Closed PGijsbers closed 1 week ago
This pull request modifies the dataset tagging functionality to consistently return tags as a list, refactors error handling, and updates related tests. The changes primarily affect the tag_dataset function in the datasets.py file and corresponding test files.
sequenceDiagram
actor User
participant DatasetTagging
participant Database
participant ErrorFactory
User->>DatasetTagging: Request to tag dataset
DatasetTagging->>Database: Get existing tags
Database-->>DatasetTagging: Return tags
DatasetTagging->>ErrorFactory: Check if tag exists
ErrorFactory-->>DatasetTagging: Return error if exists
DatasetTagging->>ErrorFactory: Check user authentication
ErrorFactory-->>DatasetTagging: Return error if authentication fails
DatasetTagging->>Database: Tag dataset
DatasetTagging-->>User: Return updated tag list
classDiagram
class DatasetTagging {
+tag_dataset(data_id, tag, user, expdb_db) dict
}
class HTTPException {
+status_code: HTTPStatus
+detail: dict
}
class ErrorFactory {
+create_authentication_failed_error() HTTPException
+create_tag_exists_error(data_id, tag) HTTPException
}
DatasetTagging --> HTTPException
DatasetTagging --> ErrorFactory
ErrorFactory --> HTTPException
Change | Details | Files |
---|---|---|
Modify tag_dataset function to always return tags as a list |
|
src/routers/openml/datasets.py |
Refactor error handling in tag_dataset function |
|
src/routers/openml/datasets.py |
Update dataset tagging tests to accommodate new list format |
|
tests/routers/openml/migration/datasets_migration_test.py tests/routers/openml/dataset_tag_test.py |
Attention: Patch coverage is 95.45455%
with 1 line
in your changes missing coverage. Please review.
Please upload report for BASE (
main@e23f74b
). Learn more about missing BASE report.
Files with missing lines | Patch % | Lines |
---|---|---|
...outers/openml/migration/datasets_migration_test.py | 83.33% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The tag element is now always a list, regardless of the number of elements.
TODO: Update migration documentation.
Summary by Sourcery
Ensure the tag element is always returned as a list in the dataset tagging API, refactor error handling with helper functions, and update tests to reflect these changes.
Enhancements:
Tests: