unicefdata 2.4.0__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.
Files changed (152) hide show
  1. {unicefdata-2.4.0/unicefdata.egg-info → unicefdata-2.4.1}/PKG-INFO +1 -1
  2. {unicefdata-2.4.0 → unicefdata-2.4.1}/pyproject.toml +1 -1
  3. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_query_status.py +55 -8
  4. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/__init__.py +1 -1
  5. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/unicefdata.py +81 -27
  6. {unicefdata-2.4.0 → unicefdata-2.4.1/unicefdata.egg-info}/PKG-INFO +1 -1
  7. {unicefdata-2.4.0 → unicefdata-2.4.1}/LICENSE +0 -0
  8. {unicefdata-2.4.0 → unicefdata-2.4.1}/README.md +0 -0
  9. {unicefdata-2.4.0 → unicefdata-2.4.1}/setup.cfg +0 -0
  10. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_404_fallback.py +0 -0
  11. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_deterministic.py +0 -0
  12. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_dimensions.py +0 -0
  13. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_direct_metadata.py +0 -0
  14. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_discovery.py +0 -0
  15. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_download.py +0 -0
  16. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_error_conditions.py +0 -0
  17. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_fallback_fix.py +0 -0
  18. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_hardcoded_removal_validation.py +0 -0
  19. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_list_dataflows.py +0 -0
  20. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_metadata_manager.py +0 -0
  21. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_pipeline_mocked.py +0 -0
  22. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_python_integration.py +0 -0
  23. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_quick_python.py +0 -0
  24. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_sdmx_client_dataflow.py +0 -0
  25. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_sync_pipeline.py +0 -0
  26. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_transformations.py +0 -0
  27. {unicefdata-2.4.0 → unicefdata-2.4.1}/tests/test_unicef_api.py +0 -0
  28. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/config.py +0 -0
  29. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/config_loader.py +0 -0
  30. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/flows.py +0 -0
  31. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/indicator_registry.py +0 -0
  32. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/_unicefdata_sync_history.yaml +0 -0
  33. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/_dataflow_fallback_sequences.yaml +0 -0
  34. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_codelists.yaml +0 -0
  35. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_countries.yaml +0 -0
  36. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_dataflows.yaml +0 -0
  37. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_indicators.yaml +0 -0
  38. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_indicators_metadata.yaml +0 -0
  39. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/_unicefdata_regions.yaml +0 -0
  40. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflow_index.yaml +0 -0
  41. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CAUSE_OF_DEATH.yaml +0 -0
  42. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CCRI.yaml +0 -0
  43. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CHILD_RELATED_SDG.yaml +0 -0
  44. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CHLD_PVTY.yaml +0 -0
  45. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME.yaml +0 -0
  46. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_CAUSE_OF_DEATH.yaml +0 -0
  47. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_COUNTRY_PROFILES_DATA.yaml +0 -0
  48. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_DF_2021_WQ.yaml +0 -0
  49. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNATIONAL.yaml +0 -0
  50. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_AGO.yaml +0 -0
  51. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_BDI.yaml +0 -0
  52. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_BEN.yaml +0 -0
  53. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_BGD.yaml +0 -0
  54. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_CMR.yaml +0 -0
  55. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_ETH.yaml +0 -0
  56. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_GHA.yaml +0 -0
  57. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_GIN.yaml +0 -0
  58. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_HTI.yaml +0 -0
  59. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_KEN.yaml +0 -0
  60. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_LAO.yaml +0 -0
  61. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_LBR.yaml +0 -0
  62. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_LSO.yaml +0 -0
  63. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MDG.yaml +0 -0
  64. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MLI.yaml +0 -0
  65. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MMR.yaml +0 -0
  66. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MRT.yaml +0 -0
  67. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MWI.yaml +0 -0
  68. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_NAM.yaml +0 -0
  69. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_NGA.yaml +0 -0
  70. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_NPL.yaml +0 -0
  71. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_PAK.yaml +0 -0
  72. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_RWA.yaml +0 -0
  73. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_SEN.yaml +0 -0
  74. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_SLE.yaml +0 -0
  75. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_TCD.yaml +0 -0
  76. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_TGO.yaml +0 -0
  77. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_TZA.yaml +0 -0
  78. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_UGA.yaml +0 -0
  79. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_ZMB.yaml +0 -0
  80. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/CME_SUBNAT_ZWE.yaml +0 -0
  81. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/COVID.yaml +0 -0
  82. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/COVID_CASES.yaml +0 -0
  83. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/DM.yaml +0 -0
  84. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/DM_PROJECTIONS.yaml +0 -0
  85. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/ECD.yaml +0 -0
  86. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/ECONOMIC.yaml +0 -0
  87. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/EDUCATION.yaml +0 -0
  88. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/EDUCATION_FLS.yaml +0 -0
  89. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/EDUCATION_UIS_SDG.yaml +0 -0
  90. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/FUNCTIONAL_DIFF.yaml +0 -0
  91. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/GENDER.yaml +0 -0
  92. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/GLOBAL_DATAFLOW.yaml +0 -0
  93. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/HIV_AIDS.yaml +0 -0
  94. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/IMMUNISATION.yaml +0 -0
  95. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/MG.yaml +0 -0
  96. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/MNCH.yaml +0 -0
  97. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/NUTRITION.yaml +0 -0
  98. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT.yaml +0 -0
  99. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT_CM.yaml +0 -0
  100. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT_CM_SUBNATIONAL.yaml +0 -0
  101. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT_CONFLICT.yaml +0 -0
  102. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/PT_FGM.yaml +0 -0
  103. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/SDG_PROG_ASSESSMENT.yaml +0 -0
  104. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/SOC_PROTECTION.yaml +0 -0
  105. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_HEALTHCARE_FACILITY.yaml +0 -0
  106. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_HOUSEHOLDS.yaml +0 -0
  107. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_HOUSEHOLD_MH.yaml +0 -0
  108. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_HOUSEHOLD_SUBNAT.yaml +0 -0
  109. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WASH_SCHOOLS.yaml +0 -0
  110. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/dataflows/WT.yaml +0 -0
  111. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/current/unicef_indicators_metadata.yaml +0 -0
  112. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-03/codelists.yaml +0 -0
  113. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-03/dataflows.yaml +0 -0
  114. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-03/indicators.yaml +0 -0
  115. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-03/summary.yaml +0 -0
  116. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_codelists.yaml +0 -0
  117. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_countries.yaml +0 -0
  118. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_dataflows.yaml +0 -0
  119. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_indicators.yaml +0 -0
  120. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_regions.yaml +0 -0
  121. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-05/summary.yaml +0 -0
  122. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_codelists.yaml +0 -0
  123. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_countries.yaml +0 -0
  124. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_dataflows.yaml +0 -0
  125. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_indicators.yaml +0 -0
  126. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_regions.yaml +0 -0
  127. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2025-12-07/summary.yaml +0 -0
  128. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_codelists.yaml +0 -0
  129. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_countries.yaml +0 -0
  130. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_dataflows.yaml +0 -0
  131. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_indicators.yaml +0 -0
  132. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_regions.yaml +0 -0
  133. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-21/summary.yaml +0 -0
  134. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_codelists.yaml +0 -0
  135. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_countries.yaml +0 -0
  136. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_dataflows.yaml +0 -0
  137. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_indicators.yaml +0 -0
  138. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_regions.yaml +0 -0
  139. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata/vintages/2026-01-25/summary.yaml +0 -0
  140. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata.py +0 -0
  141. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/metadata_manager.py +0 -0
  142. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/run_sync.py +0 -0
  143. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/schema_cache.py +0 -0
  144. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/schema_sync.py +0 -0
  145. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/sdmx.py +0 -0
  146. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/sdmx_client.py +0 -0
  147. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/utils.py +0 -0
  148. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata/yaml_formatter.py +0 -0
  149. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata.egg-info/SOURCES.txt +0 -0
  150. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata.egg-info/dependency_links.txt +0 -0
  151. {unicefdata-2.4.0 → unicefdata-2.4.1}/unicefdata.egg-info/requires.txt +0 -0
  152. {unicefdata-2.4.0 → 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.4.0
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "unicefdata"
7
- version = "2.4.0"
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"}
@@ -33,6 +33,8 @@ MNCH_BRA_GAP_CSV = (
33
33
  "MNCH,BRA,MNCH_CSEC,_T,2019,56.4,PCT,AVAILABLE,SURVEY\n"
34
34
  )
35
35
 
36
+ EMPTY_CSV = "DATAFLOW,REF_AREA,INDICATOR,SEX,TIME_PERIOD,OBS_VALUE,UNIT_MEASURE,OBS_STATUS\n"
37
+
36
38
  MNCH_ARG_CSV = (
37
39
  "DATAFLOW,REF_AREA,INDICATOR,SEX,TIME_PERIOD,OBS_VALUE,UNIT_MEASURE,OBS_STATUS,DATA_SOURCE\n"
38
40
  "MNCH,ARG,MNCH_CSEC,_T,2020,32.1,PCT,AVAILABLE,SURVEY\n"
@@ -64,7 +66,7 @@ MNCH_PATTERN = re.compile(rf"{re.escape(BASE_URL)}/UNICEF,MNCH.*MNCH_CSEC.*")
64
66
  def test_ok():
65
67
  _reset()
66
68
  _mock(MNCH_BRA_CSV, MNCH_PATTERN)
67
- df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], dataflow="MNCH")
69
+ df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], dataflow="MNCH", diagnose=True)
68
70
  assert len(df) > 0
