|
1 | 1 | (Meta)data storage
|
2 | 2 | ******************
|
3 | 3 |
|
| 4 | +:mod:`transport_data.store` provides for storing and handling two kinds of data files: |
| 5 | + |
| 6 | +Local data |
| 7 | + Data that exist only on an individual user's system. |
| 8 | + These may include: |
| 9 | + |
| 10 | + - Cached files such as those downloaded from particular network locations. |
| 11 | + - Temporary or intermediate data files produced or used by other code in :mod:`transport_data` or downstream packages. |
| 12 | + |
| 13 | + These data are handled by an instance of the :class:`.LocalStore` class. |
| 14 | + |
| 15 | +Maintained data |
| 16 | + These are data that may be distributed and referenced by other users and SDMX data or structures. |
| 17 | + They are handled by an instance of the :class:`.Registry` class. |
| 18 | + |
| 19 | +:data:`transport_data.STORE` is an instance of the :class:`.UnionStore` class, which dispatches operations to :class:`.LocalStore` or :class:`.Registry` according to the maintainer of objects. |
| 20 | +All three classes are subclassed of :class:`.BaseStore` and share a common interface. |
| 21 | + |
| 22 | +.. _store-layout: |
| 23 | + |
| 24 | +Formats and layout |
| 25 | +================== |
| 26 | + |
| 27 | +- Files are stored in the (configurable) directory indicated by :attr:`.Config.data_path`. |
| 28 | + This defaults to the :ref:`platformdirs:api:user data directory`. |
| 29 | + For instance, on a Unix/Linux system, the data may be in :file:`$HOME/.local/share/transport-data/`. |
| 30 | + |
| 31 | + - :class:`.LocalStore` files are in a :file:`…/local/` subdirectory. |
| 32 | + - :class:`.Registry` files are in a :file:`…/registry/` subdirectory. |
| 33 | + |
| 34 | +- All files are stored as SDMX-ML (XML). |
| 35 | + |
| 36 | + Every SDMX :class:`~sdmx.model.common.MaintainableArtefact` has a `uniform resource name (URN) <https://en.wikipedia.org/wiki/Uniform_Resource_Name>`__ that resembles ``urn:sdmx:org.sdmx.infomodel.codelist.Codelist=TEST:COLOUR(1.2.3)``. |
| 37 | + In this example: |
| 38 | + |
| 39 | + - "TEST" is the :attr:`~sdmx.model.common.IdentifiableArtefact.id` of a :class:`~sdmx.model.common.Agency` stored as the :attr:`~sdmx.model.common.MaintainableArtefact.maintainer` attribute. |
| 40 | + - "COLOUR" is the ID of the object itself. |
| 41 | + - "(1.2.3)" is the :attr:`~sdmx.model.common.VersionableArtefact.version` attribute of a :class:`~sdmx.model.common.VersionableArtefact`. |
| 42 | + |
| 43 | +- Directory and file names include maintainer ID, object class name, and object ID. |
| 44 | + For instance, the file :file:`TEST/Codelist_TEST_COLOUR.xml` contains the :class:`~sdmx.model.common.Codelist` with ID "COLOUR" maintained by the agency with ID "TEST". |
| 45 | +- Each file contains **only** objects of the class, ID, and maintainer corresponding to its path. |
| 46 | +- Each file **may** contain *multiple versions* of objects. |
| 47 | + For instance, the file :file:`TEST/Codelist_TEST_COLOUR.xml` may contain objects with the URNs and versions: |
| 48 | + |
| 49 | + - ``urn:sdmx:org.sdmx.infomodel.codelist.Codelist=TEST:COLOUR(1.0.0)`` → version 1.0.0; |
| 50 | + - ``urn:sdmx:org.sdmx.infomodel.codelist.Codelist=TEST:COLOUR(1.2.3)`` → version 1.2.3; |
| 51 | + - ``urn:sdmx:org.sdmx.infomodel.codelist.Codelist=TEST:COLOUR(1.2.4)`` → version 1.2.4; |
| 52 | + - and so on. |
| 53 | + |
4 | 54 | .. include:: _api/transport_data.store.rst
|
0 commit comments