Skip to content

Give SexType/SpeciesType built from IRIs a name; allow dandischema 0.15.x - #1949

Open
yarikoptic-gitmate wants to merge 3 commits into
masterfrom
claude/gifted-gates-chiot1
Open

yarikoptic-gitmate wants to merge 3 commits into
masterfrom
claude/gifted-gates-chiot1

Conversation

@yarikoptic-gitmate

Copy link
Copy Markdown
Collaborator

Prepares dandi-cli for dandi/dandi-schema#444. That PR makes name required (and non-empty) for Contributor and for every BaseType subclass (SexType, SpeciesType, …), with schema version 0.8.1.

Changes

extract_sex (dandi/metadata/util.py)

  • When NWB subject.sex is an IRI, this produced SexType(identifier=<iri>, name=None), which would no longer validate (as noted in the review of #444).
  • It now maps the two PATO IRIs this function itself emits back to "Male"/"Female". Any other IRI is used as its own name.
  • It no longer lowercases the IRI: http://purl.obolibrary.org/obo/PATO_0000384 used to become .../pato_0000384.

extract_species

  • For an NCBITaxon IRI that is not in species_map, the name came from an ontology lookup and was None when the lookup failed (ConnectionError) or found no label.
  • It now falls back to the IRI itself.

Pin: dandischema < 0.15.0 → < 0.16.0, so that the release carrying #444 can be installed.

  • Simplify release workflow #444 keeps schema 0.8.0 as an allowed migrate() target, so the downgrades this client relies on for older Archive servers still work.
  • If maintainers prefer to bump the ceiling only once that release exists, the second commit can be dropped.

Tests

  • New tests (marked @pytest.mark.ai_generated):
    • test_extract_sex: letter codes, the PATO IRIs, and an unknown IRI.
    • test_species_unknown_iri_lookup_fails: the ontology lookup is monkeypatched to raise ConnectionError.
  • dandi/tests/test_metadata.py passes against dandischema from Simplify release workflow #444's head (166 passed, 1 skipped) and against current dandischema master (-k "sex or species": 46 passed).
  • pre-commit hooks pass.

Related: dandi/dandi-schema#442, dandi/dandi-schema#444.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NdN9xPzPo1AzsnEMuU8UQs


Generated by Claude Code

claude added 2 commits October 6, 2026 14:44
dandi/dandi-schema#444 makes `name` required for `BaseType` subclasses
(and `Contributor`).  Two code paths here could produce nameless records,
which would no longer validate:

- `extract_sex` with a sex given as an IRI produced
  `SexType(identifier=<iri>, name=None)`.  It now maps the two PATO IRIs
  this function itself emits back to "Male"/"Female", and otherwise uses
  the IRI itself as the name.  It also no longer lowercases the IRI
  (`PATO_0000384` became `pato_0000384`).
- `extract_species` for an NCBITaxon IRI not in `species_map` produced
  `SpeciesType(name=None)` when the ontology lookup failed or found no
  label.  It now falls back to the IRI itself as the name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NdN9xPzPo1AzsnEMuU8UQs
So that the release with dandi/dandi-schema#444 (required `name` for
`Contributor` and `BaseType`, schema 0.8.1) can be installed; dandischema
keeps 0.8.0 as an allowed migration target, so downgrades for older
Archive servers keep working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NdN9xPzPo1AzsnEMuU8UQs
@yarikoptic-gitmate yarikoptic-gitmate added patch Increment the patch version when merged dependencies Update one or more dependencies version labels Oct 6, 2026 — with Claude
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.93%. Comparing base (ad8f64d) to head (0778f26).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1949      +/-   ##
==========================================
+ Coverage   90.77%   90.93%   +0.16%     
==========================================
  Files          92       92              
  Lines       14130    14149      +19     
==========================================
+ Hits        12826    12867      +41     
+ Misses       1304     1282      -22     
Flag Coverage Δ
unittests 90.93% <100.00%> (+0.16%) ⬆️

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

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

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

Labels

dependencies Update one or more dependencies version patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants