Skip to content

Commit 5a6ea56

Browse files
authored
Merge pull request #227 from khaeru/enh/2025-w08
Miscellaneous improvements from 2025-W08
2 parents 5588f01 + 3504cdf commit 5a6ea56

25 files changed

+1175
-401
lines changed

doc/api/model-common-list.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
:obj:`~.common.ActionType`
44
:obj:`~.common.Agency`
55
:obj:`~.common.AgencyScheme`
6+
:obj:`~.common.AllDimensions`
67
:obj:`~.common.AnnotableArtefact`
7-
:obj:`~.common.Annotation`
88
:obj:`~.common.AttributeDescriptor`
99
:obj:`~.common.AttributeRelationship`
1010
:obj:`~.common.AttributeValue`
@@ -77,6 +77,7 @@
7777
:obj:`~.common.ToVTLSpaceKey`
7878
:obj:`~.common.Transformation`
7979
:obj:`~.common.TransformationScheme`
80+
:obj:`~.common.UsageStatus`
8081
:obj:`~.common.UserDefinedOperator`
8182
:obj:`~.common.UserDefinedOperatorScheme`
8283
:obj:`~.common.VTLConceptMapping`

doc/api/model-v21-list.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.. This file is auto-generated by doc/conf.py.
22
33
:obj:`~.v21.AfterPeriod`
4+
:obj:`~.v21.Annotation`
45
:obj:`~.v21.BeforePeriod`
56
:obj:`~.v21.CodeMap`
67
:obj:`~.v21.CodelistMap`

doc/api/model-v30-list.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.. This file is auto-generated by doc/conf.py.
22
33
:obj:`~.v30.AfterPeriod`
4+
:obj:`~.v30.Annotation`
45
:obj:`~.v30.BeforePeriod`
6+
:obj:`~.v30.CodeSelection`
57
:obj:`~.v30.CodedMetadataAttributeValue`
68
:obj:`~.v30.CodelistExtension`
79
:obj:`~.v30.Constraint`
@@ -12,6 +14,7 @@
1214
:obj:`~.v30.DataStructureDefinition`
1315
:obj:`~.v30.Dataflow`
1416
:obj:`~.v30.DataflowRelationship`
17+
:obj:`~.v30.ExclusiveCodeSelection`
1518
:obj:`~.v30.GeoCodelist`
1619
:obj:`~.v30.GeoFeatureSetCode`
1720
:obj:`~.v30.GeoGridCode`
@@ -21,6 +24,7 @@
2124
:obj:`~.v30.Hierarchy`
2225
:obj:`~.v30.HierarchyAssociation`
2326
:obj:`~.v30.IdentifiableObjectSelection`
27+
:obj:`~.v30.InclusiveCodeSelection`
2428
:obj:`~.v30.Measure`
2529
:obj:`~.v30.MeasureDescriptor`
2630
:obj:`~.v30.MeasureRelationship`

doc/example.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ These include *structural metadata* that together completely describe the data a
2424
sm
2525
2626
:py:`sm` is a Python object of class :class:`.StructureMessage`.
27-
We can explore some of the specific artifacts—for example, two **code lists**—using :meth:`.StructureMessage.get` to retrieve them and :func:`.to_pandas` to convert to :class:`.pandas.Series`:
27+
We can explore some of the specific artifacts—for example, three **code lists**—using :meth:`.StructureMessage.get` to retrieve them and :func:`.to_pandas` to convert to :class:`.pandas.Series`:
2828

2929
.. ipython:: python
3030
31-
for cl in "AGE", "SEX":
31+
for cl in "AGE(10.3)", "SEX(1.13)", "UNIT(55.0)":
3232
print(sdmx.to_pandas(sm.get(cl)))
3333
3434
Next, we download a **data set** containing a portion of the data in this data flow, structured by this DSD.

doc/implementation.rst

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,61 @@ Implementation notes
44
:mod:`sdmx` aims for a **precise, Pythonic, and useful implementation of the SDMX standards**.
55
This means:
66

7-
- Classes and their attributes have the same names, types, cardinality that appear in the standard.
7+
- Classes and their attributes have the names, types, cardinality, and directionality given in the standard.
88