69
71
  assert df.attrs.get("query_status") == "ok"
70
72
 
@@ -73,7 +75,7 @@ def test_ok():
73
75
  def test_year_not_found_gap():
74
76
  _reset()
75
77
  _mock(MNCH_BRA_GAP_CSV, MNCH_PATTERN)
76
- df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2017, dataflow="MNCH")
78
+ df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2017, dataflow="MNCH", diagnose=True)
77
79
  assert len(df) == 0
78
80
  assert df.attrs["query_status"] == "year_not_found"
79
81
  assert 2015 in df.attrs["available_years"]
@@ -85,7 +87,7 @@ def test_year_not_found_gap():
85
87
  def test_year_beyond_range_future():
86
88
  _reset()
87
89
  _mock(MNCH_BRA_CSV, MNCH_PATTERN)
88
- df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2025, dataflow="MNCH")
90
+ df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2025, dataflow="MNCH", diagnose=True)
89
91
  assert len(df) == 0
90
92
  assert df.attrs["query_status"] == "year_beyond_range"
91
93
  assert df.attrs["nearest_year"] == 2019
@@ -96,7 +98,7 @@ def test_year_beyond_range_future():
96
98
  def test_year_beyond_range_past():
97
99
  _reset()
98
100
  _mock(MNCH_BRA_CSV, MNCH_PATTERN)
