Skip to content

Add persistent global configuration via python-dotenv#352

Draft
Copilot wants to merge 9 commits into
mainfrom
copilot/add-configuration-file
Draft

Add persistent global configuration via python-dotenv#352
Copilot wants to merge 9 commits into
mainfrom
copilot/add-configuration-file

Conversation

Copilot AI commented Mar 19, 2026

Copy link
Copy Markdown
Contributor
  • Add python-dotenv as a core dependency in pyproject.toml
  • Create src/nwb2bids/_core/_global_config.py with helper functions to load from .env files at global (~/.nwb2bids/.env) and local (.nwb2bids/.env in dataset directory) levels
  • Update RunConfig to support loading defaults from .env files via RunConfig.from_dotenv_files()
  • Update CLI (_main.py) to use RunConfig.from_dotenv_files() with dotenv-aware sanitization handling
  • Add unit tests in tests/unit/test_global_config.py covering dotenv loading logic and priority ordering
  • Resolve merge conflicts from main branch (new use_session_labels, probe, silent fields in RunConfig/CLI)
  • All 121 non-remote unit + CLI tests pass
Original prompt

This section details on the original issue you should resolve

<issue_title>Add configuration file</issue_title>
<issue_description>For persistent global options

This will include

  1. default number of jobs to use in parallelization
  2. default sanitization level
  3. add more here</issue_description>

Comments on the Issue (you are @copilot in this section)

@CodyCBakerPhD The start of this in-memory is in #164

Follow-up will allow setting perment global config on disk</comment_new>
<comment_new>@CodyCBakerPhD
Plan:

  • use python-dotenv package for allowing persistent (dataset-specific or system-specific; or local vs. global, in order of priority) files for the RunConfig model
  • this also allows environment variables of the specific convention of that package to be used to override items from the persistent files
  • the best source of ground truth is still the manually passed flags to the CLI or API </comment_new>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: CodyCBakerPhD <51133164+CodyCBakerPhD@users.noreply.github.com>
Copilot AI changed the title [WIP] Add configuration file for persistent global options Add persistent global configuration via python-dotenv Mar 19, 2026
Copilot AI requested a review from CodyCBakerPhD March 19, 2026 04:00
@codecov

codecov Bot commented Mar 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.10345% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.75%. Comparing base (7252b58) to head (dea88cd).

Files with missing lines Patch % Lines
src/nwb2bids/_command_line_interface/_main.py 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
+ Coverage   85.42%   85.75%   +0.32%     
==========================================
  Files          41       42       +1     
  Lines        1818     1874      +56     
==========================================
+ Hits         1553     1607      +54     
- Misses        265      267       +2     
Flag Coverage Δ
unittests 85.75% <93.10%> (+0.32%) ⬆️

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

Files with missing lines Coverage Δ
src/nwb2bids/_converters/_run_config.py 96.29% <100.00%> (+0.64%) ⬆️
src/nwb2bids/_core/_global_config.py 100.00% <100.00%> (ø)
src/nwb2bids/_command_line_interface/_main.py 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CodyCBakerPhD

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Co-authored-by: CodyCBakerPhD <51133164+CodyCBakerPhD@users.noreply.github.com>

Copilot AI commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved in 7b43fa6. The conflict in _main.py was between main's updated sanitization_config initialization (placed before run_config_kwargs) and the PR's dotenv-aware approach that only adds sanitization_config to kwargs when --sanitization flags are explicitly passed. The merge keeps the dotenv behavior while incorporating main's new use_session_labels, probe, and silent fields. All 121 non-remote tests pass.

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.

Add configuration file

2 participants