Skip to content

manifest

manifest

Dataset manifests: declaration, discovery, and model-level fetching.

Datasets are declared in TOML manifests. fwl-io ships one manifest for datasets shared by several models (spectral files, multi-consumer lookup tables); each model package may ship its own manifest for data only it consumes and expose it through the fwl_io.manifests entry-point group. Adding data to a model therefore never requires an fwl-io release.

Manifest schema, one table per dataset, identified by its subdir key::

[interior_lookup_tables.MgSiO3_Wolf_Bower_2018]
name = "Wolf & Bower (2018) MgSiO3 equation of state"
subdir = "interior_lookup_tables/MgSiO3_Wolf_Bower_2018"
zenodo = "10.5281/zenodo.1234567"       # version DOI, never a concept DOI
dataverse = "10.34894/ABCDEF"           # optional download mirror
required_by = ["aragog", "zalmoxis", "spider"]

Every dataset requires a Zenodo version DOI: the committed registry is generated from the Zenodo record, so Dataverse is a download mirror, not an alternative primary source. Version DOIs are pinned deliberately: a Zenodo concept DOI resolves to the newest deposit and would let data drift underneath pinned code, so fwl-io sync rejects concept DOIs.

Every dataset has a committed registry file next to the manifest, named <group>.<key>.registry.txt, generated by fwl-io sync. Packages that ship their own manifest must ship the registry files with it (include both in package-data).

Dataset(key, name, subdir, zenodo=None, dataverse=None, required_by=tuple(), registry_path=None) dataclass

A single downloadable dataset declared in a manifest.

registry()

Return the committed name-to-hash registry for this dataset.

Source code in src/fwl_io/manifest.py
70
71
72
73
74
75
76
def registry(self) -> dict[str, str]:
    """Return the committed name-to-hash registry for this dataset."""
    if self.registry_path is None or not self.registry_path.is_file():
        raise FileNotFoundError(
            f'no registry file for dataset {self.key!r}; run: fwl-io sync <manifest>'
        )
    return load_registry(self.registry_path)

discover_manifests()

Collect datasets from every installed fwl_io.manifests entry point.

Entry points must resolve to a zero-argument callable returning the manifest path. A provider whose manifest fails to load is skipped with a logged warning, so one broken package cannot break data access for every other model.

Source code in src/fwl_io/manifest.py
179
180
181
182
183
184
185
186
187
188
def discover_manifests() -> dict[str, list[Dataset]]:
    """Collect datasets from every installed ``fwl_io.manifests`` entry point.

    Entry points must resolve to a zero-argument callable returning the
    manifest path. A provider whose manifest fails to load is skipped with a
    logged warning, so one broken package cannot break data access for every
    other model.
    """
    found, _ = _discover()
    return found

fetch_for(model, data_root=None)

Fetch every dataset a given model requires; return paths per dataset.

All matching datasets are attempted; failures are collected and raised together at the end so one broken dataset does not block the others (files fetched before the error remain in place).

Parameters:

Name Type Description Default
model str

Model name matched (case-insensitively) against required_by.

required
data_root str | Path | None

Override for the data root; defaults to the resolved FWL_DATA tree.

None
Source code in src/fwl_io/manifest.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
def fetch_for(model: str, data_root: str | Path | None = None) -> dict[str, list[Path]]:
    """Fetch every dataset a given model requires; return paths per dataset.

    All matching datasets are attempted; failures are collected and raised
    together at the end so one broken dataset does not block the others
    (files fetched before the error remain in place).

    Parameters
    ----------
    model : str
        Model name matched (case-insensitively) against ``required_by``.
    data_root : str | Path | None
        Override for the data root; defaults to the resolved FWL_DATA tree.
    """
    from fwl_io.fetch import create_fetcher

    model = model.lower()
    fetched: dict[str, list[Path]] = {}
    failures: dict[str, str] = {}
    for datasets in discover_manifests().values():
        for ds in datasets:
            if model not in tuple(r.lower() for r in ds.required_by):
                continue
            try:
                fetcher = create_fetcher(
                    subdir=ds.subdir,
                    zenodo=ds.zenodo,
                    dataverse=ds.dataverse,
                    registry=ds.registry(),
                    data_root=data_root,
                )
                fetched[ds.key] = fetcher.fetch_all()
            except Exception as exc:  # noqa: BLE001 -- aggregate and re-raise below
                failures[ds.key] = str(exc)
    if failures:
        detail = '\n'.join(f'  {key}: {msg}' for key, msg in sorted(failures.items()))
        raise RuntimeError(
            f'{len(failures)} dataset(s) failed for model {model!r} '
            f'({len(fetched)} succeeded):\n{detail}'
        )
    return fetched

load_manifest(path)

Load and validate all datasets declared in one manifest file.

Source code in src/fwl_io/manifest.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
def load_manifest(path: str | Path) -> list[Dataset]:
    """Load and validate all datasets declared in one manifest file."""
    path = Path(path)
    with path.open('rb') as fh:
        tree = tomllib.load(fh)

    datasets: list[Dataset] = []
    for key, table in _walk_tables(tree):
        subdir = table['subdir']
        _validate_subdir(key, subdir)
        zenodo = table.get('zenodo')
        dataverse = table.get('dataverse')
        if not zenodo:
            raise ValueError(
                f'dataset {key!r}: a Zenodo version DOI is required '
                f'("dataverse" is a download mirror, not a primary source)'
            )
        if not ZENODO_DOI_PATTERN.match(zenodo):
            raise ValueError(
                f'dataset {key!r}: zenodo value {zenodo!r} is not a Zenodo DOI '
                f'of the form 10.5281/zenodo.<record-id>'
            )
        if dataverse and not _GENERIC_DOI_PATTERN.match(dataverse):
            raise ValueError(f'dataset {key!r}: dataverse value {dataverse!r} is not a DOI')
        datasets.append(
            Dataset(
                key=key,
                name=table.get('name', key),
                subdir=subdir,
                zenodo=zenodo,
                dataverse=dataverse,
                required_by=tuple(table.get('required_by', ())),
                registry_path=path.parent / f'{key}.registry.txt',
            )
        )
    return datasets

shared_manifest_path()

Entry-point target: the manifest of datasets shared across models.

Source code in src/fwl_io/manifest.py
160
161
162
def shared_manifest_path() -> Path:
    """Entry-point target: the manifest of datasets shared across models."""
    return Path(__file__).parent / 'data' / 'shared_manifest.toml'

zenodo_record_id(doi)

Return the numeric record id of a Zenodo version DOI.

Parameters:

Name Type Description Default
doi str

A Zenodo DOI of the form 10.5281/zenodo.<record-id> (an optional doi: prefix is accepted).

required

Returns:

Type Description
str

The trailing record-id digits.

Raises:

Type Description
ValueError

When the string is not a Zenodo DOI.

Source code in src/fwl_io/doi.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def zenodo_record_id(doi: str) -> str:
    """Return the numeric record id of a Zenodo version DOI.

    Parameters
    ----------
    doi : str
        A Zenodo DOI of the form ``10.5281/zenodo.<record-id>`` (an optional
        ``doi:`` prefix is accepted).

    Returns
    -------
    str
        The trailing record-id digits.

    Raises
    ------
    ValueError
        When the string is not a Zenodo DOI.
    """
    match = ZENODO_DOI_PATTERN.match(doi.strip())
    if not match:
        raise ValueError(f'{doi!r} is not a Zenodo DOI of the form 10.5281/zenodo.<id>')
    return match.group(2)