99
- df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2010, dataflow="MNCH")
101
+ df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2010, dataflow="MNCH", diagnose=True)
100
102
  assert len(df) == 0
101
103
  assert df.attrs["query_status"] == "year_beyond_range"
102
104
  assert df.attrs["nearest_year"] == 2015
@@ -111,7 +113,7 @@ def test_country_not_found():
111
113
  responses.add(responses.GET, MNCH_PATTERN, body=MNCH_ARG_CSV, status=200, content_type="text/csv")
112
114
  responses.add(responses.GET, SDMX_ANY, body="Not Found", status=404)
113
115
 
114
- df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], dataflow="MNCH")
116
+ df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], dataflow="MNCH", diagnose=True)
115
117
  assert len(df) == 0
116
118
  assert df.attrs["query_status"] == "country_not_found"
117
119
  assert "ARG" in df.attrs.get("available_countries", [])
@@ -122,14 +124,14 @@ def test_indicator_not_found():
122
124
  _reset()
123
125
  responses.add(responses.GET, SDMX_ANY, body="Not Found", status=404)
124
126
  with pytest.raises(SDMXNotFoundError):
125
- unicefData(indicator="COMPLETELY_FAKE_XYZ", countries=["BRA"])
127
+ unicefData(indicator="COMPLETELY_FAKE_XYZ", countries=["BRA"], diagnose=True)
126
128
 
