-
Notifications
You must be signed in to change notification settings - Fork 9
Update custom license #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Replaces instance-level access to model_fields with class-level access via self.__class__.model_fields in DataverseBase methods. This ensures correct field resolution and avoids potential issues with inheritance or instance-specific modifications.
Introduces logic to update a dataset's license, supporting both predefined and custom licenses via JSON-LD metadata. Adds integration tests for custom and predefined license updates, and a fixture for minimal custom license upload.
Introduces to_json_ld and json_ld_field_names methods to License and CustomLicense classes, enabling conversion of license data to JSON-LD format and retrieval of relevant field names. This facilitates interoperability with systems using JSON-LD for metadata representation.
Eliminated unnecessary imports of the 'rich' module from uploader.py and test_dataset_update.py to clean up the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive license management functionality to the easyDataverse package, enabling users to update both custom and predefined licenses through the Dataverse semantic API. The implementation fetches dataset metadata as JSON-LD, applies license updates, and synchronizes changes back to the server.
Key Changes
- Added JSON-LD conversion methods to License and CustomLicense classes for API compatibility
- Implemented license update workflow in the uploader module with helper functions for JSON-LD metadata operations
- Enhanced dataset update functionality to support license modifications
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
easyDataverse/license.py |
Added to_json_ld and json_ld_field_names methods to License and CustomLicense classes |
easyDataverse/uploader.py |
Implemented license update functionality with JSON-LD metadata fetch/update helpers |
easyDataverse/dataset.py |
Modified update method to pass license parameter to update_dataset function |
easyDataverse/base.py |
Fixed model_fields references to use class-level access |
tests/integration/test_dataset_update.py |
Added comprehensive integration tests for license update functionality |
tests/fixtures/minimal_upload_custom_license.json |
New test fixture for custom license dataset creation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Refactored license type assertion to use tuple for isinstance. Changed generic Exception to httpx.HTTPError for failed JSON-LD metadata updates to provide more specific error handling.
Introduces the minimal_upload_custom_license pytest fixture to load data from minimal_upload_custom_license.json for tests requiring custom license uploads.
Changed comments in test_dataset_update.py to correctly indicate that the tests update the dataset license instead of the title, improving code clarity.
As discussed in #46, @qqmyers suggested updating the custom license terms using the semantic API. This PR implements the workflow, which involves fetching the metadata as JSON-LD upon update, adding the corresponding license terms, and then updating the metadata. These changes ensure that license updates are accurately reflected in the dataset metadata. Furthermore, the PR includes thorough testing with new integration tests to verify its functionality. Additionally, several internal improvements were made to enhance consistency and maintainability.
License management and JSON-LD support:
to_json_ldandjson_ld_field_namesmethods to bothLicenseandCustomLicenseclasses ineasyDataverse/license.py, enabling conversion to JSON-LD format and listing JSON-LD field names for metadata updates. [1] [2]_update_license,_fetch_json_ld_metadata, and_update_json_ld_metadatahelper functions ineasyDataverse/uploader.pyto fetch, update, and synchronize license information in JSON-LD format with the Dataverse API.update_datasetfunction to accept alicenseargument and trigger license updates via the new helpers. [1] [2] [3]Testing and fixtures:
tests/integration/test_dataset_update.pyto verify license updates for both custom and predefined licenses, ensuring proper round-trip serialization and retrieval.tests/fixtures/minimal_upload_custom_license.json.Internal consistency and code maintenance:
model_fieldsineasyDataverse/base.pyto useself.__class__.model_fieldsfor correct class-level access in attribute management and change extraction logic. [1] [2] [3]easyDataverse/license.pyandeasyDataverse/uploader.pyfor clarity and correctness. [1] [2]These changes collectively provide robust, extensible support for license management in Dataverse datasets, with reliable API integration and thorough test coverage.