9-
- Where the standard uses non-Pythonic naming conventions (for instance, "dimensionAtObservation"), :mod:`sdmx` follows the `PEP-8 naming conventions <https://peps.python.org/pep-0008/#naming-conventions>`_ (for instance, "dimension_at_observation" for an attribute).
9+
- Where the standard has non-Pythonic names (for instance, "dimensionAtObservation"), :mod:`sdmx` follows the `PEP-8 naming conventions <https://peps.python.org/pep-0008/#naming-conventions>`_ (for instance, "dimension_at_observation" for a class attribute).
1010
- Where the standard is ambiguous or imprecise itself, implementation (for instance, naming) choices in :mod:`sdmx` are clearly labelled.
1111

1212
- Extensions, additional features, and conveniences in :mod:`sdmx` that do not appear in the standards are clearly labeled.
13-
- All behaviour visible “in the wild”—that is, from publicly available data sources and files—is supported, so long as it is verifiably standards compliant.
13+
- All behaviour visible “in the wild”—that is, from publicly available data sources and files—is either:
14+
15+
- supported, if it is verifiably standards-compliant, or
16+
- tolerated if otherwise, so long as this does not complicate the implementation of standards.
17+
Non-standard content is flagged using log messages and by other means.
1418

1519
This page gives brief explanations of **how** this implementation is achieved.
1620
Although this page is organized (see the contents in the sidebar) to correspond to the standards, it (:ref:`again <not-the-standard>`) **does not restate them** or set out to explain all their details.
1721
For those purposes, see :doc:`resources`; or the :doc:`walkthrough`, which includes some incidental explanations.
1822

1923
.. _sdmx-version-policy:
2024

21-
SDMX standard versions 2.0, 2.1, and 3.0
22-
========================================
25+
Standards versions
26+
==================
2327

28+
SDMX standards documents are available `on the SDMX website <https://sdmx.org/?page_id=5008>`__ and via links to other locations.
2429
Multiple versions of the SDMX standards have been adopted:
2530

2631
- 2.0 in November 2005.
2732
- 2.1 in August 2011; published at the International Standards Organization (ISO) in January 2013; and revised multiple times since.
28-
- 3.0 in October 2021.
29-
30-
The standards are available on the SDMX website: https://sdmx.org/?page_id=5008
31-
32-
- In SDMX 2.1, sections of the standards were numbered from 1 to 7.
33-
For instance, the :ref:`im` is Section 2.
34-
- From SDMX 3.0, some of these section numbers have been removed.
35-
For instance, SDMX-ML was described in SDMX 2.1 sections 3A and 3B; in SDMX 3.0, these section numbers are no longer used, replaced with a reference to the SDMX Technical Working Group (TWG) Git repository at https://github.com/sdmx-twg/sdmx-ml .
36-
- Some of these sections or sub-standards are versioned differently from the overall standard.
37-
See in particular :ref:`sdmx-csv`, :ref:`sdmx-json`, and :ref:`sdmx-rest` below.
33+
- 3.0.0 in October 2021.
34+
- 3.1 planned for some time in 2025.
35+
36+
Some notes about the organization of the standards:
37+
38+
- In SDMX 2.1, **‘sections’** of the standards were numbered from 1 to 7.
39+
For instance, the :ref:`im` is referred to as “Section 2”.
40+
41+
- This is distinct from numbered sections or headings *within* the particular standards documents.
42+
For instance, SDMX 2.1 Section 2 “Information Model/UML Conceptual Design” is a document that contains numbered sections/headings such as “2. Actors and Use Cases” and “2.1. Introduction.”
43+
Documentation and code comments for the :mod:`sdmx` package attempts to be unambiguous about such references, and uses the “§” character to refer to these (sub-)headings.
44+
- From SDMX 3.0.0, some of these section numbers have been removed or disused.
45+
For instance, the SDMX-ML file format was described in SDMX 2.1 sections 3A and 3B; in SDMX 3.0.0, these section numbers are no longer used, replaced with a reference to the SDMX Technical Working Group (TWG) Git repository at https://github.com/sdmx-twg/sdmx-ml.
46+
- Some of the sections or component standards are versioned differently from SDMX as a whole.
47+
The following table lists the *apparent* correspondences between versions of the component standards (The SDMX TWG does not publish such a table, so this should not be taken as official):
48+
49+
======== ========================== =============== =============== ==========================
50+
SDMX SDMX-REST SDMX-CSV SDMX-JSON SDMX-ML
51+
======== ========================== =============== =============== ==========================
52+
1.0 (not versioned separately) (did not exist) (did not exist) (not versioned separately)
53+
2.0 (not versioned separately) (did not exist) (did not exist) (not versioned separately)
54+
2.1 1.x; latest 1.5 1.0 1.0 (not versioned separately)
55+
3.0.0 2.x; latest 2.2 2.0.0 2.0.0 3.0.0
56+
3.1 ? ? ? ?
57+
======== ========================== =============== =============== ==========================
58+
59+
See further details under the :ref:`sdmx-csv`, :ref:`sdmx-json`, and :ref:`sdmx-rest` sections, below.
60+
- The version numbers `do not <https://github.com/sdmx-twg/sdmx-3_1_0/issues/1#issuecomment-2519837607>`_ follow the `semantic versioning <https://semver.org>`_ system.
61+
This means that increments to the second (3.0 → 3.1) or first (3.1 → 4.0) version part do not necessarily indicate the presence/absence of 'breaking' or backwards-incompatible changes.
3862

