Skip to content

Adds support for Health-RI v2#65

Merged
agjharms merged 18 commits into
developfrom
feature/health-ri-v2-rc1-required
Jul 9, 2025
Merged

Adds support for Health-RI v2#65
agjharms merged 18 commits into
developfrom
feature/health-ri-v2-rc1-required

Conversation

@agjharms

@agjharms agjharms commented May 9, 2025

Copy link
Copy Markdown
Contributor

In this pull request:

  • Support for the required fields of the Health-RI v2 model is implemented. This is done by modifying the input xnat and adding a mapping from XNAT variables to the Health-RI v2 Sempyro classes.
  • Refactor the CLI so the input, mapping and output components get more modular.
  • Update the documentation in the form of the Readme.

Due to the change of the CLI and the upgrade to Health-RI v2, this version will be a 2.0.0 release.

This pull request uses the Health-RI v2 Sempyro classes as defined in this version of Sempyro: Health-RI/SeMPyRO#56. This is the reason the tests aren't passing.
These additions to Sempyro will most likely also be released as a 2.0.0 release.

@sourcery-ai

sourcery-ai Bot commented May 9, 2025

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This pull request implements support for the Health-RI v2 model. This was achieved by refactoring the Command Line Interface (CLI) into a modular input-mapping-output structure using chained click commands, updating the XNAT-to-Health-RI mapping logic to use Health-RI v2 Sempyro Pydantic classes, and modifying the configuration system and tests accordingly. The documentation (README) was also comprehensively updated to reflect these changes.

File-Level Changes

Change Details Files
Refactored CLI into a modular input-mapping-output structure.
  • Decomposed the main CLI command into chained subcommands for input (e.g., xnat, xnat-project), mapping (map-xnat-hriv2), and output (e.g., rdf, fdp).
  • Utilized click.Context (ctx.obj) to pass data like configuration, XNAT connection, and metadata objects between these chained commands.
src/img2catalog/cli_app.py
Updated metadata mapping to support Health-RI v2 model using new Sempyro classes.
  • Replaced map_xnat_to_healthriv1 with map_xnat_to_healthriv2 function.
  • Integrated Health-RI v2 Sempyro Pydantic classes (HRICatalog, HRIDataset, HRIVCard, HRIAgent).
  • Updated mapping logic to populate new/revised fields for Health-RI v2 (e.g., access_rights, applicable_legislation, structured contact_point, publisher, creator with mbox/homepage).
  • Upgraded sempyro dependency to version 2.0.0 or higher and bumped package version to 2.0.0.
src/img2catalog/mappings/xnat.py
pyproject.toml
src/img2catalog/__about__.py
Enhanced configuration to support Health-RI v2 fields and control private project processing.
  • Revised default and example configurations to include Health-RI v2 specific fields (e.g., applicable_legislation, access_rights, formatted_name, mbox, homepage).
  • Improved ConfigInput.update_metadata method for deep updates of nested dictionary structures from the configuration.
  • Added an include_private configuration option and corresponding logic in XNATInput to control the processing of private XNAT projects.
src/img2catalog/configmanager.py
src/img2catalog/inputs/config.py
src/img2catalog/inputs/xnat.py
src/img2catalog/const.py
tests/example-config.toml
tests/xnat_integration_test_config.toml
Overhauled test suite for new CLI, Health-RI v2 models, and added mapping-specific tests.
  • Adapted existing unit and integration tests to the new modular CLI structure and Health-RI v2 data models.
  • Introduced a new test file (test_mappings_xnat_hri_v2.py) for the Health-RI v2 mapping logic.
  • Added test cases for new functionalities, such as the include_private project handling.
  • Updated test fixtures and reference data files to align with Health-RI v2.
tests/test_inputs_xnat.py
tests/test_cliapp.py
tests/test_xnat_integration_tests.py
tests/test_mappings_xnat_hri_v2.py
tests/conftest.py
tests/references/valid_project.ttl
tests/references/xnat_integration_test-single_dataset.ttl
tests/references/xnat_integration_test.ttl
Updated README to reflect new CLI structure and Health-RI v2 support.
  • Rewrote the README to accurately describe the new modular CLI usage (input, mapping, output commands).
  • Detailed the support for the Health-RI v2 model.
  • Updated information on configuration options, authentication, and FDP integration.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@PatrickDekkerHealthRI PatrickDekkerHealthRI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why was this overwrite mechanism for private projects added ? I would expect the project should decide and not the person who runs the img2catalog tool, would optin keyword not be a better solution ?

Creator / identifier I often see [ ] so it look like a list, but in the datamodel these two have cardinality 1..1

I like your comment, it helped me to understand the code.

Comment thread src/img2catalog/cli_app.py Outdated
Comment thread src/img2catalog/cli_app.py Outdated
Comment thread src/img2catalog/configmanager.py
Comment thread src/img2catalog/configmanager.py Outdated
name = ["Example publishing institution",]
identifier = "http://www.example.com/institution#example"
identifier = ["http://www.example.com/institution#example"]
mbox = "publisher@example.com"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

mailto: ?

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.

All example emails have been prefixed with 'mailto:'

Comment thread src/img2catalog/inputs/xnat.py Outdated
Comment thread tests/example-config.toml Outdated
# Default License for datasets is "available upon reasonable request"
# I can't find that, so putting a placeholder here
license = "http://example.com/license#nolicense"
# license = "http://example.com/license#nolicense"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove ?

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.

I have removed all unused, commented out statements from the test configuration

Comment thread tests/example-config.toml Outdated
Comment thread tests/example-config.toml Outdated
Comment thread tests/example-config.toml Outdated
Comment thread tests/test_mappings_xnat_hri_v2.py
@agjharms

agjharms commented May 9, 2025

Copy link
Copy Markdown
Contributor Author

The reason to include a feature to index metadata from private projects is allow for broader use of the tool on our XNAT server. To get metadata from a private project, you will still need to have access to that project. It will not be possible to set 'include_private = true' and get the metadata from these projects without the knowledge of the data holder.

It is also still possible to set an opt-in or opt-out keyword to filter projects. This functionality still holds also for private projects.

@codecov

codecov Bot commented Jun 12, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 85.71429% with 10 lines in your changes missing coverage. Please review.

Project coverage is 93.88%. Comparing base (2624490) to head (3a60734).
Report is 23 commits behind head on develop.

Files with missing lines Patch % Lines
src/img2catalog/mappings/xnat.py 64.28% 2 Missing and 3 partials ⚠️
src/img2catalog/cli_app.py 92.10% 1 Missing and 2 partials ⚠️
src/img2catalog/inputs/config.py 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #65      +/-   ##
===========================================
- Coverage    94.65%   93.88%   -0.78%     
===========================================
  Files           10       10              
  Lines          393      425      +32     
  Branches        48       58      +10     
===========================================
+ Hits           372      399      +27     
  Misses          12       12              
- Partials         9       14       +5     

☔ View full report in Codecov by Sentry.
📢 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.

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
57 Security Hotspots
63.9% Coverage on New Code (required ≥ 80%)
38.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@PatrickDekkerHealthRI PatrickDekkerHealthRI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to me.

@agjharms agjharms merged commit 32a4f24 into develop Jul 9, 2025
17 of 20 checks passed
@agjharms agjharms deleted the feature/health-ri-v2-rc1-required branch July 9, 2025 10:37
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