127
129
 
128
130
  @responses.activate
129
131
  def test_attrs_survive():
130
132
  _reset()
131
133
  _mock(MNCH_BRA_CSV, MNCH_PATTERN)
132
- df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2025, dataflow="MNCH")
134
+ df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year=2025, dataflow="MNCH", diagnose=True)
133
135
  for key in ["query_status", "query_indicator", "query_countries", "available_years", "nearest_year", "message"]:
134
136
  assert key in df.attrs, f"Missing attr: {key}"
135
137
  assert isinstance(df.attrs["available_years"], list)
@@ -141,7 +143,52 @@ def test_attrs_survive():
141
143
  def test_year_range_beyond():
142
144
  _reset()
143
145
  _mock(MNCH_BRA_CSV, MNCH_PATTERN)
144
- df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year="2025:2028", dataflow="MNCH")
146
+ df = unicefData(indicator="MNCH_CSEC", countries=["BRA"], year="2025:2028", dataflow="MNCH", diagnose=True)
145
147
  assert len(df) == 0
146
148
  assert df.attrs["query_status"] == "year_beyond_range"
147
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
@@ -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.4.0"
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."""
@@ -395,6 +395,7 @@ def _fetch_indicator_with_fallback(
395
395
  max_retries: int = 3,
396
396
  tidy: bool = True,
397
397
  totals: bool = False,
398
+ diagnose: bool = False,
398
399
  ) -> pd.DataFrame:
399
400
  """
400
401
  Fetch indicator data with automatic dataflow fallback on 404 errors.