3963
For the current Python package, :mod:`sdmx`:
4064

@@ -45,20 +69,20 @@ For the current Python package, :mod:`sdmx`:
4569
This makes it more difficult and costly to support them.
4670
- While no SDMX 2.0 implementation is planned, contributions from new developers are possible and welcome.
4771

48-
- **SDMX 2.1 and 3.0** are implemented as described on this page, with exhaustive implementation as the design goal for :mod:`sdmx`.
49-
- For **SDMX 3.0** specifically, as of v2.14.0 :mod:`sdmx` implements:
72+
- **SDMX 2.1 and 3.0.0** are implemented as described on this page, with exhaustive implementation as the design goal for :mod:`sdmx`.
73+
- For **SDMX 3.0.0** specifically, as of v2.14.0 :mod:`sdmx` implements:
5074

51-
- The SDMX 3.0 information model (:mod:`.model.v30`), to the same extent as SDMX 2.1.
52-
- Reading of SDMX-ML 3.0 (:mod:`.reader.xml.v30`).
75+
- The SDMX 3.0.0 information model (:mod:`.model.v30`), to the same extent as SDMX 2.1.
76+
- Reading of SDMX-ML 3.0.0 (:mod:`.reader.xml.v30`).
5377
- Construction of URLs and querying SDMX-REST API v2.1.0 data sources (:mod:`.rest.v30`).
5478

5579
This implies the following are not yet supported:
5680

57-
- Writing SDMX-ML 3.0.
81+
- Writing SDMX-ML 3.0.0.
5882
- Reading and writing SDMX-JSON 2.0 (see :ref:`sdmx-json`).
5983

60-
Follow the :doc:`whatsnew`; :issue:`87`; and other GitHub issues and pull requests for details.
61-
Please `open an issue <https://github.com/khaeru/sdmx/issues>`_ on GitHub to report examples of real-world SDMX 3.0 web services examples and specimens of data that can be added.
84+
Follow the :doc:`whatsnew` and GitHub issues and pull requests with the `'sdmx-3' label <https://github.com/khaeru/sdmx/labels/sdmx-3>`__ for details.
85+
Please `open an issue <https://github.com/khaeru/sdmx/issues>`_ on GitHub to report examples of real-world SDMX 3.0.0 web services examples and specimens of data that can be added.
6286

6387
.. _im:
6488

@@ -68,14 +92,14 @@ Information model (SDMX-IM)
6892
Reference:
6993

7094
- `SDMX 2.1 Section 2 — Information Model <https://sdmx.org/wp-content/uploads/SDMX_2-1-1_SECTION_2_InformationModel_201108.pdf>`_ (PDF).
71-
- `SDMX 3.0 Section 2 — Information Model <https://sdmx.org/wp-content/uploads/SDMX_3-0-0_SECTION_2_FINAL-1_0.pdf>`_ (PDF).
95+
- `SDMX 3.0.0 Section 2 — Information Model <https://sdmx.org/wp-content/uploads/SDMX_3-0-0_SECTION_2_FINAL-1_0.pdf>`_ (PDF).
7296

