Skip to content

Conversation

@yarikoptic
Copy link
Member

Prompted by inability to understand what is going on in dandi-archive testing against dandi-cli ATM -- my suspect using old image of some kind.

@dandi/archive-maintainers may be we should adopt such construct project wide?
As all projects depend on dandi-schema, may be that is where I should move it (and may be other helpers for testing?) then?

Display versions of all project dependencies in pytest test session header, similar to how plugins are displayed. Shows packages in sorted order with their installed versions, or " missing" if declared but not installed.

Uses importlib.metadata to discover dependencies from package metadata, with fallback to key packages (dandischema, h5py, hdmf) if metadata unavailable. Fixed typing to handle None return from requires().

🤖 Generated with Claude Code

Display versions of all project dependencies in pytest test session header,
similar to how plugins are displayed. Shows packages in sorted order with
their installed versions, or " missing" if declared but not installed.

Uses importlib.metadata to discover dependencies from package metadata,
with fallback to key packages (dandischema, h5py, hdmf) if metadata
unavailable. Fixed typing to handle None return from requires().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.02%. Comparing base (a18619e) to head (7a663cf).
⚠️ Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
dandi/pytest_plugin.py 66.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1761      +/-   ##
==========================================
- Coverage   75.03%   75.02%   -0.02%     
==========================================
  Files          84       84              
  Lines       11873    11888      +15     
==========================================
+ Hits         8909     8919      +10     
- Misses       2964     2969       +5     
Flag Coverage Δ
unittests 75.02% <66.66%> (-0.02%) ⬇️

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

☔ 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.

@yarikoptic yarikoptic added the tests Add or improve existing tests label Dec 2, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds pytest header reporting of dependency versions to aid debugging test environments (e.g., mismatched images) by showing installed versions for declared project dependencies.

  • Introduces pytest_report_header hook to display dependency versions (or “missing”) in the test session header.
  • Discovers dependencies via importlib.metadata.requires("dandi") with a reasonable fallback set and sorted output for consistency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

match.group(1)
for dep in (requires("dandi") or [])
if (match := re.match(r"^([a-zA-Z0-9_-]+)", dep))
}
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The regex used to extract package names excludes dots, which are valid in PEP 508 names (e.g., "ruamel.yaml", "zope.interface"). This will incorrectly truncate such names (e.g., matching "ruamel"), leading to wrong lookups in importlib.metadata.version() and inaccurate header output. Prefer robust parsing with packaging.Requirements, e.g.:

from packaging.requirements import Requirement
name = Requirement(dep).name

If avoiding a new dependency, broaden the pattern to include dots per PEP 508, e.g. r"^([A-Za-z0-9][A-Za-z0-9._-]*)".

Copilot uses AI. Check for mistakes.
@yarikoptic yarikoptic added the release Create a release when this pr is merged label Dec 2, 2025
@yarikoptic
Copy link
Member Author

and even though it leads to hangs ATM for dandi-archive (#1762 ) since otherwise red either way -- I will mark this for release.

@yarikoptic
Copy link
Member Author

better merge

first so we get release more devel friendly (although potentially still hanging for dandi-archive as reported in #1762 )

Copy link
Member

@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.

I left a suggestion in #1761 (comment). It is opinionated, so take it or move forward without it.

@yarikoptic
Copy link
Member Author

here is how it looks now

dependencies: allensdk NOT INSTALLED, anys-0.3.1, bids-validator-deno-2.2.3, bidsschematools-1.1.3, boto3 NOT INSTALLED, click-8.1.8, click-didyoumean-0.3.1, coverage-7.12.0, dandi-0.73.2+22.ga18619e1.dirty, dandischema-0.12.1, duecredit NOT INSTALLED, etelemetry-0.3.1, fasteners-0.20, flake8 NOT INSTALLED, fscacher-0.4.4, fsspec-2025.10.0, h5py-3.15.1, hdmf-4.1.2, humanize-4.14.0, interleave-0.3.0, joblib-1.5.2, keyring-25.7.0, keyrings.alt-5.0.2, ndx-events NOT INSTALLED, ndx-hed NOT INSTALLED, numcodecs-0.15.1, nwbinspector-0.6.5, opencv-python-4.11.0.86, packaging-25.0, platformdirs-4.5.0, pre-commit NOT INSTALLED, pycryptodomex-3.23.0, pydantic-2.12.5, pynwb-3.1.2, pyout-0.8.1, pytest-9.0.1, pytest-cov-7.0.0, pytest-mock-3.15.1, pytest-rerunfailures-16.1, pytest-timeout-2.4.0, python-dateutil-2.9.0.post0, requests-2.32.5, responses-0.25.8, ruamel.yaml-0.18.16, semantic-version-2.10.0, tenacity-9.1.2, tensorstore-0.1.79, urllib3-2.5.0, vcrpy-7.0.0, yarl-1.22.0, zarr-2.18.7, zarr_checksum-0.4.7

@yarikoptic yarikoptic removed the release Create a release when this pr is merged label Dec 3, 2025
@yarikoptic
Copy link
Member Author

removing release label -- better orchestrate tomorrow.

@yarikoptic yarikoptic merged commit 7cf6ace into master Dec 3, 2025
35 of 37 checks passed
@yarikoptic yarikoptic deleted the enh-test-versions branch December 3, 2025 02:52
@github-actions
Copy link

🚀 PR was released in 0.74.0 🚀

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

Labels

released tests Add or improve existing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants