Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle reference to non-existent concept identity in SDMX-ML 2.1 #207

Merged
merged 7 commits into from
Nov 12, 2024

Conversation

khaeru
Copy link
Owner

@khaeru khaeru commented Nov 5, 2024

Closes #205.

PR checklist

  • Checks all ✅
  • Update documentation
  • Update doc/whatsnew.rst

@khaeru khaeru added enh Enhancements & new features xml SDMX-ML format reader Read file formats defined by the SDMX standards labels Nov 5, 2024
@khaeru khaeru self-assigned this Nov 5, 2024
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.94%. Comparing base (240dd89) to head (87893de).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #207      +/-   ##
==========================================
- Coverage   98.90%   97.94%   -0.97%     
==========================================
  Files          97       97              
  Lines        8051     8073      +22     
==========================================
- Hits         7963     7907      -56     
- Misses         88      166      +78     
Files with missing lines Coverage Δ
sdmx/model/common.py 99.90% <ø> (ø)
sdmx/reader/xml/v21.py 99.18% <100.00%> (-0.13%) ⬇️
sdmx/testing/__init__.py 99.35% <ø> (ø)
sdmx/tests/reader/test_reader_xml_v21.py 100.00% <100.00%> (ø)
sdmx/tests/test_sources.py 93.23% <ø> (-5.34%) ⬇️

... and 17 files with indirect coverage changes

@khaeru
Copy link
Owner Author

khaeru commented Nov 5, 2024

FYI @nicolas-graves —the added log messages and annotations are tested here:

def test_gh_205(caplog, specimen) -> None:
"""Test of https://github.com/khaeru/sdmx/issues/205."""
with specimen("INSEE/gh-205.xml") as f:
msg = sdmx.read_sdmx(f)
# Messages were logged
msg_template = "Could not resolve {cls}.concept_identity reference to ConceptScheme=FR1:CONCEPTS_INSEE(1.0) → Concept={id}"
m1 = msg_template.format(cls="TimeDimension", id="TIME_PERIOD")
m2 = msg_template.format(cls="PrimaryMeasure", id="OBS_VALUE")
assert m1 in caplog.messages
assert m2 in caplog.messages
# Access the parsed DSD
dsd = msg.structure["CNA-2014-PIB"]
# Components have annotations with expected ID and text
for component, text in (
(dsd.dimensions.get("TIME_PERIOD"), m1),
(dsd.measures.get("OBS_VALUE"), m2),
):
a = component.annotations[0]
assert "sdmx.reader.xml.v21-parse-error" == a.id
assert text == str(a.text)

@khaeru khaeru merged commit 4116706 into main Nov 12, 2024
20 checks passed
@khaeru khaeru deleted the issue/205 branch November 13, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enh Enhancements & new features reader Read file formats defined by the SDMX standards xml SDMX-ML format
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KeyError in .reader.xml.v21 with reference to non-existent Concept (INSEE)
1 participant