sdmxlib 0.76.2__tar.gz → 0.78.0__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 (201) hide show
  1. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/PKG-INFO +1 -1
  2. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/pyproject.toml +11 -7
  3. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/pyproject.toml.orig +12 -1
  4. sdmxlib-0.78.0/src/sdmxlib/EGM.md +131 -0
  5. sdmxlib-0.78.0/src/sdmxlib/_duckdb.py +42 -0
  6. sdmxlib-0.78.0/src/sdmxlib/_read_errors.py +170 -0
  7. sdmxlib-0.78.0/src/sdmxlib/api/EGM.md +129 -0
  8. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/api/registry.py +66 -29
  9. sdmxlib-0.78.0/src/sdmxlib/builders/EGM.md +63 -0
  10. sdmxlib-0.78.0/src/sdmxlib/bundle/EGM.md +124 -0
  11. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_fingerprint.py +2 -1
  12. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_overlay.py +11 -1
  13. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_write.py +7 -6
  14. sdmxlib-0.78.0/src/sdmxlib/formats/EGM.md +99 -0
  15. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/__init__.py +7 -3
  16. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/render.py +2 -2
  17. sdmxlib-0.78.0/src/sdmxlib/formats/sdmx_csv/EGM.md +55 -0
  18. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_csv/reader.py +38 -27
  19. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_csv/writer.py +17 -7
  20. sdmxlib-0.78.0/src/sdmxlib/formats/sdmx_json/EGM.md +103 -0
  21. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/_data_common.py +87 -9
  22. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/_header.py +5 -8
  23. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/_structure_ingest.py +4 -4
  24. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/data.py +11 -2
  25. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/data_v1.py +10 -10
  26. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/data_v2.py +19 -13
  27. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/metadata.py +17 -3
  28. sdmxlib-0.78.0/src/sdmxlib/formats/sdmx_json_1_0/EGM.md +40 -0
  29. sdmxlib-0.78.0/src/sdmxlib/formats/sdmx_ml/EGM.md +87 -0
  30. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml/_header.py +2 -2
  31. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml/_v3_reader.py +5 -5
  32. sdmxlib-0.78.0/src/sdmxlib/formats/sdmx_ml21/EGM.md +66 -0
  33. sdmxlib-0.78.0/src/sdmxlib/formats/sdmx_ml30/EGM.md +53 -0
  34. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml30/metadata.py +2 -2
  35. sdmxlib-0.78.0/src/sdmxlib/formats/sdmx_ml31/EGM.md +35 -0
  36. sdmxlib-0.78.0/src/sdmxlib/local/EGM.md +144 -0
  37. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/local/_scan.py +51 -18
  38. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/local/data_store.py +35 -9
  39. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/local/object_store.py +3 -1
  40. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/local/registry.py +43 -24
  41. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/local/sql.py +5 -4
  42. sdmxlib-0.78.0/src/sdmxlib/model/EGM.md +179 -0
  43. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_invariants.py +5 -1
  44. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/in_memory_registry.py +11 -1
  45. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/mapping.py +9 -0
  46. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/message.py +14 -0
  47. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/metadatastructure.py +65 -3
  48. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/rollup.py +2 -2
  49. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/validation.py +380 -14
  50. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/version.py +35 -0
  51. sdmxlib-0.78.0/src/sdmxlib/query/EGM.md +151 -0
  52. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_compile.py +12 -1
  53. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_execute.py +4 -1
  54. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_expr.py +3 -3
  55. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_joins.py +1 -1
  56. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_rest.py +6 -0
  57. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/observations.py +9 -14
  58. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/query.py +46 -21
  59. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/raw.py +2 -2
  60. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/session.py +5 -33
  61. sdmxlib-0.78.0/src/sdmxlib/storage/EGM.md +129 -0
  62. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/_projections.py +3 -3
  63. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/_synthetic.py +2 -1
  64. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/_trim.py +19 -14
  65. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/lazy.py +9 -15
  66. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/readers.py +78 -60
  67. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/resolve.py +4 -3
  68. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/schema.py +8 -6
  69. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/writers.py +17 -13
  70. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/testing.py +25 -17
  71. sdmxlib-0.76.2/src/sdmxlib/_duckdb.py +0 -19
  72. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/LICENSE +0 -0
  73. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/README.md +0 -0
  74. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/__init__.py +0 -0
  75. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/_singleflight.py +0 -0
  76. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/_time.py +0 -0
  77. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/api/__init__.py +0 -0
  78. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/api/_freshness.py +0 -0
  79. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/api/client.py +0 -0
  80. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/api/federated.py +0 -0
  81. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/api/policy.py +0 -0
  82. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/api/providers.py +0 -0
  83. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/api/session.py +0 -0
  84. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/builders/__init__.py +0 -0
  85. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/builders/contentconstraint.py +0 -0
  86. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/builders/metadata_annotation.py +0 -0
  87. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/__init__.py +0 -0
  88. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_availability.py +0 -0
  89. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_build.py +0 -0
  90. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_canonical.py +0 -0
  91. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_check.py +0 -0
  92. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_copy.py +0 -0
  93. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_fetch.py +0 -0
  94. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_finding.py +0 -0
  95. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/_remote.py +0 -0
  96. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/manifest.schema.json +0 -0
  97. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/bundle/overlay.schema.json +0 -0
  98. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/data_store.py +0 -0
  99. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/_arrow.py +0 -0
  100. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/_attachment.py +0 -0
  101. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/_coerce.py +0 -0
  102. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/_index.py +0 -0
  103. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/_positions.py +0 -0
  104. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/_refuse.py +0 -0
  105. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/data_format.py +0 -0
  106. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/gaps.py +0 -0
  107. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_csv/__init__.py +0 -0
  108. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/__init__.py +0 -0
  109. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/_dto.py +0 -0
  110. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/_losses.py +0 -0
  111. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/_periods.py +0 -0
  112. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/_resolve.py +0 -0
  113. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/_structure_dto.py +0 -0
  114. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/reader.py +0 -0
  115. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/structure_values.py +0 -0
  116. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json/writer.py +0 -0
  117. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json_1_0/__init__.py +0 -0
  118. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_json_1_0/writer.py +0 -0
  119. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml/__init__.py +0 -0
  120. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml/_allowed_children.py +0 -0
  121. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml/_closed_world.py +0 -0
  122. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml/_common.py +0 -0
  123. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml/_losses.py +0 -0
  124. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml/_v3_writer.py +0 -0
  125. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml21/__init__.py +0 -0
  126. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml21/_providers.py +0 -0
  127. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml21/_synthetic.py +0 -0
  128. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml21/namespaces.py +0 -0
  129. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml21/reader.py +0 -0
  130. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml21/writer.py +0 -0
  131. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml30/__init__.py +0 -0
  132. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml30/namespaces.py +0 -0
  133. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml30/reader.py +0 -0
  134. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml30/writer.py +0 -0
  135. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml31/__init__.py +0 -0
  136. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml31/namespaces.py +0 -0
  137. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml31/reader.py +0 -0
  138. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/formats/sdmx_ml31/writer.py +0 -0
  139. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/local/__init__.py +0 -0
  140. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/local/engine.py +0 -0
  141. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/__init__.py +0 -0
  142. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_binding.py +0 -0
  143. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_container.py +0 -0
  144. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_items.py +0 -0
  145. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_label_match.py +0 -0
  146. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_rebind.py +0 -0
  147. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_referenceable.py +0 -0
  148. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_refshape.py +0 -0
  149. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_resolvers.py +0 -0
  150. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_rules.py +0 -0
  151. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/_tree.py +0 -0
  152. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/annotations.py +0 -0
  153. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/base.py +0 -0
  154. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/binding.py +0 -0
  155. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/category.py +0 -0
  156. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/codelist.py +0 -0
  157. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/collections.py +0 -0
  158. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/concept.py +0 -0
  159. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/constraint.py +0 -0
  160. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/convert.py +0 -0
  161. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/dataflow.py +0 -0
  162. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/datastructure.py +0 -0
  163. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/errors.py +0 -0
  164. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/expr.py +0 -0
  165. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/header.py +0 -0
  166. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/hierarchy.py +0 -0
  167. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/istring.py +0 -0
  168. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/link.py +0 -0
  169. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/metadata_provision.py +0 -0
  170. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/metadataflow.py +0 -0
  171. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/metadataset.py +0 -0
  172. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/organisation.py +0 -0
  173. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/provision.py +0 -0
  174. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/ref.py +0 -0
  175. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/registry.py +0 -0
  176. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/representation.py +0 -0
  177. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/rest_api.py +0 -0
  178. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/urn.py +0 -0
  179. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/valuelist.py +0 -0
  180. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/model/version_rewrite.py +0 -0
  181. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/polars.py +0 -0
  182. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/py.typed +0 -0
  183. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/__init__.py +0 -0
  184. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_closure.py +0 -0
  185. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_common.py +0 -0
  186. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_edges.py +0 -0
  187. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_plan.py +0 -0
  188. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_pushdown.py +0 -0
  189. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/_rebase.py +0 -0
  190. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/accessors.py +0 -0
  191. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/query/schema.py +0 -0
  192. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/rest.py +0 -0
  193. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/sql.py +0 -0
  194. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/__init__.py +0 -0
  195. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/_checked.py +0 -0
  196. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/_columns.py +0 -0
  197. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/_kinds.py +0 -0
  198. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/_manifest.py +0 -0
  199. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/_parsed.py +0 -0
  200. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/storage/_references.py +0 -0
  201. {sdmxlib-0.76.2 → sdmxlib-0.78.0}/src/sdmxlib/versions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdmxlib
3
- Version: 0.76.2
3
+ Version: 0.78.0
4
4
  Summary: SDMX for Python: structures, reference metadata and observation data, from REST, files or a local DuckDB store.
5
5
  Keywords: sdmx,statistics,metadata,datastructure
6
6
  Author: gabrielgellner
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sdmxlib"
3
- version = "0.76.2"
3
+ version = "0.78.0"
4
4
  description = "SDMX for Python: structures, reference metadata and observation data, from REST, files or a local DuckDB store."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -47,6 +47,15 @@ Changelog = "https://github.com/StatCat-Suite/sdmxlib/blob/main/CHANGELOG.md"
47
47
  requires = ["uv_build>=0.13.0,<0.14.0"]
48
48
  build-backend = "uv_build"
49
49
 
50
+ [tool.uv.build-backend]
51
+ wheel-exclude = ["**/EGM.md"]
52
+
53
+ [tool.uv.workspace]
54
+ members = ["cli"]
55
+
56
+ [tool.uv.sources.sdmxlib-cli]
57
+ workspace = true
58
+
50
59
  [tool.pytest.ini_options]
51
60
  testpaths = ["tests"]
52
61
  strict = true
@@ -100,12 +109,6 @@ mutate_only_covered_lines = false
100
109
  process_isolation = "forkserver"
101
110
  forkserver_warmup = "none"
102
111
 
103
- [tool.uv.workspace]
104
- members = ["cli"]
105
-
106
- [tool.uv.sources.sdmxlib-cli]
107
- workspace = true
108
-
109
112
  [dependency-groups]
110
113
  dev = [
111
114
  "sdmxlib-cli",
@@ -134,6 +137,7 @@ dev = [
134
137
  "sqlglot>=27.0",
135
138
  "fastapi>=0.115",
136
139
  ]
140
+ fuzz = ["atheris>=3.1.0,<3.2; sys_platform == 'linux' and platform_machine == 'x86_64'"]
137
141
  bench-compete = [
138
142
  "sdmx1>=2.27.0",
139
143
  "pysdmx[xml,json]>=1.20.0",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sdmxlib"
3
- version = "0.76.2"
3
+ version = "0.78.0"
4
4
  description = "SDMX for Python: structures, reference metadata and observation data, from REST, files or a local DuckDB store."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -61,6 +61,11 @@ Changelog = "https://github.com/StatCat-Suite/sdmxlib/blob/main/CHANGELOG.md
61
61
  requires = ["uv_build>=0.13.0,<0.14.0"]
62
62
  build-backend = "uv_build"
63
63
 
64
+ [tool.uv.build-backend]
65
+ # The EGM.md contracts describe the source for developers; the wheel carries
66
+ # the package alone. The sdist keeps them as part of the source.
67
+ wheel-exclude = ["**/EGM.md"]
68
+
64
69
  [tool.pytest.ini_options]
65
70
  testpaths = ["tests"]
66
71
  # `--strict-markers` turns an unregistered mark into a collection *error*.
@@ -171,6 +176,12 @@ dev = [
171
176
  # dependency and must not become one: sdmxlib has no web framework.
172
177
  "fastapi>=0.115",
173
178
  ]
179
+ # The fuzzer (GH-241), installed only by .github/workflows/fuzz.yml. Atheris
180
+ # ships Linux x86_64 wheels only, so the marker keeps a macOS or ARM sync from
181
+ # trying to build it; crash inputs replay without it (test_fuzz_crashes.py).
182
+ fuzz = [
183
+ "atheris>=3.1.0,<3.2; sys_platform == 'linux' and platform_machine == 'x86_64'",
184
+ ]
174
185
  # Optional: third-party SDMX libraries for the competitive benchmarks
175
186
  # (tests/bench/test_compete.py, and `just bench-compete` — bench/compete/).
176
187
  # Install via `uv sync --group bench-compete`.
@@ -0,0 +1,131 @@
1
+ # sdmxlib
2
+
3
+ ## Overview
4
+
5
+ `sdmxlib` fetches, models, stores and queries SDMX structural metadata,
6
+ reference metadata and observation data. It works over SDMX REST APIs, SDMX
7
+ files, or a local DuckDB store. `__init__.py` re-exports the public API from
8
+ the subpackages in `__all__`: the registries, the model types, the query
9
+ language (`sl.q`, `Col`, `Agg`, `CompiledQuery`, `RawSql`, `sl.schema`), the
10
+ format helpers (`DataFormat`, `Gap`, `dropped`), `DataStore`, `Session`,
11
+ `ValueSet` and the version-rewrite types. It also defines the `sl.len`
12
+ aggregate itself. The modules directly in this directory hold infrastructure
13
+ the subpackages share.
14
+
15
+ ## Interface
16
+
17
+ - `Session`, `SessionFactory` and `ValueSet` (`session.py`): one DuckDB
18
+ session per thread, per store. A `Session` has `execute`, `value_set` and
19
+ `handle`. `SessionFactory` is the mixin `LocalRegistry` and `DuckDBDataStore`
20
+ use, providing `session()` (nested sessions are counted), `execute`,
21
+ `on_connect` and `open_sessions`. `SessionHook` is the type of an
22
+ `on_connect` callback. The internal helpers are `cursor_for`, `own_handle`,
23
+ `adopt`, `frame_of`, `value_match`, the module-level
24
+ `on_connect(base, fn)` and `handle_count(base)` (live handles, for leak
25
+ hunting), and `VALUES_RELATION_PREFIX` (`"_sl_values_"`).
26
+ - `SqlRelation` and `HasSource` (`sql.py`): protocols for something that
27
+ splices into `is_in` (`columns`, `to_sql() -> (sql, params)`) and for
28
+ something that names where it reads (`source`). statcatlib implements
29
+ `SqlRelation`.
30
+ - `DataStore` and `WriteSource` (`data_store.py`): the protocol for the write
31
+ side of the data plane, `write_observations(*, schema, table, source,
32
+ partition_by=(), mode="overwrite" | "append", lake_alias="lake")`, all
33
+ keyword-only. Reads go through `obs()`.
34
+ - `ComponentFilter`, `widen_key` and `parse_components` (`rest.py`): turn a
35
+ REST key and component parameters into SQL `WHERE` clauses.
36
+ - `schema`, `label`, `validation_report`, `structure_frame` and
37
+ `SupportsCodeMap` (`polars.py`): the Polars bridge. Builds a dtype schema
38
+ from a DSD (`coded_as="enum"`), labels codes, and builds validation reports
39
+ and structure frames.
40
+ - `SingleFlight` (`_singleflight.py`): `run(key, work)` runs `work` once per
41
+ key, and a bounded FIFO remembers completed keys. `clear()` empties it.
42
+ `RestRegistry`'s query fetches (`api/registry.py`) and `storage/_parsed.py`
43
+ use it. These runtime caches do not: `_FIFOCache` (`local/registry.py`),
44
+ `SdmxClient._freshness` and `RestRegistry._settled` (bounded FIFO dicts),
45
+ the unbounded `functools.cache` in `api/federated.py`, and the
46
+ `functools.lru_cache` in `model/urn.py`. A new cache goes through
47
+ `SingleFlight` (`docs/design/caching.md`).
48
+ - `to_storage`, `from_storage` and `as_utc` (`_time.py`): store every
49
+ TIMESTAMP as naive UTC.
50
+ - `reading_csv`, `csv_errors`, `converting`, `reads_scan`, `type_mismatch`
51
+ and `SCANS` (`_read_errors.py`): what reading observations raises. Data
52
+ that cannot be read is `SdmxParseError`; a value that does not fit its
53
+ component's type is the one `ValueError` naming `.validate()`.
54
+ `reading_csv` wraps a `read_csv` statement sdmxlib runs itself (a scan, a
55
+ REST ingest); `csv_errors` and `converting` convert at a query terminal and
56
+ in a drained stream, and only errors DuckDB's CSV reader raised.
57
+ - `first` and `count` (`_duckdb.py`): a cursor's first row with its result
58
+ finished, and the row count from a cursor.
59
+ - `synthetic_bundle`, `profile_bundle`, `Shape`, `Dim` and `HierarchyShape`
60
+ (`testing.py`): build a seeded synthetic bundle that passes `check_bundle`,
61
+ or take a `Shape` from an existing bundle.
62
+ - `RewrittenVersion`, `VersionRewrite` and `strip_leading_zeros`
63
+ (`versions.py`): re-exported from `model.version_rewrite` for
64
+ `add_all(rewrite_version=...)`.
65
+ - Subpackages:
66
+ - [`model/`](./model/EGM.md): the frozen attrs SDMX information model,
67
+ `SdmxUrn`, `Ref[T]` and `InMemoryRegistry`.
68
+ - [`formats/`](./formats/EGM.md): SDMX-ML 2.1/3.0/3.1, SDMX-JSON and
69
+ SDMX-CSV readers and writers, and the format gap table.
70
+ - [`storage/`](./storage/EGM.md): the DuckDB schema, writers, readers, lazy
71
+ facades and publication trimming.
72
+ - [`local/`](./local/EGM.md): `BundleRegistry`, `LocalRegistry`,
73
+ `BundleEngine` and `DuckDBDataStore` over DuckDB and DuckLake.
74
+ - [`query/`](./query/EGM.md): the `sl.q` path language, compiled to
75
+ parameterised DuckDB SQL; `ObsQuery`; and raw SQL.
76
+ - [`api/`](./api/EGM.md): `RestRegistry`, `FmrRegistry`,
77
+ `FederatedRegistry`, `Provider` and the httpx2 client.
78
+ - [`bundle/`](./bundle/EGM.md): `write_manifest`, `check_bundle`,
79
+ `copy_bundle`, `build_bundle`, `fetch_bundle`, overlays and
80
+ fingerprints.
81
+ - [`builders/`](./builders/EGM.md): availability constraints and DSD
82
+ metadata annotations, computed from a bundle.
83
+
84
+ ## Invariants
85
+
86
+ - Layering: `model/` imports nothing from `formats/` and does no I/O.
87
+ `formats/` owns all XML and JSON. `storage/` and `local/` own DuckDB. `api/`
88
+ owns HTTP.
89
+ - Each thread holds one DuckDB cursor per base connection, kept in a
90
+ thread-local `WeakKeyDictionary` and reused across calls. `own_handle`
91
+ creates a separate handle for each reader that holds one until exhausted,
92
+ such as an Arrow stream.
93
+ - A `Session` is valid only inside its `with` block. Nested sessions share the
94
+ handle. The outermost block releases it, and the next session gets a fresh
95
+ cursor.
96
+ - Every read in `src/` finishes its own `execute()` result: a single-row
97
+ read goes through `_duckdb.first`, and no `fetchone()` or `fetchmany()`
98
+ appears elsewhere (`test_no_read_in_src_strands_its_result`). DuckDB 2.0
99
+ refuses a `sql`, `register` or `unregister` call on a handle holding an
100
+ unfinished result, so a read that strands one raises at the next relation
101
+ call on that thread's handle (GH-75).
102
+ - `SingleFlight` work must be idempotent: eviction runs it again, and a
103
+ failure is not remembered, so waiters retry. A `maxsize` of 0 or less raises
104
+ `ValueError`.
105
+ - Timestamps are stored as UTC with `tzinfo` removed. A naive input is assumed
106
+ to be UTC already.
107
+ - `SqlRelation.to_sql()` returns `(sql, params)`, and values are bound as
108
+ parameters.
109
+ - `synthetic_bundle` gives the same artefacts and observation rows for a given
110
+ seed and shape, and writes its manifest through `write_manifest`. The token
111
+ and the DuckDB file bytes differ on each build.
112
+
113
+ ## Side Effects
114
+
115
+ - `session.py` creates DuckDB cursors on demand, keeps them in thread-local
116
+ state, and runs the registered `on_connect` hooks on each new handle.
117
+ `_hook_lock` guards the hook and handle bookkeeping; the hooks run outside
118
+ it.
119
+ - `Session.value_set` registers temporary relations named `_sl_values_*` on
120
+ the handle.
121
+ - `SingleFlight` uses `threading.Lock` and `threading.Event`. Waiters block
122
+ until the leader finishes.
123
+ - `testing.synthetic_bundle` creates directories, writes observations and
124
+ writes a manifest.
125
+ - `_read_errors` converts the exceptions raised by CSV reads and by
126
+ `RecordBatchReader` iteration.
127
+
128
+ ## Verification
129
+
130
+ - Run: `just check` (lint and typecheck) and `just test` (unit tests).
131
+ - `just ci` is the full gate and runs locally.
@@ -0,0 +1,42 @@
1
+ """Private DuckDB helpers shared by the storage layer and the query language.
2
+
3
+ Lives at the package root because both ``storage/`` and ``query/`` need it, and
4
+ neither layer may import the other.
5
+
6
+ Every single-row read goes through `first`. A thread's handle is shared by
7
+ every read on that thread, and DuckDB 2.0 refuses a relation call (`sql`,
8
+ `register`, `unregister`) on a handle holding an `execute()` result nobody
9
+ finished. `fetchone()` never finishes one, even on a one-row result, so a bare
10
+ `fetchone()` breaks the next relation call, usually in an unrelated module
11
+ (GH-75). `tests/unit/test_session.py` refuses a bare one in `src/`.
12
+ """
13
+
14
+ from typing import Any
15
+
16
+ import duckdb
17
+
18
+
19
+ def first(cursor: duckdb.DuckDBPyConnection) -> tuple[Any, ...] | None:
20
+ """The first row of the result `cursor` holds, or None, with the result finished.
21
+
22
+ Typed as DuckDB's `fetchone()` is: a row's cells are whatever the query
23
+ selected, and each caller narrows them, as it did reading `fetchone()`.
24
+
25
+ Args:
26
+ cursor: A handle that has just run ``execute()``.
27
+
28
+ Returns:
29
+ The first row, or None when the result has none.
30
+ """
31
+ row = cursor.fetchone()
32
+ cursor.complete()
33
+ return row
34
+
35
+
36
+ def count(cursor: duckdb.DuckDBPyConnection) -> int:
37
+ """Return the integer in the first cell of the cursor's first row, or 0.
38
+
39
+ The ``__len__`` helper for ``SELECT COUNT(*)`` queries.
40
+ """
41
+ row = first(cursor)
42
+ return int(row[0]) if row is not None else 0
@@ -0,0 +1,170 @@
1
+ """What reading observations raises, in sdmxlib's terms (GH-247).
2
+
3
+ Two failures, two exceptions:
4
+
5
+ 1. **The bytes are not a readable data message** — truncated JSON, a CSV row
6
+ DuckDB cannot split, a missing column: `SdmxParseError`, as `sl.parse`
7
+ raises for a structure message. The library's own error is its
8
+ ``__cause__``.
9
+ 2. **The message reads, but a value does not fit its component's type** —
10
+ text where the DSD declares a number or a date: ``ValueError``, naming the
11
+ structure and `.validate()`, the one message whether the value is found
12
+ while the file is read or when a query casts its result.
13
+
14
+ DuckDB parses every SDMX-CSV file sdmxlib reads, `scan_csv` and a REST
15
+ `obs()` response alike. Where sdmxlib runs the read itself
16
+ (`reading_csv`), any DuckDB failure of that statement is about the file. A
17
+ scanned path is a view that DuckDB reads when a query runs, so the query
18
+ terminals convert too (`csv_errors`, `converting`), and there only an error
19
+ DuckDB's CSV reader raised: its message starts ``CSV Error on Line``. A
20
+ failed cast elsewhere is also a ``ConversionException``, and passes through.
21
+ """
22
+
23
+ import functools
24
+ from collections.abc import Callable, Generator, Iterator
25
+ from contextlib import contextmanager
26
+
27
+ import duckdb
28
+ import pyarrow as pa
29
+
30
+ from sdmxlib.model.errors import SdmxParseError
31
+
32
+ #: What DuckDB's CSV reader puts in every error it raises, and no other part does.
33
+ _CSV_ERROR = "CSV Error"
34
+
35
+ #: The catalog every scanned file's relation lives in (`sdmxlib.local._scan`).
36
+ #: Here rather than there so the query layer can tell a scan from a table
37
+ #: without importing `sdmxlib.local`.
38
+ SCANS = "sdmx_scans"
39
+
40
+
41
+ def type_mismatch(structure: str, exc: BaseException, *, raw_rows: bool = False) -> ValueError:
42
+ """The error for a value that does not fit its component's type.
43
+
44
+ Args:
45
+ structure: The data structure's id.
46
+ exc: The library's error, for the message.
47
+ raw_rows: Whether to name `.stream()` as the way to the untyped rows,
48
+ which holds for a query's cast and not for a CSV read, whose
49
+ columns DuckDB types as it reads.
50
+
51
+ Returns:
52
+ The ``ValueError`` to raise from `exc`.
53
+ """
54
+ msg = (
55
+ f"an observation column does not fit its component's type in {structure}: {exc}. "
56
+ "Results are typed from the DSD."
57
+ )
58
+ if raw_rows:
59
+ msg += " .stream() reads the raw rows;"
60
+ msg += (
61
+ " an observation query's .validate(), or sdmxlib.polars.validation_report(dsd, frame), "
62
+ "names every value that does not fit."
63
+ )
64
+ return ValueError(msg)
65
+
66
+
67
+ def _converted(exc: Exception, *, structure: str, any_read_error: bool) -> Exception | None:
68
+ """The error sdmxlib raises for DuckDB's `exc`, or `None` when `exc` is not a CSV read's.
69
+
70
+ A stream's error reaches Python through pyarrow as an ``OSError`` carrying
71
+ DuckDB's message, so the kind is read off the message's prefix too.
72
+ """
73
+ text = str(exc)
74
+ if not any_read_error and _CSV_ERROR not in text:
75
+ return None
76
+ if isinstance(exc, duckdb.ConversionException) or text.startswith("Conversion Error"):
77
+ return type_mismatch(structure, exc)
78
+ if isinstance(exc, (duckdb.InvalidInputException, duckdb.BinderException)) or text.startswith(
79
+ "Invalid Input Error"
80
+ ):
81
+ return SdmxParseError(f"the SDMX-CSV data could not be read: {exc}")
82
+ return None
83
+
84
+
85
+ @contextmanager
86
+ def reading_csv(*, structure: str) -> Generator[None]:
87
+ """Convert what the one ``read_csv`` statement inside raises.
88
+
89
+ Args:
90
+ structure: The data structure's id, for a type mismatch.
91
+
92
+ Yields:
93
+ Nothing; the statement runs in the block.
94
+
95
+ Raises:
96
+ SdmxParseError: The file is not readable SDMX-CSV.
97
+ ValueError: A value does not fit its component's type.
98
+ """
99
+ try:
100
+ yield
101
+ except duckdb.Error as exc:
102
+ err = _converted(exc, structure=structure, any_read_error=True)
103
+ if err is None:
104
+ raise
105
+ raise err from exc
106
+
107
+
108
+ def _structure_of(query: object) -> str:
109
+ """The data structure id a query reads with, for the message."""
110
+ root = getattr(getattr(query, "_query", query), "root", None)
111
+ dsd = getattr(root, "dsd", None)
112
+ found: object = getattr(dsd, "id", None)
113
+ return found if isinstance(found, str) else "its data structure"
114
+
115
+
116
+ def csv_errors[**P, T](method: Callable[P, T]) -> Callable[P, T]:
117
+ """Convert the CSV read errors a query terminal's statement raises.
118
+
119
+ Args:
120
+ method: A query method whose first argument is the query.
121
+
122
+ Returns:
123
+ The method, raising `SdmxParseError` or the type ``ValueError`` in
124
+ place of DuckDB's CSV reader errors.
125
+ """
126
+
127
+ @functools.wraps(method)
128
+ def run(*args: P.args, **kwargs: P.kwargs) -> T:
129
+ try:
130
+ return method(*args, **kwargs)
131
+ except duckdb.Error as exc:
132
+ err = _converted(exc, structure=_structure_of(args[0]), any_read_error=False)
133
+ if err is None:
134
+ raise
135
+ raise err from exc
136
+
137
+ return run
138
+
139
+
140
+ def reads_scan(query: object) -> bool:
141
+ """Whether `query` reads a scanned file, whose rows DuckDB parses as the query runs."""
142
+ root = getattr(getattr(query, "_query", query), "root", None)
143
+ binding = getattr(root, "binding", None)
144
+ return getattr(binding, "database_role", None) == SCANS
145
+
146
+
147
+ def converting(reader: pa.RecordBatchReader, *, query: object) -> pa.RecordBatchReader:
148
+ """`reader`, raising sdmxlib's errors for a CSV read failure while it is drained.
149
+
150
+ A stream runs its statement as it is read, after the terminal returned,
151
+ so the conversion goes with the batches.
152
+
153
+ Args:
154
+ reader: The stream DuckDB returned.
155
+ query: The query it reads, for the structure's id.
156
+
157
+ Returns:
158
+ A reader over the same batches.
159
+ """
160
+
161
+ def batches() -> Iterator[pa.RecordBatch]:
162
+ try:
163
+ yield from reader
164
+ except (duckdb.Error, OSError) as exc:
165
+ err = _converted(exc, structure=_structure_of(query), any_read_error=False)
166
+ if err is None:
167
+ raise
168
+ raise err from exc
169
+
170
+ return pa.RecordBatchReader.from_batches(reader.schema, batches())
@@ -0,0 +1,129 @@
1
+ # sdmxlib.api
2
+
3
+ ## Overview
4
+
5
+ `sdmxlib.api` is the HTTP-facing layer. `SdmxClient` wraps an `httpx2.Client`
6
+ to fetch and parse SDMX REST resources. `RestRegistry` is a context-managed
7
+ connection to one endpoint: it keeps fetched artefacts in a `Session` identity
8
+ map and can write them through to a `LocalRegistry` store. `FederatedRegistry`
9
+ routes URN lookups across several sources by maintenance agency. The package
10
+ exports `BearerToken`, `FmrRegistry`, `Provider` and `RestRegistry`. Queries go
11
+ through `RestRegistry.query` (structures) and `RestRegistry.obs`
12
+ (observations).
13
+
14
+ ## Interface
15
+
16
+ - `RestRegistry` (`registry.py`): connection to an SDMX REST endpoint. Takes a
17
+ URL or a `ProviderInfo`, plus `api`, `timeout`, `headers`, `id`, `store`,
18
+ `fetch_cache_size`, `latest_ttl`, `csv_media_type` and forwarded
19
+ `HttpxOptions`. A `ProviderInfo` supplies its own `api`, and the `api`
20
+ argument is then ignored. `store=` without an `id` raises `ValueError`.
21
+ - `RestRegistry.get` (`registry.py`): reads by URN or `Ref`, with `resolve=`,
22
+ `partial=` and `expect=`. Raises `SdmxConformanceError` for an artefact the
23
+ provider served and the reader refused.
24
+ - `RestRegistry.refused`, `registry` and `__contains__` (`registry.py`): the
25
+ `Refusal`s of served artefacts the reader left out; the `InMemoryRegistry`
26
+ every fetched artefact is added to; and membership by `SdmxUrn` or `Ref`
27
+ in the session or the store, with no HTTP.
28
+ - `RestRegistry.query` (`registry.py`): builds a `Query[R, A]` (the path
29
+ language over REST) against a local query store.
30
+ - `RestRegistry.obs` (`registry.py`): an `ObsQuery` over a dataflow's
31
+ observations. Accepts a `Dataflow`, a `Ref` or a URN.
32
+ - `RestRegistry.download` (`registry.py`): downloads data in a required `fmt`.
33
+ With `to` it writes the file and returns its `Path`, checking the suffix
34
+ against `fmt`; without `to` it returns the bytes. The response
35
+ `Content-Type` is checked against `fmt` too.
36
+ - `RestRegistry.load`, `scan_csv` and `scan_json` (`registry.py`): load a
37
+ structure message, or scan local CSV or JSON data into an `ObsQuery`.
38
+ - `RestRegistry.check_binding_drift` and `validate_binding` (`registry.py`):
39
+ compare a `DataflowBinding` with what the registry serves.
40
+ - `FmrRegistry` and `BearerToken` (`registry.py`): a `RestRegistry` for FMR.
41
+ `auth=` takes a `BearerToken`, sent as an `Authorization` header, or a
42
+ `(user, pass)` tuple, passed to httpx2. It always uses `api="2.1"` and
43
+ forwards only `HttpxTransportOptions`.
44
+ - `FederatedRegistry` (`federated.py`): read-only router built from a
45
+ `routing` map (agency id to `RegistryReader`) and an optional `default`.
46
+ Provides `get`, `source_for`, `__contains__` and binding checks. `get`
47
+ reads each source's `get` signature and passes `resolve`/`partial` only to
48
+ a source that takes them; `partial=False` to a source without `partial`
49
+ raises `TypeError`. `__contains__` takes an `SdmxUrn` only and returns
50
+ `False` for anything else.
51
+ - `Provider` and `ProviderInfo` (`providers.py`): the built-in endpoints `ECB`,
52
+ `BIS`, `ESTAT`, `IMF`, `OECD` and `SDMX_GLOBAL`, each with its REST API
53
+ version. Look one up by attribute or by subscript. A `ProviderInfo` has
54
+ `url`, `api`, `id` and an optional `csv_media_type`.
55
+ - `RegistryUnavailable` (`policy.py`): a source that could not be reached.
56
+ Carries `source_id`, `cause` and `tried`.
57
+ - `Session` (`session.py`): identity map keyed by versioned URN. Provides
58
+ `ingest`, `get`, `get_at_least`, `record_parents`, `completeness_for`,
59
+ `first_of_class`, `all_of_class` and `extract`. `Completeness` and
60
+ `completeness_of` rank a fetch's depth from its `detail` and `references`.
61
+ This is a different `Session` from `sdmxlib/session.py`'s DuckDB session.
62
+ - `SdmxClient` (`client.py`): the httpx2 wrapper. Provides `get_artefact`,
63
+ `get_artefact_if_changed`, `get_all`, `get_data_at`, `stream_data_at`,
64
+ `download_data`, `forget_freshness`, `close` and the `api` property (the
65
+ REST API version, which decides a request's key slots). `_freshness.py`
66
+ holds the `Freshness` record.
67
+ - `HttpxOptions`, `HttpxTransportOptions` and `HttpxAuthOption` (`client.py`):
68
+ closed TypedDicts (PEP 728). `HttpxOptions` is every httpx2 option
69
+ `RestRegistry` forwards; it combines the transport options and the `auth`
70
+ option. `event_hooks` is left out on purpose. `ResponseTooLargeError` is
71
+ defined here too.
72
+
73
+ ## Invariants
74
+
75
+ - `Provider` cannot be subclassed: `__init_subclass__` raises `TypeError`.
76
+ `Provider["X"]` for an unknown name raises a `KeyError` that lists the
77
+ providers.
78
+ - `FederatedRegistry.get` raises `KeyError` when no route matches the URN's
79
+ agency and no default is set. It re-raises `RegistryUnavailable` as is, and
80
+ wraps any other `httpx2.HTTPError` or `OSError` as
81
+ `RegistryUnavailable(source.id, exc, tried=urn)`. It applies `expect` itself
82
+ and returns `None` when the result is a different type.
83
+ - `SdmxClient` turns only `httpx2.TransportError` and `OSError` into "source
84
+ unreachable". `get_artefact` and `get_artefact_if_changed` map a 404 to
85
+ `KeyError`; `get_all` and the data methods raise httpx2's
86
+ `HTTPStatusError` for it. A 413 or 414 raises `ResponseTooLargeError`.
87
+ - `Session` completeness never goes down: `ingest` keeps the higher of the old
88
+ and new values. Artefacts whose class has no `sdmx_package` are skipped.
89
+ - `SdmxClient` caches freshness metadata (ETag, Last-Modified, max-age) only
90
+ for conditional `latest`-version structure calls, keyed by URL and sorted
91
+ params, in a bounded FIFO behind a lock. Within a fresh window such a call
92
+ returns `NOT_MODIFIED` without a request. It never caches response bodies.
93
+ - For API versions starting with `3` or `2.0`, the default `Accept` header is
94
+ the SDMX 3.0 structure XML type; for all others it is `application/xml`.
95
+ - Concurrent identical `query()` fetches run once, through `SingleFlight`.
96
+ `get()` does not use it. The observation path serialises its fetch and
97
+ ingest under `_data_lock`, one question per table at a time.
98
+ - `RestRegistry._settled`, the bounded `latest -> pinned` map, is written
99
+ under `_settled_lock`, and `_raise_if_refused` reads a snapshot of the
100
+ refusal record, so concurrent `get`s neither collide evicting a pointer
101
+ nor fail iterating a refusal record another fetch is adding to (GH-286).
102
+ The refusal record has no bound; it holds one entry per refused artefact.
103
+ - With `store=` set, a pinned `get` with `resolve=False` or `"parents"` is
104
+ served from the store, when the store holds it, before any HTTP. A `latest`
105
+ URN is never served from the store.
106
+ - An `obs()` response DuckDB cannot read raises `SdmxParseError`, and a value
107
+ that does not fit its component's type the "does not fit its component's
108
+ type" `ValueError` (`reading_csv` around the ingest,
109
+ `sdmxlib._read_errors`). `scan_csv` and `scan_json` raise the same two.
110
+
111
+ ## Side Effects
112
+
113
+ - Makes HTTP GETs through the single `httpx2.Client` that `SdmxClient` owns.
114
+ The client carries default headers, a timeout (30 s by default) and the
115
+ forwarded options.
116
+ - `get_artefact_if_changed` sends conditional requests: a 304 means unchanged
117
+ and a 404 means not found. `stream_data_at` writes the response to a file,
118
+ and `download_data` writes one only when `to` is given.
119
+ - `RestRegistry` is a context manager. `close()` closes the HTTP client, and
120
+ also the query store if the registry created it.
121
+ - With `store=` set, every fetched artefact is written to that `LocalRegistry`,
122
+ tagged `source_registry=<id>`.
123
+ - The query store is created once, under a double-checked lock.
124
+ - No automatic retry. A transport failure surfaces as `RegistryUnavailable`.
125
+
126
+ ## Verification
127
+
128
+ - Run: `just test` (unit tests) and `just test-integration` (end-to-end
129
+ tests replayed from recorded cassettes, no network).