Skip to content

Conversation

@CodyCBakerPhD
Copy link
Collaborator

What changed

Release Notes

This release incudes big changes to how arguments are passed in the nwb2bids API: the RunConfig object.

This class is a Pydantic model which encapsulates all previous configuration settings, such as the output BIDS directory and the additional metadata file path. This class is also now passed at time of initialization for all Converter classes and prior to calling the convert_nwb_dataset helper function. This reduces any confusion about which steps of the workflow take which arguments, and allows all internal actions to refer to the common location instead of having to manage passing values back-and-forth. It also has the added benefit of simplifying any future additions to configuration options, such as sanitization parameters.

CLI users are unaffected by these changes, aside from gaining a few new arguments - check them out with

nwb2bids convert --help

CodyCBakerPhD and others added 2 commits October 26, 2025 00:21
Reduced CodeCov spam

feat: rollback sanitization for split PR
@CodyCBakerPhD CodyCBakerPhD self-assigned this Oct 26, 2025
@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 86.41975% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.71%. Comparing base (558818f) to head (365f1ef).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
src/nwb2bids/_command_line_interface/_main.py 0.00% 13 Missing ⚠️
src/nwb2bids/_core/_validate_existing_bids.py 80.00% 5 Missing ⚠️
src/nwb2bids/_converters/_dataset_converter.py 93.54% 2 Missing ⚠️
src/nwb2bids/_core/_file_mode.py 84.61% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #164      +/-   ##
==========================================
- Coverage   87.39%   86.71%   -0.69%     
==========================================
  Files          27       32       +5     
  Lines         960     1001      +41     
