Skip to content

fix: emit number_of_cases as a JSON integer instead of source text - #139

Merged
SkyeAv merged 1 commit into
mainfrom
type-errors
Sep 4, 2026
Merged

fix: emit number_of_cases as a JSON integer instead of source text#139
SkyeAv merged 1 commit into
mainfrom
type-errors

Conversation

@SkyeAv

@SkyeAv SkyeAv commented Sep 4, 2026

Copy link
Copy Markdown
Owner

FAERS/DailyMed applied_to_treat edges shipped number_of_cases as a raw TSV string ("1") even though biolink-model types the slot int — the numeric coercion machinery simply missed the slot. This widens numeric_columns() so the count leaves the pipeline as a real JSON integer, matching the slot's model typing and the Rust merge path.

Fixes

  • Missed slot: fix: leave number_of_cases alone instead of coercing it to study_size #119's STUDY_SIZE_EXEMPT_PATTERN stopped number_of_cases being renamed onto study_size, but nothing ever cast its values — the raw TSV cell ("1") rode through as String onto the edge NDJSON. numeric_columns()' exact set now includes number_of_cases, so it rides the same clean_numeric / format_numeric machinery as study_size.
  • Model-driven typing: biolink.numeric_slot_kind("number_of_cases") reads the int typing off the installed model (EntityToDiseaseAssociation / EntityToPhenotypicFeatureAssociation), so format_numeric emits real Int64; fractional, negative, and non-numeric counts become null, exactly like study counts.
  • Validation silence: validate_kgx never flagged this because Pydantic's lax validation coerces "1"1 for the int-ranged slot, while the Rust uuid_on_collision: merge recompute already wrote a real int — leaving the shipped KG type-inconsistent edge to edge. Now uniform.

Compatibility

  • drop_low_number_of_cases unchanged: the release-mode filter already cast inline to Float64, so it works on either dtype.
  • DAKP needs no change: its TSV contract erases dtypes by design, and its test_faers_case_count_rides_the_edge_as_number_of_cases accepts int | str and anticipated this fix. Follow-up: tighten that test to require int after this release.

Testing

  • uv run pytest -q1164 passed, 44 skipped (full gate env: --group dev --extra qc --extra log + maturin develop).
  • uv run ruff check . / uv run ruff format --check . / uv run pyright → all clean.
  • New test_format_numeric_emits_number_of_cases_as_int: "1"/"25"1/25 as Int64; "0.42"/"-3"/"abc"/null → null.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: b0ec7cb5-3d8c-4095-b77c-bed5c3e647af


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@SkyeAv
SkyeAv merged commit 27b7167 into main Sep 4, 2026
5 checks passed
@SkyeAv
SkyeAv deleted the type-errors branch September 4, 2026 20:27
SkyeAv added a commit that referenced this pull request Sep 4, 2026
Cut 16.6.2 and bump the package version in pyproject.toml, uv.lock, and
CITATION.cff.

Patch: two fix PRs ship. `number_of_cases` is now emitted as a JSON
integer instead of raw source text — the slot is typed `int` on
biolink-model but sat outside `lib.numeric_columns`, so string cells
shipped on the edge NDJSON and left the graph type-inconsistent edge to
edge (#139). `--release` builds no longer reuse section parquets cached
by other build modes: `--head`, `--release`, and `--qc` now cache under
distinct suffixes via `_section_store_path`, closing a cache-poisoning
bug where release filters were silently skipped and `applied_to_treat`
edges with `number_of_cases < 25` shipped (#140). The release-mode
`drop_low_number_of_cases` and `drop_zero_effect_size` filters also
tolerate non-numeric cells (e.g. a TSV header row read as data) instead
of crashing with `InvalidOperationError` (#140).

Changelog:
- Versioned the Unreleased section as 16.6.2 and gave the
  `number_of_cases` entry its missing PR link (#139).

Docs: none needed here — #140's `cli.py` change is an internal cache-key
helper and #139 changes emission types only; both are fully documented
in their changelog entries.

Testing:
- uv run pytest -q -> 1253 passed, 3 skipped (96% coverage)
- uv run ruff check . && uv run ruff format --check . && uv run pyright -> clean / 0 errors
- uv lock --check -> up to date
- uv run mkdocs build --strict -> clean
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.

1 participant