@@ -503,32 +504,38 @@ def _fetch_indicator_with_fallback(
503
504
  _logger.info(f"Trying fallback dataflow '{df_attempt}'...")
504
505
 
505
506
  try:
506
- # Fetch WITHOUT year filter to get all available data.
507
- # Year filtering is done client-side to:
508
- # 1. Avoid SDMX API 404 quirk on survey dataflows (NUTRITION, MNCH, EDUCATION)
509
- # 2. Enable query_status classification (country_not_found vs year_not_found)
507
+ # diagnose=True: fetch WITHOUT year filter, filter client-side.
508
+ # Avoids SDMX API 404 quirk on survey dataflows and enables
509
+ # query_status classification (available_years, nearest_year).
510
+ # diagnose=False: pass year filters to the API (server-side).
511
+ # Faster — downloads only matching data, but no diagnostics.
512
+ fetch_start = start_year if not diagnose else None
513
+ fetch_end = end_year if not diagnose else None
510
514
  df = client.fetch_indicator(
511
515
  indicator_code=indicator_code,
512
516
  countries=countries,
513
- start_year=None,
514
- end_year=None,
517
+ start_year=fetch_start,
518
+ end_year=fetch_end,
515
519
  dataflow=df_attempt,
516
520
  sex_disaggregation=sex,
517
- totals=False,
521
+ totals=totals,
518
522
  max_retries=max_retries,
519
523
  return_raw=not tidy,
520
524
  )
521
525
 
522
- if df.empty:
523
- # Dataflow returned 200 but 0 rows for these countries.
524
- # Don't try fallbacks — the dataflow exists, data just
525
- # isn't available for these countries.
526
+ if df.empty and not diagnose:
527
+ # Without diagnose: empty result, no classification.
528
+ # Don't try fallbacks if data was fetched with year filter —
529
+ # the dataflow may exist but not for this country+year.
530
+ if not (start_year or end_year):
531
+ # No year filter was used, so this is a true empty
532
+ continue # try next dataflow
533
+ return pd.DataFrame()
534
+
535
+ if df.empty and diagnose:
536
+ # With diagnose: classify why the result is empty.
526
537
  empty = pd.DataFrame()
527
538
  all_countries = set()
528
- # Probe API without country filter to discover which countries
529
- # have data. This downloads the full indicator dataset (can be
530
- # large for CME ~65K rows). No lighter alternative exists in
531
- # the SDMX API — there is no availability/summary endpoint.
532
539
  try:
533
540
  df_probe = client.fetch_indicator(
534
541
  indicator_code=indicator_code,
@@ -547,11 +554,15 @@ def _fetch_indicator_with_fallback(
547
554
  except Exception:
548
555
  pass
549
556
 
557
+ # Common attrs for all empty statuses
558
+ empty.attrs["query_indicator"] = indicator_code
559
+ empty.attrs["query_countries"] = countries or []
560
+ if start_year or end_year:
561
+ empty.attrs["query_year"] = start_year or end_year
562
+
550
563
  if all_countries:
551
564
  sample = sorted(all_countries)[:20]
552
565
  empty.attrs["query_status"] = "country_not_found"
553
- empty.attrs["query_indicator"] = indicator_code
554
- empty.attrs["query_countries"] = countries or []
555
566
  empty.attrs["available_countries"] = sample
556
567
  empty.attrs["message"] = (
557
568
  f"No data for {countries} for indicator '{indicator_code}'. "
@@ -561,21 +572,18 @@ def _fetch_indicator_with_fallback(
561
572
  _logger.info(empty.attrs["message"])
562
573
  else:
563
574
  empty.attrs["query_status"] = "indicator_not_found"
564
- empty.attrs["query_indicator"] = indicator_code
565
575
  empty.attrs["message"] = (
566
576
  f"Indicator '{indicator_code}' returned no data from "
567
577
  f"dataflow '{df_attempt}'."
568
578
  )
569
579
  return empty
570
580
 
571
- # Data found — apply year filter client-side
572
- if start_year or end_year:
581
+ # diagnose=True: apply year filter client-side
582
+ if diagnose and (start_year or end_year):
573
583
  period_col = 'period' if 'period' in df.columns else 'TIME_PERIOD'
574
584
  if period_col in df.columns:
575
585
  df_pre_filter = df.copy()
576
586
 
577
- # Coerce period to numeric year for robust comparison
578
- # Handles both tidy (float) and raw (string '2020' or '2020-01')
579
587
  years = pd.to_numeric(
580
588
  df[period_col].astype(str).str.slice(0, 4),
581
589
  errors="coerce",
@@ -588,7 +596,6 @@ def _fetch_indicator_with_fallback(
588
596
  df = df[mask]
589
597
 
590
598
  if df.empty:
591
- # Country has data but not for the requested year(s)
592
599
  years_pre = pd.to_numeric(
593
600
  df_pre_filter[period_col].astype(str).str.slice(0, 4),
594
601
  errors="coerce",
@@ -598,7 +605,6 @@ def _fetch_indicator_with_fallback(
598
605
  min_year = min(avail_years) if avail_years else None
599
606
  max_year = max(avail_years) if avail_years else None
600
607
 
601
- # Handle year range queries
602
608
  if start_year and end_year and start_year != end_year:
603
609
  target = (start_year + end_year) // 2
604
610
  year_desc = f"{start_year}-{end_year}"
@@ -608,7 +614,6 @@ def _fetch_indicator_with_fallback(
608
614
 
609
615
  nearest = min(avail_years, key=lambda y: abs(y - target)) if avail_years else None
610
616
 
611
- # Distinguish: gap year vs beyond all available data
612
617
  if avail_years and (target > max_year or target < min_year):
613
618
  df.attrs["query_status"] = "year_beyond_range"
614
619
  df.attrs["message"] = (
@@ -642,6 +647,46 @@ def _fetch_indicator_with_fallback(
642
647
  return df
643
648
 
644
649
  except SDMXNotFoundError as e:
650
+ # diagnose=False with year filters: the SDMX API returns 404 for
651
+ # valid survey-based indicators when the specific country+year has
652
+ # no data. Retry once without year filters before giving up.
653
+ if not diagnose and (start_year or end_year) and fetch_start is not None:
654
+ _logger.info(
655
+ f"404 with year filter on '{df_attempt}' — retrying without "
656
+ f"period params (survey dataflow quirk)"
657
+ )
658
+ try:
659
+ df = client.fetch_indicator(
660
+ indicator_code=indicator_code,
661
+ countries=countries,
662
+ start_year=None,
663
+ end_year=None,
664
+ dataflow=df_attempt,
665
+ sex_disaggregation=sex,
666
+ totals=totals,
667
+ max_retries=1,
668
+ return_raw=not tidy,
669
+ )
670
+ if not df.empty:
671
+ # Data exists — year filter was the problem.
672
+ # Filter client-side and return.
673
+ period_col = 'period' if 'period' in df.columns else 'TIME_PERIOD'
674
+ if period_col in df.columns:
675
+ years = pd.to_numeric(
676
+ df[period_col].astype(str).str.slice(0, 4),
677
+ errors="coerce",
678
+ )
679
+ mask = pd.Series(True, index=df.index)
680
+ if start_year:
681
+ mask &= years >= start_year
682
+ if end_year:
683
+ mask &= years <= end_year
684
+ df = df[mask]
685
+ df.attrs["query_status"] = "ok" if not df.empty else "year_not_found"
686
+ return df
687
+ except Exception:
688
+ pass # Fall through to normal fallback logic
689
+
645
690
  last_error = e
646
691
  if df_attempt != dataflows_to_try[-1]:
647
692
  _logger.debug(
@@ -684,6 +729,7 @@ def _fetch_with_fallback(
684
729
  max_retries: int = 3,
685
730
  tidy: bool = True,
686
731
  totals: bool = False,
732
+ diagnose: bool = False,
687
733
  ) -> pd.DataFrame:
688
734
  """
689
735
  Fetch multiple indicators using get_sdmx() with fallback logic.
@@ -723,6 +769,7 @@ def _fetch_with_fallback(
723
769
  sex=sex,
724
770
  max_retries=max_retries,
725
771
  tidy=tidy,
772
+ diagnose=diagnose,
726
773
  )
727
774
  if not df.empty:
728
775
  dfs.append(df)
@@ -781,6 +828,7 @@ def unicefData(
781
828
  mrv: Optional[int] = None,
782
829
  raw: bool = False,
783
830
  ignore_duplicates: bool = False,
831
+ diagnose: bool = False,
784
832
  ) -> pd.DataFrame:
785
833
  """
786
834
  Fetch UNICEF indicator data from SDMX API.
@@ -845,9 +893,14 @@ def unicefData(
845
893
  mrv: Most Recent Value(s). Keep only the N most recent years per country.
846
894
  Example: mrv=1 is equivalent to latest=True, mrv=3 keeps last 3 years.
847
895
  ignore_duplicates: If False (default), raises an error when exact duplicate
848
- rows are found (all column values identical). Set to True to allow
896
+ rows are found (all column values identical). Set to True to allow
849
897
  automatic removal of duplicates.
850
-
898
+ diagnose: If True, fetch all data without year filter and classify
899
+ empty results via df.attrs["query_status"]. Enables available_years,
900
+ nearest_year, and message metadata. Slower (downloads full dataset).
901
+ If False (default), pass year filter to API (faster, no diagnostics).
902
+ MCP tools should set diagnose=True for structured error reporting.
903
+
851
904
  Returns:
852
905
  pandas.DataFrame with columns (varies by options):
853
906
  - indicator_code: Indicator code
@@ -990,6 +1043,7 @@ def unicefData(
990
1043
  totals=totals,
991
1044
  max_retries=max_retries,
992
1045
  tidy=not raw,
1046
+ diagnose=diagnose,
993
1047
  )
994
1048
 
995
1049
  print("")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unicefdata
3
- Version: 2.4.0
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
File without changes
File without changes
File without changes