7397
In general:
7498

7599
- :mod:`sdmx.model.common` implements:
76100

77-
1. Classes that are fully identical in the SDMX 2.1 and 3.0 information models.
78-
2. Base classes like :class:`.BaseDataStructureDefinition` that contain **common attributes and features** shared by SDMX 2.1 and 3.0 classes that differ in some ways.
101+
1. Classes that are fully identical in the SDMX 2.1 and 3.0.0 information models.
102+
2. Base classes like :class:`.BaseDataStructureDefinition` that contain **common attributes and features** shared by SDMX 2.1 and 3.0.0 classes that differ in some ways.
79103
These classes should not be instantiated or used directly, except for type checking and hinting.
80104

81105
- :mod:`sdmx.model.v21` and :mod:`sdmx.model.v30` contain:
@@ -254,7 +278,7 @@ The IM provides terms and concepts for data and metadata, but does not specify h
254278
The SDMX standards include multiple formats for storing data, metadata, and structures.
255279
In general, :mod:`sdmx`:
256280

257-
- Reads most SDMX-ML 2.1 and 3.0 and SDMX-JSON 1.0 messages.
281+
- Reads most SDMX-ML 2.1 and 3.0.0 and SDMX-JSON 1.0 messages.
258282
- Uses collected specimens of messages in various formats, stored in the `khaeru/sdmx-test-data <https://github.com/khaeru/sdmx-test-data/>`_ Git repository.
259283
These are used by the test suite to check that the code functions as intended, but can also be viewed to understand the data formats.
260284

@@ -272,7 +296,7 @@ SDMX-ML can represent every class and property in the IM.
272296

273297
.. versionadded:: 2.11.0
274298

275-
Support for reading SDMX-ML 3.0.
299+
Support for reading SDMX-ML 3.0.0.
276300

277301
.. _sdmx-json:
278302

@@ -345,17 +369,17 @@ These generally elaborate the SDMX standards, but in some cases also document so
345369
The SDMX-REST *web service API* is versioned differently from the overall SDMX *standard*:
346370

347371
- SDMX-REST API v1.5.0 and earlier corresponding to SDMX 2.1 and earlier.
348-
- SDMX-REST API v2.0.0 and later corresponding to SDMX 3.0 and later.
372+
- SDMX-REST API v2.0.0 and later corresponding to SDMX 3.0.0 and later.
349373

350374
:mod:`sdmx` aims to support:
351375

352376
- SDMX-REST API versions in the 1.x series from v1.5.0 and later
353377
- SDMX-REST API versions in the 2.x series from v2.1.0 and later.
354-
- Data retrieved in SDMX 2.1 and 3.0 :ref:`formats <formats>`.
378+
- Data retrieved in SDMX 2.1 and 3.0.0 :ref:`formats <formats>`.
355379
Some existing services offer a parameter to select SDMX 2.1 *or* 2.0 format; :mod:`sdmx` does not support the latter.
356380
Other services *only* provide SDMX 2.0-formatted data; these cannot be used with :mod:`sdmx` (:ref:`see above <sdmx-version-policy>`).
357381

358-
:class:`.Client` constructs valid URLs (using :class:`~.rest.URL` subclasses :class:`.v21.URL` and :class:`.v30.URL`).
382+
:class:`.Client` constructs valid URLs using the :class:`~.rest.URL` subclasses :class:`.v21.URL` and :class:`.v30.URL`.
359383

360384
- For example, :meth:`.Client.get` automatically adds the HTTP header ``Accept: application/vnd.sdmx.structurespecificdata+xml;`` when a :py:`structure=...` argument is provided and the data source supports this content type.
361385
- :class:`.v21.URL` supplies some default parameters in certain cases.

doc/whatsnew.rst

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,70 @@
33
What's new?
44
***********
55

