open-sdg / sdg-build

Python package to convert SDG-related data and metadata between formats
MIT License
5 stars 23 forks source link

Avoid key error when report field does not exist in indicator metadata #337

Closed brockfanning closed 1 year ago

brockfanning commented 1 year ago

Testing instructions:

This avoids an error that happens when the metadata report is used with a field that does not have any metadata. For example, the following data config:

docs_metadata_fields:
    - key: foo
      label: Foo

That would cause a build error, assuming no indicators actually have "foo" metadata. But with this PR, the build would succeed and the metadata report would have a "Foo" column that is blank.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +4.09 :tada:

Comparison is base (e04ed81) 74.70% compared to head (7daf4d4) 78.79%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## 2.2.0-dev #337 +/- ## ============================================= + Coverage 74.70% 78.79% +4.09% ============================================= Files 74 74 Lines 4606 4608 +2 ============================================= + Hits 3441 3631 +190 + Misses 1165 977 -188 ``` | [Impacted Files](https://codecov.io/gh/open-sdg/sdg-build/pull/337?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-sdg) | Coverage Δ | | |---|---|---| | [sdg/outputs/OutputSdmxMl.py](https://codecov.io/gh/open-sdg/sdg-build/pull/337?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-sdg#diff-c2RnL291dHB1dHMvT3V0cHV0U2RteE1sLnB5) | `76.92% <ø> (ø)` | | | [sdg/MetadataReportService.py](https://codecov.io/gh/open-sdg/sdg-build/pull/337?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-sdg#diff-c2RnL01ldGFkYXRhUmVwb3J0U2VydmljZS5weQ==) | `90.28% <100.00%> (+75.83%)` | :arrow_up: | ... and [3 files with indirect coverage changes](https://codecov.io/gh/open-sdg/sdg-build/pull/337/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-sdg) Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-sdg). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-sdg)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.