sdmxlib 0.76.2__tar.gz → 0.77.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.76.2 → sdmxlib-0.77.0}/PKG-INFO +1 -1
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/pyproject.toml +2 -1
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/pyproject.toml.orig +7 -1
- sdmxlib-0.77.0/src/sdmxlib/_read_errors.py +170 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/api/registry.py +19 -9
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_csv/reader.py +10 -6
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/_data_common.py +30 -7
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/_structure_ingest.py +2 -2
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/data.py +11 -2
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/data_v1.py +3 -2
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/data_v2.py +5 -5
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml/_header.py +2 -2
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml/_v3_reader.py +3 -3
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/local/_scan.py +42 -14
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/local/registry.py +8 -2
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/query.py +26 -10
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/LICENSE +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/README.md +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/_duckdb.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/_singleflight.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/_time.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/api/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/api/_freshness.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/api/client.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/api/federated.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/api/policy.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/api/providers.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/api/session.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/builders/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/builders/contentconstraint.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/builders/metadata_annotation.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_availability.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_build.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_canonical.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_check.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_copy.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_fetch.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_finding.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_fingerprint.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_overlay.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_remote.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/_write.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/manifest.schema.json +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/bundle/overlay.schema.json +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/data_store.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/_arrow.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/_attachment.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/_coerce.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/_index.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/_positions.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/_refuse.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/data_format.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/gaps.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/render.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_csv/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_csv/writer.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/_dto.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/_header.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/_losses.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/_periods.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/_resolve.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/_structure_dto.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/metadata.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/reader.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/structure_values.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json/writer.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json_1_0/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_json_1_0/writer.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml/_allowed_children.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml/_closed_world.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml/_common.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml/_losses.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml/_v3_writer.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml21/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml21/_providers.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml21/_synthetic.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml21/namespaces.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml21/reader.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml21/writer.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml30/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml30/metadata.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml30/namespaces.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml30/reader.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml30/writer.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml31/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml31/namespaces.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml31/reader.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/formats/sdmx_ml31/writer.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/local/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/local/data_store.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/local/engine.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/local/object_store.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/local/sql.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_binding.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_container.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_invariants.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_items.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_label_match.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_rebind.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_referenceable.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_refshape.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_resolvers.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_rules.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/_tree.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/annotations.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/base.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/binding.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/category.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/codelist.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/collections.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/concept.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/constraint.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/convert.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/dataflow.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/datastructure.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/errors.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/expr.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/header.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/hierarchy.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/in_memory_registry.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/istring.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/link.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/mapping.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/message.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/metadata_provision.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/metadataflow.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/metadataset.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/metadatastructure.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/organisation.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/provision.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/ref.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/registry.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/representation.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/rest_api.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/rollup.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/urn.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/validation.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/valuelist.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/version.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/model/version_rewrite.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/polars.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/py.typed +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_closure.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_common.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_compile.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_edges.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_execute.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_expr.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_joins.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_plan.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_pushdown.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_rebase.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/_rest.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/accessors.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/observations.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/raw.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/query/schema.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/rest.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/session.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/sql.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/__init__.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/_checked.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/_columns.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/_kinds.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/_manifest.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/_parsed.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/_projections.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/_references.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/_synthetic.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/_trim.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/lazy.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/readers.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/resolve.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/schema.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/storage/writers.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.0}/src/sdmxlib/testing.py +0 -0
- {sdmxlib-0.76.2 → sdmxlib-0.77.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.77.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.77.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"
|
|
@@ -134,6 +134,7 @@ dev = [
|
|
|
134
134
|
"sqlglot>=27.0",
|
|
135
135
|
"fastapi>=0.115",
|
|
136
136
|
]
|
|
137
|
+
fuzz = ["atheris>=3.1.0,<3.2; sys_platform == 'linux' and platform_machine == 'x86_64'"]
|
|
137
138
|
bench-compete = [
|
|
138
139
|
"sdmx1>=2.27.0",
|
|
139
140
|
"pysdmx[xml,json]>=1.20.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sdmxlib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.77.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"
|
|
@@ -171,6 +171,12 @@ dev = [
|
|
|
171
171
|
# dependency and must not become one: sdmxlib has no web framework.
|
|
172
172
|
"fastapi>=0.115",
|
|
173
173
|
]
|
|
174
|
+
# The fuzzer (GH-241), installed only by .github/workflows/fuzz.yml. Atheris
|
|
175
|
+
# ships Linux x86_64 wheels only, so the marker keeps a macOS or ARM sync from
|
|
176
|
+
# trying to build it; crash inputs replay without it (test_fuzz_crashes.py).
|
|
177
|
+
fuzz = [
|
|
178
|
+
"atheris>=3.1.0,<3.2; sys_platform == 'linux' and platform_machine == 'x86_64'",
|
|
179
|
+
]
|
|
174
180
|
# Optional: third-party SDMX libraries for the competitive benchmarks
|
|
175
181
|
# (tests/bench/test_compete.py, and `just bench-compete` — bench/compete/).
|
|
176
182
|
# Install via `uv sync --group bench-compete`.
|
|
@@ -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()` / `data()` 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())
|
|
@@ -9,6 +9,7 @@ from typing import Literal, Never, Self, Unpack, cast, overload
|
|
|
9
9
|
|
|
10
10
|
import attrs
|
|
11
11
|
|
|
12
|
+
from sdmxlib._read_errors import reading_csv
|
|
12
13
|
from sdmxlib._singleflight import SingleFlight
|
|
13
14
|
from sdmxlib.api.client import NOT_MODIFIED, HttpxAuthOption, HttpxOptions, HttpxTransportOptions, SdmxClient
|
|
14
15
|
from sdmxlib.api.providers import ProviderInfo
|
|
@@ -1140,13 +1141,16 @@ class RestRegistry:
|
|
|
1140
1141
|
csv_path = Path(tmp) / "data.csv"
|
|
1141
1142
|
self._client.stream_data_at(request.path, request.params, to=csv_path)
|
|
1142
1143
|
schema, _, name = root.binding.table_location.partition(".")
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1144
|
+
# A provider's response is read here, in full, so what DuckDB
|
|
1145
|
+
# cannot read is reported as the response's fault (GH-247).
|
|
1146
|
+
with reading_csv(structure=root.dsd.id):
|
|
1147
|
+
DuckDBDataStore.from_registry(self._query_store()).ingest_csv(
|
|
1148
|
+
schema=schema,
|
|
1149
|
+
table=name,
|
|
1150
|
+
path=csv_path,
|
|
1151
|
+
types=column_types(root.binding, root.dsd),
|
|
1152
|
+
lake_alias=root.binding.database_role,
|
|
1153
|
+
)
|
|
1150
1154
|
self._fetched_data[table] = key
|
|
1151
1155
|
|
|
1152
1156
|
def scan_csv(self, source: str | Path | bytes) -> ObsQuery:
|
|
@@ -1163,6 +1167,11 @@ class RestRegistry:
|
|
|
1163
1167
|
|
|
1164
1168
|
Raises:
|
|
1165
1169
|
ValueError: If the ``DATAFLOW`` column is absent or unparseable.
|
|
1170
|
+
SdmxParseError: If the bytes are not readable SDMX-CSV, or lack a
|
|
1171
|
+
column the structure declares. For a path, a row DuckDB cannot
|
|
1172
|
+
read raises it when a query reads that row.
|
|
1173
|
+
ValueError: If a value does not fit its component's type, when the
|
|
1174
|
+
file is read; for a path, when a query reads the value.
|
|
1166
1175
|
|
|
1167
1176
|
Example:
|
|
1168
1177
|
with sl.RestRegistry(sl.Provider.ECB) as reg:
|
|
@@ -1215,8 +1224,9 @@ class RestRegistry:
|
|
|
1215
1224
|
An `ObsQuery` over the message's observations.
|
|
1216
1225
|
|
|
1217
1226
|
Raises:
|
|
1218
|
-
|
|
1219
|
-
|
|
1227
|
+
SdmxParseError: If the message is not a readable SDMX-JSON data message.
|
|
1228
|
+
ValueError: If it names no dataflow, or holds a value that does not
|
|
1229
|
+
fit its component's type.
|
|
1220
1230
|
"""
|
|
1221
1231
|
frame, urn = read_observations(source)
|
|
1222
1232
|
|
|
@@ -22,6 +22,7 @@ from typing import Final
|
|
|
22
22
|
|
|
23
23
|
from sdmxlib.model.dataflow import Dataflow
|
|
24
24
|
from sdmxlib.model.datastructure import DataStructure
|
|
25
|
+
from sdmxlib.model.errors import SdmxParseError
|
|
25
26
|
from sdmxlib.model.provision import ProvisionAgreement
|
|
26
27
|
from sdmxlib.model.ref import Ref
|
|
27
28
|
from sdmxlib.model.registry import SupportsGet
|
|
@@ -94,17 +95,20 @@ def _peek_structure(source: str | Path | bytes) -> tuple[str | None, str | None]
|
|
|
94
95
|
``STRUCTURE`` column at all — its ``DATAFLOW`` implies the kind — so the
|
|
95
96
|
first element is None there and the caller treats it as a dataflow.
|
|
96
97
|
"""
|
|
97
|
-
if isinstance(source, (str, Path)):
|
|
98
|
-
with Path(source).open(newline="", encoding="utf-8") as f:
|
|
99
|
-
head = f.read(4096)
|
|
100
|
-
else:
|
|
101
|
-
head = source[:4096].decode("utf-8", errors="replace")
|
|
102
|
-
reader = csv.reader(io.StringIO(head))
|
|
103
98
|
try:
|
|
99
|
+
if isinstance(source, (str, Path)):
|
|
100
|
+
with Path(source).open(newline="", encoding="utf-8") as f:
|
|
101
|
+
head = f.read(4096)
|
|
102
|
+
else:
|
|
103
|
+
head = source[:4096].decode("utf-8", errors="replace")
|
|
104
|
+
reader = csv.reader(io.StringIO(head))
|
|
104
105
|
header = next(reader)
|
|
105
106
|
first_row = next(reader)
|
|
106
107
|
except StopIteration:
|
|
107
108
|
return None, None
|
|
109
|
+
except (csv.Error, UnicodeDecodeError) as exc:
|
|
110
|
+
msg = f"the SDMX-CSV header could not be read: {exc}"
|
|
111
|
+
raise SdmxParseError(msg) from exc
|
|
108
112
|
|
|
109
113
|
def value(column: str) -> str | None:
|
|
110
114
|
if column not in header:
|
|
@@ -11,6 +11,7 @@ deltas.
|
|
|
11
11
|
|
|
12
12
|
import calendar
|
|
13
13
|
import re
|
|
14
|
+
from collections.abc import Sequence
|
|
14
15
|
from datetime import datetime, timedelta
|
|
15
16
|
from typing import Literal, NamedTuple, TypedDict
|
|
16
17
|
|
|
@@ -931,7 +932,7 @@ def decode_observations(
|
|
|
931
932
|
# don't see a silently truncated frame.
|
|
932
933
|
if dim_decl.series or attr_decl.series:
|
|
933
934
|
msg = "SDMX-JSON series layout is not supported by the reader yet — only flat layout"
|
|
934
|
-
raise
|
|
935
|
+
raise SdmxParseError(msg)
|
|
935
936
|
|
|
936
937
|
ds_dim_ids = [d.id for d in ds_dims]
|
|
937
938
|
obs_dim_ids = [d.id for d in obs_dims]
|
|
@@ -939,7 +940,7 @@ def decode_observations(
|
|
|
939
940
|
obs_attr_ids = [a.id for a in obs_attrs]
|
|
940
941
|
|
|
941
942
|
# dataSet-level values are scalar (every dim has exactly one value).
|
|
942
|
-
ds_dim_const = [_value_label(d.values
|
|
943
|
+
ds_dim_const = [_value_label(_value_at(d.values, 0)) for d in ds_dims]
|
|
943
944
|
ds_attr_const = _decode_dataset_attrs(ds_attrs, dataset_block.attributes)
|
|
944
945
|
|
|
945
946
|
obs_dim_values = [[_value_label(v) for v in d.values] for d in obs_dims]
|
|
@@ -954,10 +955,10 @@ def decode_observations(
|
|
|
954
955
|
f"Observation key {key!r} has {len(positions)} positions but "
|
|
955
956
|
f"the structure declares {len(obs_dim_ids)} observation dimensions"
|
|
956
957
|
)
|
|
957
|
-
raise
|
|
958
|
+
raise SdmxParseError(msg)
|
|
958
959
|
row: list[object] = list(ds_dim_const)
|
|
959
960
|
for col_idx, pos in enumerate(positions):
|
|
960
|
-
row.append(obs_dim_values[col_idx]
|
|
961
|
+
row.append(_value_at(obs_dim_values[col_idx], _wire_position(pos, what="observation key position")))
|
|
961
962
|
|
|
962
963
|
# First slot is the measure; remaining slots are attribute positions
|
|
963
964
|
# into their respective code lists (or None for unset).
|
|
@@ -969,7 +970,8 @@ def decode_observations(
|
|
|
969
970
|
if raw is None:
|
|
970
971
|
row.append(None)
|
|
971
972
|
else:
|
|
972
|
-
|
|
973
|
+
position = _wire_position(raw, what="observation attribute position")
|
|
974
|
+
row.append(_value_at(obs_attr_values[col_idx], position))
|
|
973
975
|
rows.append(row)
|
|
974
976
|
return (
|
|
975
977
|
[*ds_dim_ids, *obs_dim_ids],
|
|
@@ -990,12 +992,26 @@ def _wire_position(raw: object, *, what: str) -> int:
|
|
|
990
992
|
"""
|
|
991
993
|
if isinstance(raw, str):
|
|
992
994
|
return to_int(raw, what=what)
|
|
993
|
-
if isinstance(raw,
|
|
995
|
+
if isinstance(raw, int) and not isinstance(raw, bool):
|
|
996
|
+
return raw
|
|
997
|
+
if isinstance(raw, float) and raw.is_integer():
|
|
994
998
|
return int(raw)
|
|
995
999
|
msg = f"{what} must be a position into the declaration's values, got {raw!r}"
|
|
996
1000
|
raise SdmxParseError(msg)
|
|
997
1001
|
|
|
998
1002
|
|
|
1003
|
+
def _value_at[V](values: Sequence[V], position: int) -> V:
|
|
1004
|
+
"""The declaration's value at a wire `position`, or `SdmxParseError` when there is none.
|
|
1005
|
+
|
|
1006
|
+
A position comes out of the payload, so one past the declaration's end, or
|
|
1007
|
+
negative, is a malformed message rather than Python's ``IndexError``.
|
|
1008
|
+
"""
|
|
1009
|
+
if 0 <= position < len(values):
|
|
1010
|
+
return values[position]
|
|
1011
|
+
msg = f"position {position} is outside the declaration's {len(values)} values"
|
|
1012
|
+
raise SdmxParseError(msg)
|
|
1013
|
+
|
|
1014
|
+
|
|
999
1015
|
def _decode_dataset_attrs(
|
|
1000
1016
|
attr_decls: list[ComponentDeclJson],
|
|
1001
1017
|
dataset_attr_values: list[object],
|
|
@@ -1042,10 +1058,17 @@ def rows_to_lazyframe(
|
|
|
1042
1058
|
Empty inputs yield an empty frame with the declared column set.
|
|
1043
1059
|
"""
|
|
1044
1060
|
columns = [*dim_ids, measure_id, *attr_ids]
|
|
1061
|
+
if len(set(columns)) != len(columns):
|
|
1062
|
+
repeated = sorted({c for c in columns if columns.count(c) > 1})
|
|
1063
|
+
msg = f"the structure declares {', '.join(repeated)} more than once"
|
|
1064
|
+
raise SdmxParseError(msg)
|
|
1045
1065
|
if not rows:
|
|
1046
1066
|
return pl.LazyFrame({c: [] for c in columns})
|
|
1047
1067
|
data: dict[str, list[object]] = {c: [] for c in columns}
|
|
1048
1068
|
for row in rows:
|
|
1049
1069
|
for col, val in zip(columns, row, strict=True):
|
|
1050
1070
|
data[col].append(val)
|
|
1051
|
-
|
|
1071
|
+
# Not strict: a measure of JSON numbers `1` and `-2.25` is a Float64
|
|
1072
|
+
# column, which the strict default refuses as an Int64 meeting a float.
|
|
1073
|
+
# Text among numbers makes a String column, which the DSD's types check.
|
|
1074
|
+
return pl.LazyFrame([pl.Series(c, data[c], strict=False) for c in columns])
|
|
@@ -1533,7 +1533,7 @@ def _date_map_kwargs(m: DateMapJson) -> _DateMapKwargs:
|
|
|
1533
1533
|
return {
|
|
1534
1534
|
"id": m.id,
|
|
1535
1535
|
"component_maps": tuple((c.source, c.target) for c in m.mapped_components),
|
|
1536
|
-
"resolve_period": ResolvePeriod
|
|
1536
|
+
"resolve_period": to_enum(ResolvePeriod, m.resolve_period, what="resolvePeriod") if m.resolve_period else None,
|
|
1537
1537
|
"frequency_dimension": m.frequency_dimension,
|
|
1538
1538
|
"mapped_frequencies": tuple(m.mapped_frequencies or []),
|
|
1539
1539
|
"target_frequency_id": m.target_frequency_id,
|
|
@@ -1566,7 +1566,7 @@ def from_structure_map(sm: StructureMapJson, maintainer: Agency) -> StructureMap
|
|
|
1566
1566
|
EpochMap(
|
|
1567
1567
|
**_date_map_kwargs(m),
|
|
1568
1568
|
base_period=m.base_period,
|
|
1569
|
-
epoch_period=EpochPeriod
|
|
1569
|
+
epoch_period=to_enum(EpochPeriod, m.epoch_period or ASSUMED_EPOCH_PERIOD, what="epochPeriod"),
|
|
1570
1570
|
)
|
|
1571
1571
|
for m in sm.epoch_maps or []
|
|
1572
1572
|
),
|
|
@@ -11,6 +11,7 @@ import msgspec
|
|
|
11
11
|
import polars as pl
|
|
12
12
|
|
|
13
13
|
from sdmxlib.formats.sdmx_json import data_v1, data_v2
|
|
14
|
+
from sdmxlib.model.errors import SdmxParseError
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class _Envelope(msgspec.Struct):
|
|
@@ -28,7 +29,15 @@ def read_observations(source: bytes | str | Path) -> tuple[pl.DataFrame, str | N
|
|
|
28
29
|
|
|
29
30
|
Returns:
|
|
30
31
|
What `data_v2.read_observations` / `data_v1.read_observations` return.
|
|
32
|
+
|
|
33
|
+
Raises:
|
|
34
|
+
SdmxParseError: If `source` is not a readable SDMX-JSON data message.
|
|
35
|
+
msgspec's error, or a bad UTF-8 sequence, is the ``__cause__``.
|
|
31
36
|
"""
|
|
32
37
|
raw = source if isinstance(source, bytes) else Path(source).read_bytes()
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
try:
|
|
39
|
+
envelope = msgspec.json.decode(raw, type=_Envelope)
|
|
40
|
+
return (data_v2 if len(envelope.data) else data_v1).read_observations(raw)
|
|
41
|
+
except (msgspec.MsgspecError, UnicodeDecodeError) as exc:
|
|
42
|
+
msg = f"could not read {len(raw)} bytes as an SDMX-JSON data message: {exc}"
|
|
43
|
+
raise SdmxParseError(msg) from exc
|
|
@@ -60,6 +60,7 @@ from sdmxlib.formats.sdmx_json._data_common import (
|
|
|
60
60
|
from sdmxlib.formats.sdmx_json._dto import ENCODER, _camel_rename, prepared_text
|
|
61
61
|
from sdmxlib.model.dataflow import Dataflow
|
|
62
62
|
from sdmxlib.model.datastructure import DataStructure
|
|
63
|
+
from sdmxlib.model.errors import SdmxParseError
|
|
63
64
|
from sdmxlib.model.ref import Ref
|
|
64
65
|
|
|
65
66
|
ActionLiteral = Literal["Information", "Append", "Replace", "Delete"]
|
|
@@ -194,12 +195,12 @@ def read_observations(source: bytes | str | Path) -> tuple[pl.DataFrame, str | N
|
|
|
194
195
|
``rel="dataflow"`` link's URN, or `None` when the message has none.
|
|
195
196
|
|
|
196
197
|
Raises:
|
|
197
|
-
|
|
198
|
+
SdmxParseError: If the document is not a recognisable data message of this version.
|
|
198
199
|
"""
|
|
199
200
|
payload = _load(source)
|
|
200
201
|
if not payload.data_sets or payload.structure is None:
|
|
201
202
|
msg = "Source does not look like a SDMX-JSON 1.0 data message — missing top-level dataSets / structure"
|
|
202
|
-
raise
|
|
203
|
+
raise SdmxParseError(msg)
|
|
203
204
|
dataset_block = payload.data_sets[0]
|
|
204
205
|
structure_block = payload.structure
|
|
205
206
|
|
|
@@ -74,6 +74,7 @@ from sdmxlib.formats.sdmx_json._data_common import (
|
|
|
74
74
|
from sdmxlib.formats.sdmx_json._dto import ENCODER, _camel_rename, prepared_text
|
|
75
75
|
from sdmxlib.model.dataflow import Dataflow
|
|
76
76
|
from sdmxlib.model.datastructure import DataStructure
|
|
77
|
+
from sdmxlib.model.errors import SdmxParseError
|
|
77
78
|
from sdmxlib.model.ref import Ref
|
|
78
79
|
|
|
79
80
|
#: The SDMX-JSON 2.0.0 data schema, where SDMX publishes it and FMR points, as
|
|
@@ -219,12 +220,12 @@ def read_observations(source: bytes | str | Path) -> tuple[pl.DataFrame, str | N
|
|
|
219
220
|
``rel="dataflow"`` link's URN, or `None` when the message has none.
|
|
220
221
|
|
|
221
222
|
Raises:
|
|
222
|
-
|
|
223
|
+
SdmxParseError: If the document is not a recognisable data message of this version.
|
|
223
224
|
"""
|
|
224
225
|
payload = _load(source).data
|
|
225
226
|
if payload is None or not payload.data_sets or not payload.structures:
|
|
226
227
|
msg = "Source does not look like a SDMX-JSON 2.0 data message — missing data.dataSets / data.structures"
|
|
227
|
-
raise
|
|
228
|
+
raise SdmxParseError(msg)
|
|
228
229
|
dataset_block = payload.data_sets[0]
|
|
229
230
|
structure_block = payload.structures[0]
|
|
230
231
|
|
|
@@ -248,9 +249,8 @@ class _DataMessageJson(msgspec.Struct):
|
|
|
248
249
|
def _load(source: bytes | str | Path) -> _DataMessageJson:
|
|
249
250
|
"""Decode *source* into the typed envelope.
|
|
250
251
|
|
|
251
|
-
A shape violation surfaces as ``msgspec.ValidationError``, which
|
|
252
|
-
|
|
253
|
-
still holds for a malformed document.
|
|
252
|
+
A shape violation surfaces as ``msgspec.ValidationError``, which
|
|
253
|
+
`sdmx_json.data.read_observations` converts to `SdmxParseError`.
|
|
254
254
|
"""
|
|
255
255
|
if isinstance(source, (bytes, bytearray)):
|
|
256
256
|
return msgspec.json.decode(source, type=_DataMessageJson)
|
|
@@ -16,7 +16,7 @@ from datetime import datetime
|
|
|
16
16
|
from lxml import etree
|
|
17
17
|
from typing_extensions import TypedDict
|
|
18
18
|
|
|
19
|
-
from sdmxlib.formats._coerce import to_datetime
|
|
19
|
+
from sdmxlib.formats._coerce import to_datetime, to_enum
|
|
20
20
|
from sdmxlib.model.errors import ReadGap, SdmxParseError, ValidationError
|
|
21
21
|
from sdmxlib.model.header import ActionType, Header, MetadataHeader, Party, Sender
|
|
22
22
|
from sdmxlib.model.istring import InternationalString
|
|
@@ -168,7 +168,7 @@ def _metadata_header(root: etree._Element, el: etree._Element, *, com: str) -> M
|
|
|
168
168
|
metadata_provider=None
|
|
169
169
|
if provider is None
|
|
170
170
|
else Ref[MetadataProvider].unresolved(MetadataProvider.parse_urn(provider.strip())),
|
|
171
|
-
data_set_action=None if action is None else ActionType
|
|
171
|
+
data_set_action=None if action is None else to_enum(ActionType, action.strip(), what="Header/DataSetAction"),
|
|
172
172
|
data_set_ids=tuple((each.text or "").strip() for each in el.findall(f"{{{mes}}}DataSetID")),
|
|
173
173
|
extracted=None if extracted is None else to_datetime(extracted.strip(), what="Header/Extracted"),
|
|
174
174
|
)
|
|
@@ -33,7 +33,7 @@ from lxml import etree
|
|
|
33
33
|
from typing_extensions import TypedDict
|
|
34
34
|
|
|
35
35
|
from sdmxlib.formats._attachment import match_dimension_case
|
|
36
|
-
from sdmxlib.formats._coerce import to_date, to_int
|
|
36
|
+
from sdmxlib.formats._coerce import to_date, to_enum, to_int
|
|
37
37
|
from sdmxlib.formats._positions import check_positions
|
|
38
38
|
from sdmxlib.formats._refuse import build_each_xml
|
|
39
39
|
from sdmxlib.formats.sdmx_ml._closed_world import required
|
|
@@ -718,7 +718,7 @@ class V3Reader:
|
|
|
718
718
|
"frequency_dimension": el.findtext("str:FrequencyDimension", namespaces=self._ns),
|
|
719
719
|
"mapped_frequencies": tuple(self._texts(el, "MappedFrequencies")),
|
|
720
720
|
"target_frequency_id": el.findtext("str:TargetFrequencyID", namespaces=self._ns),
|
|
721
|
-
"resolve_period": ResolvePeriod
|
|
721
|
+
"resolve_period": to_enum(ResolvePeriod, resolve, what="resolvePeriod") if resolve else None,
|
|
722
722
|
}
|
|
723
723
|
|
|
724
724
|
def _read_structure_map_parts(self, el: etree._Element) -> _StructureMapParts:
|
|
@@ -728,7 +728,7 @@ class V3Reader:
|
|
|
728
728
|
EpochMap(
|
|
729
729
|
**self._date_map_fields(em_el),
|
|
730
730
|
base_period=required(em_el, "basePeriod"),
|
|
731
|
-
epoch_period=EpochPeriod
|
|
731
|
+
epoch_period=to_enum(EpochPeriod, em_el.get("epochPeriod", "day"), what="epochPeriod"),
|
|
732
732
|
)
|
|
733
733
|
for em_el in el.findall("str:EpochMap", namespaces=self._ns)
|
|
734
734
|
),
|
|
@@ -31,19 +31,18 @@ from pathlib import Path
|
|
|
31
31
|
|
|
32
32
|
import polars as pl
|
|
33
33
|
|
|
34
|
+
from sdmxlib._read_errors import SCANS, reading_csv, type_mismatch
|
|
34
35
|
from sdmxlib.local.data_store import DuckDBDataStore, column_types
|
|
35
36
|
from sdmxlib.local.object_store import sql_literal
|
|
36
37
|
from sdmxlib.model.binding import DataflowBinding
|
|
37
38
|
from sdmxlib.model.dataflow import Dataflow
|
|
38
39
|
from sdmxlib.model.datastructure import DataStructure
|
|
40
|
+
from sdmxlib.model.errors import SdmxParseError
|
|
39
41
|
from sdmxlib.model.ref import Ref
|
|
40
42
|
from sdmxlib.model.urn import SdmxUrn
|
|
41
43
|
from sdmxlib.query.observations import ObsQuery
|
|
42
44
|
from sdmxlib.session import completed
|
|
43
45
|
|
|
44
|
-
#: The catalog every scan's relation lives in — see the module docstring.
|
|
45
|
-
SCANS = "sdmx_scans"
|
|
46
|
-
|
|
47
46
|
|
|
48
47
|
def scan_csv_into(
|
|
49
48
|
plane: DuckDBDataStore, source: str | Path | bytes, *, dsd: DataStructure, dataflow: Ref[Dataflow]
|
|
@@ -65,18 +64,44 @@ def scan_csv_into(
|
|
|
65
64
|
with tempfile.TemporaryDirectory(prefix="sdmxlib-scan-") as tmp:
|
|
66
65
|
path = Path(tmp) / "data.csv"
|
|
67
66
|
path.write_bytes(source)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
with reading_csv(structure=dsd.id):
|
|
68
|
+
plane.connection.execute(
|
|
69
|
+
f"CREATE TABLE {relation} AS SELECT * FROM read_csv(?, types=?, header=true)", [str(path), types]
|
|
70
|
+
)
|
|
71
71
|
else:
|
|
72
72
|
literal_types = ", ".join(f"{sql_literal(c)}: {sql_literal(t)}" for c, t in types.items())
|
|
73
73
|
path_literal = sql_literal(str(Path(source).resolve()))
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
74
|
+
# DuckDB reads the header when the view is made, and the rows when a
|
|
75
|
+
# query runs; the query terminals convert what those raise.
|
|
76
|
+
with reading_csv(structure=dsd.id):
|
|
77
|
+
read = f"read_csv({path_literal}, types={{{literal_types}}}, header=true)"
|
|
78
|
+
plane.connection.execute(f"CREATE VIEW {relation} AS SELECT * FROM {read}")
|
|
79
|
+
_require_columns(plane, relation, binding)
|
|
77
80
|
return plane.obs(binding, dsd=dsd)
|
|
78
81
|
|
|
79
82
|
|
|
83
|
+
def _require_columns(plane: DuckDBDataStore, relation: str, binding: DataflowBinding) -> None:
|
|
84
|
+
"""Refuse a file without a column the binding reads, before a query finds out.
|
|
85
|
+
|
|
86
|
+
A forced column that is absent already fails the read. A measure the DSD
|
|
87
|
+
leaves untyped is not forced (`column_types`), so without this a file
|
|
88
|
+
lacking it would scan and then fail every query on a binder error.
|
|
89
|
+
|
|
90
|
+
Raises:
|
|
91
|
+
SdmxParseError: If a dimension, measure or attribute column is absent.
|
|
92
|
+
"""
|
|
93
|
+
present = {row[0] for row in plane.connection.execute(f"DESCRIBE {relation}").fetchall()}
|
|
94
|
+
wanted = [
|
|
95
|
+
*binding.dimension_column_map.values(),
|
|
96
|
+
*binding.measure_column_map.values(),
|
|
97
|
+
*binding.attribute_column_map.values(),
|
|
98
|
+
]
|
|
99
|
+
missing = [column for column in wanted if column not in present]
|
|
100
|
+
if missing:
|
|
101
|
+
msg = f"the SDMX-CSV data has no {', '.join(missing)} column, which its structure declares"
|
|
102
|
+
raise SdmxParseError(msg)
|
|
103
|
+
|
|
104
|
+
|
|
80
105
|
def scan_frame_into(
|
|
81
106
|
plane: DuckDBDataStore, frame: pl.DataFrame, *, dsd: DataStructure, dataflow: Ref[Dataflow]
|
|
82
107
|
) -> ObsQuery:
|
|
@@ -95,11 +120,14 @@ def scan_frame_into(
|
|
|
95
120
|
A query over the rows, typed from `dsd` as any is.
|
|
96
121
|
"""
|
|
97
122
|
binding, relation = _new_relation(plane, dsd, dataflow)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
123
|
+
try:
|
|
124
|
+
typed = frame.with_columns(
|
|
125
|
+
pl.col(column).cast(_POLARS_TYPE[duckdb_type])
|
|
126
|
+
for column, duckdb_type in column_types(binding, dsd).items()
|
|
127
|
+
if column in frame.columns
|
|
128
|
+
)
|
|
129
|
+
except pl.exceptions.PolarsError as exc:
|
|
130
|
+
raise type_mismatch(dsd.id, exc) from exc
|
|
103
131
|
name = relation.rpartition(".")[2]
|
|
104
132
|
completed(plane.connection).register(name, typed.to_arrow())
|
|
105
133
|
try:
|