==========================================
+ Hits          839      868      +29     
- Misses        121      133      +12     
Flag Coverage Δ
unittests 86.71% <86.41%> (-0.69%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/nwb2bids/__init__.py 100.00% <100.00%> (ø)
src/nwb2bids/_converters/_base_converter.py 77.77% <100.00%> (-10.23%) ⬇️
src/nwb2bids/_converters/_run_config.py 100.00% <100.00%> (ø)
src/nwb2bids/_converters/_session_converter.py 90.17% <100.00%> (ø)
src/nwb2bids/_core/_convert_nwb_dataset.py 100.00% <100.00%> (ø)
src/nwb2bids/_core/_home.py 100.00% <100.00%> (ø)
src/nwb2bids/_core/_run_id.py 100.00% <100.00%> (ø)
src/nwb2bids/bids_models/_bids_session_metadata.py 92.77% <100.00%> (ø)
src/nwb2bids/bids_models/_model_globals.py 100.00% <100.00%> (ø)
src/nwb2bids/bids_models/_participant.py 95.34% <100.00%> (ø)
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Removed release notes for version 0.6.0 and added version 0.5.1 section.
@CodyCBakerPhD
Copy link
Collaborator Author

@candleindark Some slight effects from a strange merge but cleaned up now, wouldn't worry about the remaining artifacts

… annotations

Redefine `_parent_run_directory` and
`_run_directory` of `RunConfig` as private
properties since they are computed based on
the value of a field of the model and are never
modified. Additionally, `None` type annotations
are removed from these properties for they are
really never `None`
… annotation

Set the default of `run_id` using the default factory
mechanism. This allows a more declarative definition
of the model and `model_post_init` should be reserved
for setting something that requires multi-field access.
Additionally, the `None` type annotation is removed.
`run_id` was never `None` once it was set. The `None`
value was only used as an indication of absence of
user provided value and to signal the setting of a
default. Setting the default of `run_id` using the
default factory mechanism obviates the `None` type
annotation.
…one` type annotation

Set the default of `cache_directory` using the default
factory mechanism. This allows a more declarative
definition of the model and `model_post_init` should be
reserved for setting something that requires multi-field
access. Additionally, the `None` type annotation is removed.
`cache_directory` was never `None` once it was set. The `None`
value was only used as an indication of absence of
user provided value and to signal the setting of a
default. Setting the default of `cache_directory` using the
default factory mechanism obviates the `None` type
annotation.
…ne` type annotation

Set the default of `bids_directory` using the default
factory mechanism. This allows a more declarative
definition of the model and `model_post_init` should be
reserved for setting something that requires multi-field
access. Additionally, the `None` type annotation is removed.
`bids_directory` was never `None` once it was set. The `None`
value was only used as an indication of absence of
user provided value and to signal the setting of a
default. Setting the default of `bids_directory` using the
default factory mechanism obviates the `None` type
annotation.
@CodyCBakerPhD CodyCBakerPhD changed the title Add config Added and integrated a configuration model Nov 4, 2025
…to"` value option

Set the default of `file_mode` using the default
factory mechanism. This allows a more declarative
definition of the model and `model_post_init`
should be reserved for setting something that
requires multi-field access. Additionally, the
 `"auto"` value option is removed.
`file_mode` was never `"auto"` once it was set.
The `"auto"` value was only used as an indication
of absence of user provided value and to signal
the setting of a default. Setting the default of
`file_mode` using the default factory mechanism
obviates the `"auto"` value option and allows
the type annotation of the `file_mode` field
to be consistent with the possible values
that it holds in operation.
…dator

Doing it this way makes the definition of the
model more declarative and also avoids using
`model_post_init` which should be preserved
for validations that requires access to multiple
fields of the model
Doing this allows CLI arguments to remain the same
to users while making the `RunConfig` more
succinct. For example, `RunConfig.run_id` can
now be of type `str` instead of `str | None` even
though it doesn't hold a value of `None` in
operation.
When validating a directory as a BIDS directory,
ensure it is a file instead of just ensuring its
mere existence. This rules out the situation
where `dataset_description.json` is a directory
…json file

when validating a directory as a BIDS directory
@candleindark candleindark mentioned this pull request Nov 4, 2025
Copy link
Contributor

@candleindark candleindark left a comment

Choose a reason for hiding this comment

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

Left some comments. Possible more to come.

Copy link
Contributor

@candleindark candleindark left a comment

Choose a reason for hiding this comment

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

Submitting some small changes/comments.

It should be ready once all the requests are addressed.

Comment on lines +8 to +9
Only light-weight configuration files are kept here.
Heavier contents (such as text files, logs, etc.) are stored in the cache directory.
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible adjustment to this docs string is needed because the only use of the return directory of this function is as the cache directory

cache_directory: typing.Annotated[pydantic.DirectoryPath, pydantic.Field(default_factory=_get_home_directory)]
.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, can you clarify what you mean here? This is a simple util function to reduce duplicated calls to the home path (which is used in more than one place across various incoming PRs)

Copy link
Contributor

Choose a reason for hiding this comment

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

The doc string seems to suggest that the return of this function, the home directory, is different than the cache directory. Specifically, it states that the home directory is for light-weight files, and the cache directory is for heavier contents. However, this home directory is being used as the default of the cache directory, so the home directory is the cache directory of the user doesn't specify a cache directory, contradicting what is suggested by the doc string.

Copy link
Collaborator Author

@CodyCBakerPhD CodyCBakerPhD Nov 8, 2025

Choose a reason for hiding this comment

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

The doc string seems to suggest that the return of this function, the home directory, is different than the cache directory.

It is 😊

Specifically, it states that the home directory is for light-weight files, and the cache directory is for heavier contents.

Glad the idea got across!

However, this home directory is being used as the default of the cache directory, so the home directory is the cache directory of the user doesn't specify a cache directory

Correct, there is currently there is no persistent cache directory (only what is specified at RunConfig instantiation). Was going to add that in follow-ups and make the distinction more formal. Didn't want to overwhelm an already very busy PR

If you really care we can remove this line, but it will simply be added back in very soon after

@CodyCBakerPhD
Copy link
Collaborator Author

@candleindark Ready for another round

The docstring suggestion can also be a follow-up PR if you have clear idea what you want

@candleindark
Copy link
Contributor

@candleindark Ready for another round

The docstring suggestion can also be a follow-up PR if you have clear idea what you want

I follow up about the doc string in #164 (comment). I actually don't know the exact intention. I just see a contradiction. I think it would be best to resolve it in this PR since the _get_home_directory function is introduced here.

Anyway, this PR is good to go. Including a doc string adjustment would be a plus.

@CodyCBakerPhD CodyCBakerPhD merged commit 17d9d25 into main Nov 8, 2025
25 checks passed
@CodyCBakerPhD CodyCBakerPhD deleted the add_config branch November 8, 2025 06:55
@github-project-automation github-project-automation bot moved this from In Progress to Done in nwb2bids Roadmap Nov 8, 2025
file_mode : one of "move", "copy", or "symlink"
Specifies how to handle the NWB files when converting to BIDS format.
- "move": Move the files to the BIDS directory.
- "copy": Copy the files to the BIDS directory.
Copy link
Member

Choose a reason for hiding this comment

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

note mentioning somewhere that it would be CoW if filesystem supports and Python 3.13+.

with preference for linking when possible.
cache_directory : directory path
The directory where run specific files (e.g., notifications, sanitization reports) will be stored.
Defaults to `~/.nwb2bids`.
Copy link
Member

Choose a reason for hiding this comment

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

worth making it relative and make that relative to the top of the bids directory. BIDS (validator) ignores all .dotdirs so there should be no side effect.

This would be inline with e.g. heudiconv functioning where we store metadata extracts etc, see e.g https://datasets.datalad.org/?dir=/dbic/QA (but need explicit path) -- frontend ignores .dotdirs so need to go directly into apache's index: https://datasets.datalad.org/dbic/QA/.heudiconv/ but it will be there if cloned locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor Increment the minor version when merged

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants