You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements a new metadata capability following the port/adapter
architecture:
- StudyMetadataConfig (core/models/metadata_dto.py): config DTO with
section gates; from_metadata_layout() stub reserves the future
peh_model MetadataLayout wire.
- MetadataInterface (core/interfaces/metadata.py): generic tree-building
orchestration (link keys, variable catalogue, datasets, provenance)
over the session cache; abstract profile_column / map_data_type
primitives implemented by the adapter.
- DataFrameMetadataAdapter (adapters/metadata/): new "metadata" adapter
label; non-identifying column profile (counts only) and wire-format
dtype mapping.
- Session.create_study_metadata(...): public facade method.
- Population resolved from Study.study_entity_id_list via StudyEntity
(StudyPopulation degrades to StudyEntity in the peh model).
- LOD/LOQ control variables excluded by default; derivation lineage
(was_derived_from) walked to include enriched/aggregated observations.
- Tests: interface unit, adapter unit, Session-level, and an integration
test comparing against the notebooks/example golden tree (peh_demo
workflow).
- Docs: session-reference.md (new method + StudyMetadataConfig),
adapters.md (metadata area).
- Reject non-JSON StudyMetadataConfig.extra_provenance values and
non-str keys during tree construction with a ValueError naming the
offending field, instead of breaking json.dumps at serialization
time; cover caller-provided provenance with serialization tests.
- Classify control observable properties from the dataset schemas in
addition to the observation designs, so exclude_control_variables
still holds when an observation design is missing from the cache
(regression test drops the design from the cache).
- Calculation inputs now carry source_observation next to
source_variable, matching how execution resolves inputs
(contextual_field_reference.dataset_label is the observation id);
the unit test covers two calculations on derived observations that
share a property, each referencing its own base observation as
execution requires.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Observation-specific calculations can be misattributed, and accepted numeric subclasses can break YAML serialization.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Normalize numeric subclasses in extra provenance
src/pypeh/core/interfaces/metadata.py:150
An IntEnum in extra_provenance passes _check_json_value as an integer, but this fallback returns it unchanged. That violates the documented builtin-only output contract and prevents yaml.safe_dump from serializing the accepted value. Normalize integer and float subclasses to builtin types, while preserving booleans.
Preserve calculation metadata per observation and property
src/pypeh/core/interfaces/metadata.py:534
When two reachable observations specify the same observable property with different calculation designs, the global seen set drops the second calculation. _datasets_section then reuses the first calculation for that property's columns in both datasets through structure_by_op, producing incorrect derivation metadata. Preserve calculation metadata per (observation_id, property_id) and use the dataset's observation context when selecting it. Add a regression test with a shared output property and different calculation designs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a new metadata capability following the port/adapter architecture: