sdmxlib 0.77.0__tar.gz → 0.79.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.
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/PKG-INFO +1 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/pyproject.toml +10 -7
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/pyproject.toml.orig +6 -1
- sdmxlib-0.79.0/src/sdmxlib/EGM.md +131 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/__init__.py +10 -0
- sdmxlib-0.79.0/src/sdmxlib/_duckdb.py +42 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/_read_errors.py +1 -1
- sdmxlib-0.79.0/src/sdmxlib/api/EGM.md +129 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/api/registry.py +50 -23
- sdmxlib-0.79.0/src/sdmxlib/builders/EGM.md +63 -0
- sdmxlib-0.79.0/src/sdmxlib/bundle/EGM.md +127 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_canonical.py +1 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_check.py +20 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_fingerprint.py +2 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_overlay.py +36 -9
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_write.py +7 -6
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/overlay.schema.json +1 -1
- sdmxlib-0.79.0/src/sdmxlib/formats/EGM.md +105 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/__init__.py +7 -3
- sdmxlib-0.79.0/src/sdmxlib/formats/_tags.py +136 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/render.py +2 -2
- sdmxlib-0.79.0/src/sdmxlib/formats/sdmx_csv/EGM.md +55 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_csv/reader.py +35 -28
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_csv/writer.py +17 -7
- sdmxlib-0.79.0/src/sdmxlib/formats/sdmx_json/EGM.md +107 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/_data_common.py +71 -13
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/_dto.py +39 -24
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/_header.py +13 -15
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/_structure_dto.py +8 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/_structure_ingest.py +85 -84
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/data_v1.py +10 -9
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/data_v2.py +17 -9
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/metadata.py +34 -19
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/reader.py +8 -0
- sdmxlib-0.79.0/src/sdmxlib/formats/sdmx_json_1_0/EGM.md +40 -0
- sdmxlib-0.79.0/src/sdmxlib/formats/sdmx_ml/EGM.md +87 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml/_common.py +13 -32
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml/_header.py +4 -5
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml/_v3_reader.py +2 -2
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml/_v3_writer.py +2 -2
- sdmxlib-0.79.0/src/sdmxlib/formats/sdmx_ml21/EGM.md +66 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml21/writer.py +2 -2
- sdmxlib-0.79.0/src/sdmxlib/formats/sdmx_ml30/EGM.md +53 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml30/metadata.py +12 -19
- sdmxlib-0.79.0/src/sdmxlib/formats/sdmx_ml31/EGM.md +35 -0
- sdmxlib-0.79.0/src/sdmxlib/local/EGM.md +144 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/local/_scan.py +10 -5
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/local/data_store.py +35 -9
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/local/object_store.py +3 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/local/registry.py +39 -26
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/local/sql.py +5 -4
- sdmxlib-0.79.0/src/sdmxlib/model/EGM.md +203 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/__init__.py +13 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_invariants.py +5 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_rules.py +2 -2
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/annotations.py +6 -3
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/codelist.py +6 -2
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/constraint.py +5 -2
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/convert.py +2 -2
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/datastructure.py +12 -3
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/in_memory_registry.py +11 -1
- sdmxlib-0.79.0/src/sdmxlib/model/istring.py +582 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/link.py +9 -5
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/mapping.py +9 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/message.py +14 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/metadatastructure.py +65 -3
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/rollup.py +2 -2
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/validation.py +380 -14
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/valuelist.py +8 -3
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/version.py +35 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/polars.py +18 -11
- sdmxlib-0.79.0/src/sdmxlib/query/EGM.md +151 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_compile.py +12 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_execute.py +4 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_expr.py +11 -7
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_joins.py +1 -1
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_rest.py +6 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/observations.py +12 -15
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/query.py +24 -15
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/raw.py +2 -2
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/session.py +5 -33
- sdmxlib-0.79.0/src/sdmxlib/storage/EGM.md +132 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/_projections.py +8 -3
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/_synthetic.py +2 -1
- sdmxlib-0.79.0/src/sdmxlib/storage/_tags.py +84 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/_trim.py +19 -14
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/lazy.py +16 -17
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/readers.py +85 -63
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/resolve.py +10 -10
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/schema.py +8 -6
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/writers.py +21 -17
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/testing.py +25 -17
- sdmxlib-0.77.0/src/sdmxlib/_duckdb.py +0 -19
- sdmxlib-0.77.0/src/sdmxlib/model/istring.py +0 -157
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/LICENSE +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/README.md +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/_singleflight.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/_time.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/api/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/api/_freshness.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/api/client.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/api/federated.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/api/policy.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/api/providers.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/api/session.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/builders/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/builders/contentconstraint.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/builders/metadata_annotation.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_availability.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_build.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_copy.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_fetch.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_finding.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/_remote.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/bundle/manifest.schema.json +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/data_store.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/_arrow.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/_attachment.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/_coerce.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/_index.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/_positions.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/_refuse.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/data_format.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/gaps.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_csv/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/_losses.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/_periods.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/_resolve.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/data.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/structure_values.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json/writer.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json_1_0/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_json_1_0/writer.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml/_allowed_children.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml/_closed_world.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml/_losses.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml21/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml21/_providers.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml21/_synthetic.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml21/namespaces.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml21/reader.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml30/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml30/namespaces.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml30/reader.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml30/writer.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml31/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml31/namespaces.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml31/reader.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/formats/sdmx_ml31/writer.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/local/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/local/engine.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_binding.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_container.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_items.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_label_match.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_rebind.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_referenceable.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_refshape.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_resolvers.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/_tree.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/base.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/binding.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/category.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/collections.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/concept.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/dataflow.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/errors.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/expr.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/header.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/hierarchy.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/metadata_provision.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/metadataflow.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/metadataset.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/organisation.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/provision.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/ref.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/registry.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/representation.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/rest_api.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/urn.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/model/version_rewrite.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/py.typed +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_closure.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_common.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_edges.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_plan.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_pushdown.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/_rebase.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/accessors.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/query/schema.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/rest.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/sql.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/__init__.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/_checked.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/_columns.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/_kinds.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/_manifest.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/_parsed.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/storage/_references.py +0 -0
- {sdmxlib-0.77.0 → sdmxlib-0.79.0}/src/sdmxlib/versions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sdmxlib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.79.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.
|
|
3
|
+
version = "0.79.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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sdmxlib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.79.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*.
|
|
@@ -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.
|
|
@@ -159,6 +159,7 @@ from sdmxlib.model import (
|
|
|
159
159
|
InclusionMode,
|
|
160
160
|
InMemoryRegistry,
|
|
161
161
|
InternationalString,
|
|
162
|
+
InvalidTagError,
|
|
162
163
|
ItemExpr,
|
|
163
164
|
ItemList,
|
|
164
165
|
ItemMap,
|
|
@@ -169,9 +170,13 @@ from sdmxlib.model import (
|
|
|
169
170
|
TimeRange,
|
|
170
171
|
Level,
|
|
171
172
|
Link,
|
|
173
|
+
LocalisedString,
|
|
174
|
+
MissingTagError,
|
|
172
175
|
RepresentationMapping,
|
|
173
176
|
SourceValue,
|
|
174
177
|
item,
|
|
178
|
+
normalize_tag,
|
|
179
|
+
tag_alias,
|
|
175
180
|
Maintainable,
|
|
176
181
|
MaintainableArtefact,
|
|
177
182
|
MapDataType,
|
|
@@ -330,6 +335,7 @@ __all__ = [
|
|
|
330
335
|
"InMemoryRegistry",
|
|
331
336
|
"InclusionMode",
|
|
332
337
|
"InternationalString",
|
|
338
|
+
"InvalidTagError",
|
|
333
339
|
"ItemExpr",
|
|
334
340
|
"ItemList",
|
|
335
341
|
"ItemMap",
|
|
@@ -340,6 +346,7 @@ __all__ = [
|
|
|
340
346
|
"Level",
|
|
341
347
|
"Link",
|
|
342
348
|
"LocalRegistry",
|
|
349
|
+
"LocalisedString",
|
|
343
350
|
"LossyReadError",
|
|
344
351
|
"Maintainable",
|
|
345
352
|
"MaintainableArtefact",
|
|
@@ -358,6 +365,7 @@ __all__ = [
|
|
|
358
365
|
"MetadataSet",
|
|
359
366
|
"MetadataStructure",
|
|
360
367
|
"Metadataflow",
|
|
368
|
+
"MissingTagError",
|
|
361
369
|
"Num",
|
|
362
370
|
"ObsQuery",
|
|
363
371
|
"ObsRow",
|
|
@@ -445,12 +453,14 @@ __all__ = [
|
|
|
445
453
|
"from_dict",
|
|
446
454
|
"item",
|
|
447
455
|
"len",
|
|
456
|
+
"normalize_tag",
|
|
448
457
|
"parse",
|
|
449
458
|
"parse_components",
|
|
450
459
|
"q",
|
|
451
460
|
"read",
|
|
452
461
|
"schema",
|
|
453
462
|
"serialize",
|
|
463
|
+
"tag_alias",
|
|
454
464
|
"to_dict",
|
|
455
465
|
"to_json",
|
|
456
466
|
"to_xml",
|
|
@@ -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
|
|
@@ -12,7 +12,7 @@ Two failures, two exceptions:
|
|
|
12
12
|
while the file is read or when a query casts its result.
|
|
13
13
|
|
|
14
14
|
DuckDB parses every SDMX-CSV file sdmxlib reads, `scan_csv` and a REST
|
|
15
|
-
`obs()`
|
|
15
|
+
`obs()` response alike. Where sdmxlib runs the read itself
|
|
16
16
|
(`reading_csv`), any DuckDB failure of that statement is about the file. A
|
|
17
17
|
scanned path is a view that DuckDB reads when a query runs, so the query
|
|
18
18
|
terminals convert too (`csv_errors`, `converting`), and there only an error
|
|
@@ -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).
|
|
@@ -31,7 +31,7 @@ from sdmxlib.model.message import StructureMessage
|
|
|
31
31
|
from sdmxlib.model.ref import Ref, SupportsUrn, artefact_urn, target_urn
|
|
32
32
|
from sdmxlib.model.urn import SdmxUrn
|
|
33
33
|
from sdmxlib.model.validation import SdmxConformanceError
|
|
34
|
-
from sdmxlib.query._closure import closure, detail_for, reached_columns
|
|
34
|
+
from sdmxlib.query._closure import closure, detail_for, reached_columns, references_for
|
|
35
35
|
from sdmxlib.query._common import canonical_key
|
|
36
36
|
from sdmxlib.query._execute import fetch_into
|
|
37
37
|
from sdmxlib.query._expr import AnyPred, Cols, Compare, RowKind
|
|
@@ -273,6 +273,9 @@ class RestRegistry:
|
|
|
273
273
|
#: and an eviction costs a fetch rather than a wrong answer.
|
|
274
274
|
self._settled: dict[str, SdmxUrn[object]] = {}
|
|
275
275
|
self._settled_size = 256
|
|
276
|
+
#: Guards `_settled`'s writes: two threads evicting at capacity pick
|
|
277
|
+
#: the same oldest key, and the second `del` raises `KeyError`.
|
|
278
|
+
self._settled_lock = threading.Lock()
|
|
276
279
|
#: What the provider served and the reader refused (#419), by URN —
|
|
277
280
|
#: so `get` of one says why rather than that it does not exist.
|
|
278
281
|
self._refused: dict[str, Refusal] = {}
|
|
@@ -283,8 +286,9 @@ class RestRegistry:
|
|
|
283
286
|
#: threads build two `:memory:` stores, one of which is leaked still
|
|
284
287
|
#: open with a thread's fetched artefacts inside it.
|
|
285
288
|
self._store_lock = threading.Lock()
|
|
286
|
-
#: Plans already fetched for, keyed by `canonical_key
|
|
287
|
-
#:
|
|
289
|
+
#: Plans already fetched for, keyed by `canonical_key` with the
|
|
290
|
+
#: `detail=` and `references=` the fetch asked for (`_fetch_for`).
|
|
291
|
+
#: Bounded and single-flight — see `_singleflight.SingleFlight`.
|
|
288
292
|
self._fetched = SingleFlight(fetch_cache_size)
|
|
289
293
|
#: Table -> the question whose rows it currently holds. See
|
|
290
294
|
#: `_fetch_data_for` for why one table serves one question at a time,
|
|
@@ -459,12 +463,13 @@ class RestRegistry:
|
|
|
459
463
|
"""Raise naming why, if the artefact `urn` names was served and refused.
|
|
460
464
|
|
|
461
465
|
A `latest` URN names no version, so it matches a refusal of any
|
|
462
|
-
version of the same artefact.
|
|
466
|
+
version of the same artefact. It reads a snapshot, since `_absorb` on
|
|
467
|
+
another thread may be adding a refusal.
|
|
463
468
|
|
|
464
469
|
Raises:
|
|
465
470
|
SdmxConformanceError: If `urn` names a refused artefact.
|
|
466
471
|
"""
|
|
467
|
-
for refusal in self._refused.values():
|
|
472
|
+
for refusal in tuple(self._refused.values()):
|
|
468
473
|
refused = SdmxUrn.parse(refusal.urn)
|
|
469
474
|
same = (refused.artefact_class, refused.agency, refused.id) == (urn.artefact_class, urn.agency, urn.id)
|
|
470
475
|
if same and urn.version in {"latest", refused.version}:
|
|
@@ -599,13 +604,15 @@ class RestRegistry:
|
|
|
599
604
|
so a stale entry cannot be served — which is what separates this from
|
|
600
605
|
the `_latest` index #338 removed.
|
|
601
606
|
"""
|
|
602
|
-
self.
|
|
603
|
-
|
|
604
|
-
|
|
607
|
+
with self._settled_lock:
|
|
608
|
+
self._settled[latest] = pinned
|
|
609
|
+
while len(self._settled) > self._settled_size:
|
|
610
|
+
del self._settled[next(iter(self._settled))]
|
|
605
611
|
|
|
606
612
|
def _forget(self, latest: str) -> None:
|
|
607
613
|
"""Drop a pointer and the freshness that vouched for it."""
|
|
608
|
-
self.
|
|
614
|
+
with self._settled_lock:
|
|
615
|
+
self._settled.pop(latest, None)
|
|
609
616
|
self._client.forget_freshness()
|
|
610
617
|
|
|
611
618
|
def _fetch_all_with[T](
|
|
@@ -695,7 +702,12 @@ class RestRegistry:
|
|
|
695
702
|
self._query_store_owned = LocalRegistry(":memory:").open()
|
|
696
703
|
return self._query_store_owned
|
|
697
704
|
|
|
698
|
-
def _fetch_for[R: "RowKind"](
|
|
705
|
+
def _fetch_for[R: "RowKind"](
|
|
706
|
+
self,
|
|
707
|
+
plan: Plan[R],
|
|
708
|
+
projection: frozenset[tuple[str, str]] | None = None,
|
|
709
|
+
projected_paths: frozenset[tuple[str, ...]] = frozenset(),
|
|
710
|
+
) -> None:
|
|
699
711
|
"""Fetch what `plan` needs, once per distinct question.
|
|
700
712
|
|
|
701
713
|
Keyed on `canonical_key` rather than on the plan object: two plans that
|
|
@@ -714,19 +726,26 @@ class RestRegistry:
|
|
|
714
726
|
`select(id).ids()` fetches stubs, then `collect()` on the same plan
|
|
715
727
|
finds the key present, skips the fetch, and resolves artefacts whose
|
|
716
728
|
items were never retrieved — a codelist with zero codes and no error.
|
|
729
|
+
|
|
730
|
+
**So is the depth the projection reaches** (GH-271). A `Select` that
|
|
731
|
+
reads `dataflow.dsd.id` needs `references=children`, and its plan alone
|
|
732
|
+
asks for `none`. Keyed on the derived `references=` value, as `detail=`
|
|
733
|
+
is: keyed on the plan alone, a `collect()` that fetched with `none`
|
|
734
|
+
would satisfy the projection, which would then read null.
|
|
717
735
|
"""
|
|
718
736
|
store = self._query_store()
|
|
719
737
|
key = canonical_key(plan)
|
|
720
738
|
detail = _detail_of(plan, projection)
|
|
739
|
+
references = references_for(plan.root.__table__, closure(plan) | projected_paths)
|
|
721
740
|
scope = str(key)
|
|
722
741
|
# `full` subsumes `allstubs`: everything a stub carries is in a full
|
|
723
742
|
# artefact, so a narrow ask after a wide fetch is pure waste. The
|
|
724
743
|
# reverse does not hold, which is what the key is for.
|
|
725
|
-
if detail != "full" and (key, "full") in self._fetched:
|
|
744
|
+
if detail != "full" and (key, "full", references) in self._fetched:
|
|
726
745
|
return
|
|
727
746
|
self._fetched.run(
|
|
728
|
-
(key, detail),
|
|
729
|
-
lambda: self._fetch_and_scope(store, plan, projection, scope),
|
|
747
|
+
(key, detail, references),
|
|
748
|
+
lambda: self._fetch_and_scope(store, plan, projection, projected_paths, scope),
|
|
730
749
|
)
|
|
731
750
|
|
|
732
751
|
def _fetch_and_scope[R: "RowKind"](
|
|
@@ -734,6 +753,7 @@ class RestRegistry:
|
|
|
734
753
|
store: LocalRegistry,
|
|
735
754
|
plan: Plan[R],
|
|
736
755
|
projection: frozenset[tuple[str, str]] | None,
|
|
756
|
+
projected_paths: frozenset[tuple[str, ...]],
|
|
737
757
|
scope: str,
|
|
738
758
|
) -> None:
|
|
739
759
|
"""Fetch, recording which artefacts came back under `scope` (§5.13).
|
|
@@ -757,7 +777,9 @@ class RestRegistry:
|
|
|
757
777
|
with store.session() as session:
|
|
758
778
|
session.execute("DELETE FROM sdmx.fetch_scope WHERE fetch_key = ?", [scope])
|
|
759
779
|
urns: list[str] = []
|
|
760
|
-
fetch_into(
|
|
780
|
+
fetch_into(
|
|
781
|
+
store, plan, self._client, projection=projection, projected_paths=projected_paths, record=urns.append
|
|
782
|
+
)
|
|
761
783
|
for urn in urns:
|
|
762
784
|
session.execute(
|
|
763
785
|
"INSERT OR IGNORE INTO sdmx.fetch_scope (fetch_key, urn) VALUES (?, ?)",
|
|
@@ -1093,13 +1115,16 @@ class RestRegistry:
|
|
|
1093
1115
|
return flow, dsd
|
|
1094
1116
|
|
|
1095
1117
|
def _fetch_data_for[R: "RowKind"](
|
|
1096
|
-
self,
|
|
1118
|
+
self,
|
|
1119
|
+
plan: Plan[R],
|
|
1120
|
+
_projection: frozenset[tuple[str, str]] | None = None,
|
|
1121
|
+
_projected_paths: frozenset[tuple[str, ...]] = frozenset(),
|
|
1097
1122
|
) -> None:
|
|
1098
1123
|
"""Fetch the slice this plan needs, and replace the table with it.
|
|
1099
1124
|
|
|
1100
|
-
The projection
|
|
1101
|
-
|
|
1102
|
-
columns the key selects either way.
|
|
1125
|
+
The projection and its paths are accepted and ignored: `detail=` and
|
|
1126
|
+
`references=` are *structure* parameters, and a data request has no
|
|
1127
|
+
equivalent — SDMX-CSV returns the columns the key selects either way.
|
|
1103
1128
|
|
|
1104
1129
|
**One table per dataflow, holding one question's rows.** A second,
|
|
1105
1130
|
different query overwrites it — and evicts the first from `_fetched`,
|
|
@@ -1159,17 +1184,19 @@ class RestRegistry:
|
|
|
1159
1184
|
Reads the file's ``DATAFLOW`` / ``STRUCTURE_ID`` column to name the
|
|
1160
1185
|
dataflow, fetches it with its structure, and reads the file with it:
|
|
1161
1186
|
the same `ObsQuery` `obs(flow)` returns, over the file's rows
|
|
1162
|
-
instead of a fetch. A path is read in place on every query
|
|
1163
|
-
loaded once. See
|
|
1187
|
+
instead of a fetch. A path is read in place on every query, and once
|
|
1188
|
+
as it is scanned, to refuse a delete row; bytes are loaded once. See
|
|
1189
|
+
`sdmxlib.local._scan`.
|
|
1164
1190
|
|
|
1165
1191
|
Args:
|
|
1166
1192
|
source: File path or raw SDMX-CSV bytes.
|
|
1167
1193
|
|
|
1168
1194
|
Raises:
|
|
1169
1195
|
ValueError: If the ``DATAFLOW`` column is absent or unparseable.
|
|
1170
|
-
SdmxParseError: If the
|
|
1171
|
-
column the structure declares
|
|
1172
|
-
|
|
1196
|
+
SdmxParseError: If the data is not readable SDMX-CSV, lacks a
|
|
1197
|
+
column the structure declares, or holds a ``D`` (delete) row
|
|
1198
|
+
in its ``ACTION`` column, which says what to remove rather
|
|
1199
|
+
than what was observed.
|
|
1173
1200
|
ValueError: If a value does not fit its component's type, when the
|
|
1174
1201
|
file is read; for a path, when a query reads the value.
|
|
1175
1202
|
|