6-
.. _2.21.1:
6+
.. _2.22.0:
7+
8+
Next release
9+
============
10+
11+
Migration notes
12+
---------------
13+
14+
- Modify code that imports :class:`~.v21.Annotation` from :mod:`sdmx.model.common` to import from either :mod:`sdmx.model.v21` or :mod:`sdmx.model.v30`, as appropriate.
15+
For example, instead of:
16+
17+
.. code-block:: python
18+
19+
from sdmx.model.common import Annotation
20+
21+
a = Annotation(id="FOO", ...)
22+
23+
…do:
724

8-
.. Next release
9-
.. ============
25+
.. code-block:: python
26+
27+
from sdmx.model.v21 import Annotation
28+
29+
a = Annotation(id="FOO", ...)
30+
- Adjust code that accesses :class:`.ReportStructure` via the :attr:`v21.MetadataSet.described_by` attribute:
31+
32+
1. To access ReportStructure, use the new :attr:`~.v21.MetadataSet.report_structure` attribute.
33+
2. To access :class:`.MetadataStructureDefinition`, use :attr:`~v21.MetadataSet.described_by`.
34+
35+
All changes
36+
-----------
37+
38+
- :meth:`StructureMessage.get` handles full and partial :class:`URNs <URN>` (:pull:`227`).
39+
- :class:`.v21.Annotation` and :class:`.v30.Annotation` are derived from :class:`.common.BaseAnnotation` (:pull:`227`).
40+
This allows to reflect that the latter has an attribute, :attr:`.v30.Annotation.value`, that the former does not.
41+
This is a change in the SDMX 3.0.0 Information Model that is not mentioned in the “Summary of major changes and new functionality” or IM document.
42+
43+
Code like :py:`from sdmx.model.common import Annotation` now emits :class:`DeprecationWarning`, and in the future will raise :class:`ImportError`.
44+
- :func:`.validate_xml` now supports :xml:`<com:StructuredText>` elements representing, for instance, :class:`.XHTMLAttributeValue` (:pull:`227`).
45+
A new function :func:`.construct_schema` modifies the official SDMX-ML schemas to insert an import of the `XML Schema for XHTML 1.0 <https://www.w3.org/TR/xhtml1-schema/>`_, allowing to validate the XHTML content within these elements.
46+
- Improve :mod:`.model` (:pull:`227`):
47+
48+
- :class:`.IdentifiableArtefact` is comparable with :class:`str` via its :attr:`~.IdentifiableArtefact.id`.
49+
This means that :func:`sorted` can be used with mixed collections of these two types.
50+
- :attr:`.Structure.grouping` now returns a list of :class:`.ComponentList`.
51+
In :mod:`sdmx` v2.21.1 and earlier, this list would include a :class:`dict` of 0 or more :class:`.GroupDimensionDescriptor`, keyed by the ID of each.
52+
Now, each group dimension descriptor is directly an item in the list.
53+
- :attr:`.v21.MetadataSet.report_structure` is added and distinguished from :attr:`~.v21.MetadataSet.described_by`.
54+
This works around an issue in the SDMX 2.1 IM; see the class docstring for details.
55+
- New convenience methods :meth:`.MetadataReport.get`, :meth:`.MetadataReport.get_value`, and :meth:`.ReportedAttribute.get_child`.
56+
57+
- Improve reading and writing of SDMX-ML (:pull:`227`):
58+
59+
- Read :xml:`<str:AnnotationValue>` in SDMX-ML 3.0.0 (:issue:`226`).
60+
- Read :xml:`<str:Hierarchy>` where the optional :xml:`<... leveled="...">` attribute is not present (:issue:`226`).
61+
- Read and write XSD-valid :class:`.v21.MetadataSet` and :class:`.v21.HierarchicalCodelist`.
62+
- Write :attr:`.Dimension.concept_role`.
63+
- Write annotations associated with :class:`DataSet <.BaseDataSet>`, :class:`MetadataSet <.BaseMetadataSet>`, and :class:`.MetadataReport`.
64+
- Pending resolution of :issue:`228`, ignore :xml:`<com:Link>` in SDMX-ML 3.0.0 .
65+
66+
- Update and expand :ref:`sdmx-version-policy` in the documentation (:pull:`227`).
67+
A table is now included showing the correspondence of versions of component SDMX standards.
68+
69+
.. _2.21.1:
1070

1171
v2.21.1 (2025-01-14)
1272
====================

0 commit comments

Comments
 (0)