unicefdata 2.3.2__tar.gz → 2.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unicefdata-2.3.2/unicefdata.egg-info → unicefdata-2.4.1}/PKG-INFO +19 -1
- {unicefdata-2.3.2 → unicefdata-2.4.1}/README.md +18 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/pyproject.toml +19 -1
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_404_fallback.py +2 -2
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_dimensions.py +6 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_download.py +6 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_fallback_fix.py +8 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_pipeline_mocked.py +5 -5
- unicefdata-2.4.1/tests/test_query_status.py +194 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_transformations.py +8 -9
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/__init__.py +1 -1
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/unicefdata.py +222 -28
- {unicefdata-2.3.2 → unicefdata-2.4.1/unicefdata.egg-info}/PKG-INFO +19 -1
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata.egg-info/SOURCES.txt +1 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/LICENSE +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/setup.cfg +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_deterministic.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_direct_metadata.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_discovery.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_error_conditions.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_hardcoded_removal_validation.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_list_dataflows.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_metadata_manager.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_python_integration.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_quick_python.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_sdmx_client_dataflow.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_sync_pipeline.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/tests/test_unicef_api.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/config.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/config_loader.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/flows.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/indicator_registry.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/_unicefdata_sync_history.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/_dataflow_fallback_sequences.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_codelists.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_countries.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_dataflows.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_indicators.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_indicators_metadata.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_regions.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflow_index.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CAUSE_OF_DEATH.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CCRI.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CHILD_RELATED_SDG.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CHLD_PVTY.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_CAUSE_OF_DEATH.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_COUNTRY_PROFILES_DATA.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_DF_2021_WQ.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNATIONAL.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_AGO.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_BDI.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_BEN.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_BGD.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_CMR.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_ETH.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_GHA.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_GIN.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_HTI.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_KEN.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_LAO.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_LBR.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_LSO.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MDG.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MLI.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MMR.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MRT.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MWI.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_NAM.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_NGA.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_NPL.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_PAK.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_RWA.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_SEN.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_SLE.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_TCD.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_TGO.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_TZA.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_UGA.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_ZMB.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_ZWE.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/COVID.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/COVID_CASES.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/DM.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/DM_PROJECTIONS.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/ECD.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/ECONOMIC.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/EDUCATION.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/EDUCATION_FLS.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/EDUCATION_UIS_SDG.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/FUNCTIONAL_DIFF.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/GENDER.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/GLOBAL_DATAFLOW.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/HIV_AIDS.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/IMMUNISATION.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/MG.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/MNCH.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/NUTRITION.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT_CM.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT_CM_SUBNATIONAL.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT_CONFLICT.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT_FGM.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/SDG_PROG_ASSESSMENT.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/SOC_PROTECTION.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_HEALTHCARE_FACILITY.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_HOUSEHOLDS.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_HOUSEHOLD_MH.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_HOUSEHOLD_SUBNAT.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_SCHOOLS.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WT.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/current/unicef_indicators_metadata.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-03/codelists.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-03/dataflows.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-03/indicators.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-03/summary.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_codelists.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_countries.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_dataflows.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_indicators.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_regions.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/summary.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_codelists.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_countries.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_dataflows.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_indicators.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_regions.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/summary.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_codelists.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_countries.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_dataflows.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_indicators.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_regions.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/summary.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_codelists.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_countries.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_dataflows.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_indicators.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_regions.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/summary.yaml +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/metadata_manager.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/run_sync.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/schema_cache.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/schema_sync.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/sdmx.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/sdmx_client.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/utils.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata/yaml_formatter.py +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata.egg-info/dependency_links.txt +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata.egg-info/requires.txt +0 -0
- {unicefdata-2.3.2 → unicefdata-2.4.1}/unicefdata.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: unicefdata
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.1
|
|
4
4
|
Summary: Python library for downloading UNICEF indicators via SDMX API
|
|
5
5
|
Author-email: Joao Pedro Azevedo <jpazevedo@unicef.org>
|
|
6
6
|
License: MIT
|
|
@@ -82,6 +82,24 @@ print(unicefdata.__version__)
|
|
|
82
82
|
|
|
83
83
|
---
|
|
84
84
|
|
|
85
|
+
## What's New in 2.4.0
|
|
86
|
+
|
|
87
|
+
- **Query status codes**: Empty results now tell you *why* via `df.attrs["query_status"]`:
|
|
88
|
+
- `year_not_found` — country has data, but not for the requested year (gap in time series)
|
|
89
|
+
- `year_beyond_range` — requested year is before the earliest or after the latest data point
|
|
90
|
+
- `country_not_found` — indicator exists but not for this country (includes `available_countries`)
|
|
91
|
+
- `indicator_not_found` — indicator doesn't exist in any dataflow
|
|
92
|
+
- **Client-side year filtering**: Fixes 6 survey-based indicators (NUTRITION, MNCH, EDUCATION) that failed with year filters due to an SDMX API quirk
|
|
93
|
+
- **Smarter fallback logic**: No longer wastes API calls trying non-existent fallback dataflows when data simply doesn't exist for the requested country/year
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
df = unicefData("MNCH_CSEC", countries=["BRA"], year=2020)
|
|
97
|
+
# len(df) == 0
|
|
98
|
+
print(df.attrs["query_status"]) # "year_not_found"
|
|
99
|
+
print(df.attrs["available_years"]) # [2000, 2001, ..., 2019]
|
|
100
|
+
print(df.attrs["nearest_year"]) # 2019
|
|
101
|
+
```
|
|
102
|
+
|
|
85
103
|
## What's New in 2.2.2
|
|
86
104
|
|
|
87
105
|
- **`UNICEFSDMXClient` dataflow resolution fixed**: `fetch_indicator()` now auto-detects the correct dataflow from metadata instead of always defaulting to `GLOBAL_DATAFLOW`, consistent with `unicefData()`
|
|
@@ -41,6 +41,24 @@ print(unicefdata.__version__)
|
|
|
41
41
|
|
|
42
42
|
---
|
|
43
43
|
|
|
44
|
+
## What's New in 2.4.0
|
|
45
|
+
|
|
46
|
+
- **Query status codes**: Empty results now tell you *why* via `df.attrs["query_status"]`:
|
|
47
|
+
- `year_not_found` — country has data, but not for the requested year (gap in time series)
|
|
48
|
+
- `year_beyond_range` — requested year is before the earliest or after the latest data point
|
|
49
|
+
- `country_not_found` — indicator exists but not for this country (includes `available_countries`)
|
|
50
|
+
- `indicator_not_found` — indicator doesn't exist in any dataflow
|
|
51
|
+
- **Client-side year filtering**: Fixes 6 survey-based indicators (NUTRITION, MNCH, EDUCATION) that failed with year filters due to an SDMX API quirk
|
|
52
|
+
- **Smarter fallback logic**: No longer wastes API calls trying non-existent fallback dataflows when data simply doesn't exist for the requested country/year
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
df = unicefData("MNCH_CSEC", countries=["BRA"], year=2020)
|
|
56
|
+
# len(df) == 0
|
|
57
|
+
print(df.attrs["query_status"]) # "year_not_found"
|
|
58
|
+
print(df.attrs["available_years"]) # [2000, 2001, ..., 2019]
|
|
59
|
+
print(df.attrs["nearest_year"]) # 2019
|
|
60
|
+
```
|
|
61
|
+
|
|
44
62
|
## What's New in 2.2.2
|
|
45
63
|
|
|
46
64
|
- **`UNICEFSDMXClient` dataflow resolution fixed**: `fetch_indicator()` now auto-detects the correct dataflow from metadata instead of always defaulting to `GLOBAL_DATAFLOW`, consistent with `unicefData()`
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "unicefdata"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.4.1"
|
|
8
8
|
description = "Python library for downloading UNICEF indicators via SDMX API"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
@@ -55,3 +55,21 @@ include = ["unicefdata*"]
|
|
|
55
55
|
|
|
56
56
|
[tool.setuptools.package-data]
|
|
57
57
|
unicefdata = ["metadata/**/*.yaml"]
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
markers = [
|
|
62
|
+
"network: tests that make live HTTP calls to external APIs (deselect with -m 'not network')",
|
|
63
|
+
"slow: tests that take more than 10 seconds",
|
|
64
|
+
]
|
|
65
|
+
filterwarnings = [
|
|
66
|
+
"ignore::DeprecationWarning",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[tool.coverage.run]
|
|
70
|
+
source = ["unicefdata"]
|
|
71
|
+
omit = ["tests/*", "scripts/*"]
|
|
72
|
+
|
|
73
|
+
[tool.coverage.report]
|
|
74
|
+
show_missing = true
|
|
75
|
+
skip_empty = true
|
|
@@ -56,9 +56,9 @@ class Test404Fallback:
|
|
|
56
56
|
col in column_names
|
|
57
57
|
for col in ['iso3', 'ref_area', 'period', 'time_period', 'value', 'obs_value', 'dataflow']
|
|
58
58
|
)
|
|
59
|
-
# If we have columns, at least one should be
|
|
59
|
+
# If we have columns, at least one should be a recognized SDMX column
|
|
60
60
|
if len(df.columns) > 0:
|
|
61
|
-
assert has_standard_col
|
|
61
|
+
assert has_standard_col, f"No standard columns found in: {column_names}"
|
|
62
62
|
|
|
63
63
|
@responses.activate
|
|
64
64
|
def test_valid_indicator_after_404_still_works(self, mock_sdmx_data_endpoints):
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Converts the previous script into proper tests and expands coverage via
|
|
4
4
|
parameterization across common UNICEF dataflows.
|
|
5
|
+
|
|
6
|
+
NOTE: All tests in this module make live HTTP calls to sdmx.data.unicef.org.
|
|
7
|
+
Run with: pytest -m network
|
|
8
|
+
Skip with: pytest -m 'not network'
|
|
5
9
|
"""
|
|
6
10
|
|
|
7
11
|
import pytest
|
|
12
|
+
|
|
13
|
+
pytestmark = pytest.mark.network
|
|
8
14
|
import requests
|
|
9
15
|
import xml.etree.ElementTree as ET
|
|
10
16
|
|
|
@@ -3,10 +3,16 @@ Automated tests to verify Python can download indicators from various dataflows
|
|
|
3
3
|
after implementing the 3-tier fallback logic and simpler .INDICATOR. key pattern.
|
|
4
4
|
|
|
5
5
|
Uses golden indicators from validation/xval/golden_indicators.yaml
|
|
6
|
+
|
|
7
|
+
NOTE: All tests in this module make live HTTP calls to sdmx.data.unicef.org.
|
|
8
|
+
Run with: pytest -m network
|
|
9
|
+
Skip with: pytest -m 'not network'
|
|
6
10
|
"""
|
|
7
11
|
|
|
8
12
|
import pytest
|
|
9
13
|
|
|
14
|
+
pytestmark = pytest.mark.network
|
|
15
|
+
|
|
10
16
|
from unicefdata import unicefData
|
|
11
17
|
from unicefdata.sdmx_client import SDMXForbiddenError
|
|
12
18
|
|
|
@@ -7,9 +7,17 @@ Tests:
|
|
|
7
7
|
3. Verify that valid, non-empty data are returned for both indicators
|
|
8
8
|
|
|
9
9
|
Uses golden indicators from validation/xval/golden_indicators.yaml
|
|
10
|
+
|
|
11
|
+
NOTE: All tests in this module make live HTTP calls to sdmx.data.unicef.org.
|
|
12
|
+
Run with: pytest -m network
|
|
13
|
+
Skip with: pytest -m 'not network'
|
|
10
14
|
"""
|
|
11
15
|
|
|
12
16
|
import sys
|
|
17
|
+
|
|
18
|
+
import pytest
|
|
19
|
+
|
|
20
|
+
pytestmark = pytest.mark.network
|
|
13
21
|
import logging
|
|
14
22
|
from pathlib import Path
|
|
15
23
|
|
|
@@ -152,18 +152,18 @@ class TestPipelineMulti:
|
|
|
152
152
|
"""Unknown indicator should return empty DataFrame or raise"""
|
|
153
153
|
mock_pipeline_endpoints()
|
|
154
154
|
|
|
155
|
-
#
|
|
155
|
+
# Should either return empty DF or raise a known SDMX error
|
|
156
|
+
from unicefdata.sdmx_client import SDMXNotFoundError, SDMXError
|
|
156
157
|
try:
|
|
157
158
|
df = unicefData(
|
|
158
159
|
indicator="NONEXISTENT_INDICATOR_XYZ",
|
|
159
160
|
countries=["ALB"],
|
|
160
161
|
)
|
|
161
|
-
# If it returns,
|
|
162
|
+
# If it returns, must be empty DataFrame
|
|
162
163
|
assert isinstance(df, pd.DataFrame)
|
|
163
164
|
assert len(df) == 0
|
|
164
|
-
except
|
|
165
|
-
#
|
|
166
|
-
pass
|
|
165
|
+
except (SDMXNotFoundError, SDMXError):
|
|
166
|
+
pass # Expected: unknown indicator raises SDMX error
|
|
167
167
|
|
|
168
168
|
|
|
169
169
|
class TestPipelineColumnOrder:
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""Tests for query status codes on empty results.
|
|
2
|
+
|
|
3
|
+
Verifies that unicefData() sets df.attrs["query_status"] correctly.
|
|
4
|
+
All tests use mocked HTTP responses — no network calls.
|
|
5
|
+
|
|
6
|
+
See docs/QUERY_STATUS_CODES.md for the full spec.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
import pytest
|
|
11
|
+
import responses
|
|
12
|
+
|
|
13
|
+
import unicefdata.unicefdata as _umod
|
|
14
|
+
from unicefdata import unicefData
|
|
15
|
+
from unicefdata.sdmx_client import SDMXNotFoundError
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
BASE_URL = "https://sdmx.data.unicef.org/ws/public/sdmxapi/rest/data"
|
|
19
|
+
SDMX_ANY = re.compile(r"https://sdmx\.data\.unicef\.org/.*")
|
|
20
|
+
|
|
21
|
+
MNCH_BRA_CSV = (
|
|
22
|
+
"DATAFLOW,REF_AREA,INDICATOR,SEX,TIME_PERIOD,OBS_VALUE,UNIT_MEASURE,OBS_STATUS,DATA_SOURCE\n"
|
|
23
|
+
"MNCH,BRA,MNCH_CSEC,_T,2015,55.5,PCT,AVAILABLE,SURVEY\n"
|
|
24
|
+
"MNCH,BRA,MNCH_CSEC,_T,2016,55.6,PCT,AVAILABLE,SURVEY\n"
|
|
25
|
+
"MNCH,BRA,MNCH_CSEC,_T,2017,55.8,PCT,AVAILABLE,SURVEY\n"
|
|
26
|
+
"MNCH,BRA,MNCH_CSEC,_T,2018,56.1,PCT,AVAILABLE,SURVEY\n"
|
|
27
|
+
"MNCH,BRA,MNCH_CSEC,_T,2019,56.4,PCT,AVAILABLE,SURVEY\n"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
MNCH_BRA_GAP_CSV = (
|
|
31
|
+
"DATAFLOW,REF_AREA,INDICATOR,SEX,TIME_PERIOD,OBS_VALUE,UNIT_MEASURE,OBS_STATUS,DATA_SOURCE\n"
|
|
32
|
+
"MNCH,BRA,MNCH_CSEC,_T,2015,55.5,PCT,AVAILABLE,SURVEY\n"
|
|
33
|
+
"MNCH,BRA,MNCH_CSEC,_T,2019,56.4,PCT,AVAILABLE,SURVEY\n"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
EMPTY_CSV = "DATAFLOW,REF_AREA,INDICATOR,SEX,TIME_PERIOD,OBS_VALUE,UNIT_MEASURE,OBS_STATUS\n"
|
|
37
|
+
|
|
38
|
+
MNCH_ARG_CSV = (
|
|
39
|
+
"DATAFLOW,REF_AREA,INDICATOR,SEX,TIME_PERIOD,OBS_VALUE,UNIT_MEASURE,OBS_STATUS,DATA_SOURCE\n"
|
|
40
|
+
"MNCH,ARG,MNCH_CSEC,_T,2020,32.1,PCT,AVAILABLE,SURVEY\n"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class _FakeSync:
|
|
45
|
+
def ensure_synced(self, **kwargs):
|
|
46
|
+
return False
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _reset():
|
|
50
|
+
"""Reset module state and disable metadata sync before each test."""
|
|
51
|
+
_umod._client = None
|
|
52
|
+
_umod.MetadataSync = _FakeSync
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _mock(csv_body, url_pattern=None):
|
|
56
|
+
"""Register mocked response + catch-all 404."""
|
|
57
|
+
if url_pattern and csv_body:
|
|
58
|
+
responses.add(responses.GET, url_pattern, body=csv_body, status=200, content_type="text/csv")
|
|
59
|
+
responses.add(responses.GET, SDMX_ANY, body="Not Found", status=404)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
MNCH_PATTERN = re.compile(rf"{re.escape(BASE_URL)}/UNICEF,MNCH.*MNCH_CSEC.*")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@responses.activate
|
|
66
|
+
def test_ok():
|
|
67
|
+
_reset()
|
|
68
|
+
_mock(MNCH_BRA_CSV, MNCH_PATTERN)
|
|
69
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], dataflow="MNCH", diagnose=True)
|
|
70
|
+
assert len(df) > 0
|
|
71
|
+
assert df.attrs.get("query_status") == "ok"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@responses.activate
|
|
75
|
+
def test_year_not_found_gap():
|
|
76
|
+
_reset()
|
|
77
|
+
_mock(MNCH_BRA_GAP_CSV, MNCH_PATTERN)
|
|
78
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2017, dataflow="MNCH", diagnose=True)
|
|
79
|
+
assert len(df) == 0
|
|
80
|
+
assert df.attrs["query_status"] == "year_not_found"
|
|
81
|
+
assert 2015 in df.attrs["available_years"]
|
|
82
|
+
assert 2019 in df.attrs["available_years"]
|
|
83
|
+
assert df.attrs["nearest_year"] in (2015, 2019)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@responses.activate
|
|
87
|
+
def test_year_beyond_range_future():
|
|
88
|
+
_reset()
|
|
89
|
+
_mock(MNCH_BRA_CSV, MNCH_PATTERN)
|
|
90
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2025, dataflow="MNCH", diagnose=True)
|
|
91
|
+
assert len(df) == 0
|
|
92
|
+
assert df.attrs["query_status"] == "year_beyond_range"
|
|
93
|
+
assert df.attrs["nearest_year"] == 2019
|
|
94
|
+
assert "outside" in df.attrs["message"].lower()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@responses.activate
|
|
98
|
+
def test_year_beyond_range_past():
|
|
99
|
+
_reset()
|
|
100
|
+
_mock(MNCH_BRA_CSV, MNCH_PATTERN)
|
|
101
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2010, dataflow="MNCH", diagnose=True)
|
|
102
|
+
assert len(df) == 0
|
|
103
|
+
assert df.attrs["query_status"] == "year_beyond_range"
|
|
104
|
+
assert df.attrs["nearest_year"] == 2015
|
|
105
|
+
assert df.attrs["available_years"] == [2015, 2016, 2017, 2018, 2019]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@responses.activate
|
|
109
|
+
def test_country_not_found():
|
|
110
|
+
_reset()
|
|
111
|
+
# Both fetches return ARG-only data
|
|
112
|
+
responses.add(responses.GET, MNCH_PATTERN, body=MNCH_ARG_CSV, status=200, content_type="text/csv")
|
|
113
|
+
responses.add(responses.GET, MNCH_PATTERN, body=MNCH_ARG_CSV, status=200, content_type="text/csv")
|
|
114
|
+
responses.add(responses.GET, SDMX_ANY, body="Not Found", status=404)
|
|
115
|
+
|
|
116
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], dataflow="MNCH", diagnose=True)
|
|
117
|
+
assert len(df) == 0
|
|
118
|
+
assert df.attrs["query_status"] == "country_not_found"
|
|
119
|
+
assert "ARG" in df.attrs.get("available_countries", [])
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@responses.activate
|
|
123
|
+
def test_indicator_not_found():
|
|
124
|
+
_reset()
|
|
125
|
+
responses.add(responses.GET, SDMX_ANY, body="Not Found", status=404)
|
|
126
|
+
with pytest.raises(SDMXNotFoundError):
|
|
127
|
+
unicefData(indicator="COMPLETELY_FAKE_XYZ", countries=["BRA"], diagnose=True)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@responses.activate
|
|
131
|
+
def test_attrs_survive():
|
|
132
|
+
_reset()
|
|
133
|
+
_mock(MNCH_BRA_CSV, MNCH_PATTERN)
|
|
134
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2025, dataflow="MNCH", diagnose=True)
|
|
135
|
+
for key in ["query_status", "query_indicator", "query_countries", "available_years", "nearest_year", "message"]:
|
|
136
|
+
assert key in df.attrs, f"Missing attr: {key}"
|
|
137
|
+
assert isinstance(df.attrs["available_years"], list)
|
|
138
|
+
assert isinstance(df.attrs["message"], str)
|
|
139
|
+
assert len(df.attrs["message"]) > 0
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
@responses.activate
|
|
143
|
+
def test_year_range_beyond():
|
|
144
|
+
_reset()
|
|
145
|
+
_mock(MNCH_BRA_CSV, MNCH_PATTERN)
|
|
146
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year="2025:2028", dataflow="MNCH", diagnose=True)
|
|
147
|
+
assert len(df) == 0
|
|
148
|
+
assert df.attrs["query_status"] == "year_beyond_range"
|
|
149
|
+
assert "2025" in df.attrs["message"]
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# ---------------------------------------------------------------------------
|
|
153
|
+
# diagnose=False (default) — no status attrs, server-side filter
|
|
154
|
+
# ---------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
@responses.activate
|
|
157
|
+
def test_default_no_diagnose_returns_data():
|
|
158
|
+
"""diagnose=False with matching data → data returned, no status attrs."""
|
|
159
|
+
_reset()
|
|
160
|
+
_mock(MNCH_BRA_CSV, MNCH_PATTERN)
|
|
161
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], dataflow="MNCH")
|
|
162
|
+
assert len(df) > 0
|
|
163
|
+
# No query_status attr when diagnose=False
|
|
164
|
+
assert df.attrs.get("query_status") in ("ok", None)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@responses.activate
|
|
168
|
+
def test_default_no_diagnose_empty_no_attrs():
|
|
169
|
+
"""diagnose=False with empty result → empty DataFrame, no status attrs."""
|
|
170
|
+
_reset()
|
|
171
|
+
# Return empty CSV for any query
|
|
172
|
+
responses.add(responses.GET, MNCH_PATTERN, body=EMPTY_CSV, status=200, content_type="text/csv")
|
|
173
|
+
responses.add(responses.GET, SDMX_ANY, body="Not Found", status=404)
|
|
174
|
+
|
|
175
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2020, dataflow="MNCH")
|
|
176
|
+
assert len(df) == 0
|
|
177
|
+
# No diagnostic attrs when diagnose=False
|
|
178
|
+
assert "available_years" not in df.attrs
|
|
179
|
+
assert "nearest_year" not in df.attrs
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
@responses.activate
|
|
183
|
+
def test_default_404_with_year_retries_without():
|
|
184
|
+
"""diagnose=False: 404 with year filter → retry without → return filtered data."""
|
|
185
|
+
_reset()
|
|
186
|
+
# First call with year filter → 404 (survey dataflow quirk)
|
|
187
|
+
responses.add(responses.GET, MNCH_PATTERN, body="Not Found", status=404)
|
|
188
|
+
# Retry without year filter → returns data
|
|
189
|
+
responses.add(responses.GET, MNCH_PATTERN, body=MNCH_BRA_CSV, status=200, content_type="text/csv")
|
|
190
|
+
responses.add(responses.GET, SDMX_ANY, body="Not Found", status=404)
|
|
191
|
+
|
|
192
|
+
df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2017, dataflow="MNCH")
|
|
193
|
+
# Should have data (2017 exists in MNCH_BRA_CSV)
|
|
194
|
+
assert len(df) > 0
|
|
@@ -270,18 +270,17 @@ class TestDiscovery:
|
|
|
270
270
|
assert result is not None, "CME_MRY0T4 should resolve to a dataflow"
|
|
271
271
|
assert isinstance(result, str)
|
|
272
272
|
|
|
273
|
-
def test_get_indicator_info(self):
|
|
273
|
+
def test_get_indicator_info(self, monkeypatch):
|
|
274
274
|
"""get_indicator_info should return metadata dict."""
|
|
275
275
|
import unicefdata.indicator_registry as reg
|
|
276
276
|
|
|
277
|
-
# Pre-seed the module cache from fixture
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
reg._cache_loaded = True
|
|
277
|
+
# Pre-seed the module cache from fixture via monkeypatch (safe — auto-reverted)
|
|
278
|
+
cache_file = METADATA_FIXTURES / "unicef_indicators_metadata.yaml"
|
|
279
|
+
if cache_file.exists():
|
|
280
|
+
with open(cache_file, 'r', encoding='utf-8') as f:
|
|
281
|
+
data = yaml.safe_load(f)
|
|
282
|
+
monkeypatch.setattr(reg, '_indicator_cache', data.get('indicators', {}))
|
|
283
|
+
monkeypatch.setattr(reg, '_cache_loaded', True)
|
|
285
284
|
|
|
286
285
|
info = reg.get_indicator_info("CME_MRY0T4")
|
|
287
286
|
assert info is not None
|
|
@@ -5,7 +5,7 @@ This library provides a simplified interface for fetching child welfare and deve
|
|
|
5
5
|
indicators from UNICEF's SDMX data repository.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
__version__ = "2.
|
|
8
|
+
__version__ = "2.4.1"
|
|
9
9
|
|
|
10
10
|
def _build_user_agent() -> str:
|
|
11
11
|
"""Build a User-Agent string including package version and Python runtime."""
|