sdmxlib-cli 0.79.0__tar.gz → 0.81.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_cli-0.79.0 → sdmxlib_cli-0.81.0}/PKG-INFO +5 -5
- {sdmxlib_cli-0.79.0 → sdmxlib_cli-0.81.0}/README.md +2 -2
- {sdmxlib_cli-0.79.0 → sdmxlib_cli-0.81.0}/pyproject.toml +3 -3
- {sdmxlib_cli-0.79.0 → sdmxlib_cli-0.81.0}/pyproject.toml.orig +3 -3
- {sdmxlib_cli-0.79.0 → sdmxlib_cli-0.81.0}/src/sdmxlib_cli/EGM.md +17 -17
- {sdmxlib_cli-0.79.0 → sdmxlib_cli-0.81.0}/src/sdmxlib_cli/__init__.py +50 -52
- {sdmxlib_cli-0.79.0 → sdmxlib_cli-0.81.0}/LICENSE +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sdmxlib-cli
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: sdmxlib from the command line: check SDMX
|
|
3
|
+
Version: 0.81.0
|
|
4
|
+
Summary: sdmxlib from the command line: check SDMX editions
|
|
5
5
|
Keywords: sdmx,statistics,metadata,cli
|
|
6
6
|
Author: gabrielgellner
|
|
7
7
|
Author-email: gabrielgellner <gabrielgellner@gmail.com>
|
|
@@ -11,7 +11,7 @@ Classifier: Development Status :: 4 - Beta
|
|
|
11
11
|
Classifier: Environment :: Console
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
-
Requires-Dist: sdmxlib==0.
|
|
14
|
+
Requires-Dist: sdmxlib==0.81.0
|
|
15
15
|
Requires-Dist: typer>=0.27.3,<0.28
|
|
16
16
|
Requires-Python: >=3.14
|
|
17
17
|
Project-URL: Homepage, https://github.com/StatCat-Suite/sdmxlib
|
|
@@ -29,10 +29,10 @@ separate install, so the library itself carries no CLI dependency:
|
|
|
29
29
|
```sh
|
|
30
30
|
uv tool install sdmxlib-cli
|
|
31
31
|
# or: pip install sdmxlib-cli
|
|
32
|
-
sdmxlib
|
|
32
|
+
sdmxlib edition check path/to/edition --at publish
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
`sdmxlib
|
|
35
|
+
`sdmxlib edition check` runs `sdmxlib.edition.check_edition` at the profile
|
|
36
36
|
`--at` names. `publish` checks the manifest, every file's checksum, the
|
|
37
37
|
DuckLake catalog, the bindings' observation counts, the structural closure
|
|
38
38
|
and the fingerprints. `receive` checks data files by size and leaves the
|
|
@@ -6,10 +6,10 @@ separate install, so the library itself carries no CLI dependency:
|
|
|
6
6
|
```sh
|
|
7
7
|
uv tool install sdmxlib-cli
|
|
8
8
|
# or: pip install sdmxlib-cli
|
|
9
|
-
sdmxlib
|
|
9
|
+
sdmxlib edition check path/to/edition --at publish
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
`sdmxlib
|
|
12
|
+
`sdmxlib edition check` runs `sdmxlib.edition.check_edition` at the profile
|
|
13
13
|
`--at` names. `publish` checks the manifest, every file's checksum, the
|
|
14
14
|
DuckLake catalog, the bindings' observation counts, the structural closure
|
|
15
15
|
and the fingerprints. `receive` checks data files by size and leaves the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sdmxlib-cli"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "sdmxlib from the command line: check SDMX
|
|
3
|
+
version = "0.81.0"
|
|
4
|
+
description = "sdmxlib from the command line: check SDMX editions"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
7
7
|
license-files = ["LICENSE"]
|
|
@@ -19,7 +19,7 @@ classifiers = [
|
|
|
19
19
|
"Programming Language :: Python :: 3.14",
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|
|
22
|
-
"sdmxlib==0.
|
|
22
|
+
"sdmxlib==0.81.0",
|
|
23
23
|
"typer>=0.27.3,<0.28",
|
|
24
24
|
]
|
|
25
25
|
|
|
@@ -3,8 +3,8 @@ name = "sdmxlib-cli"
|
|
|
3
3
|
# Locked to sdmxlib's version and released with it (GH-67): the release steps
|
|
4
4
|
# bump both and the pin below, and a test asserts the three agree, so the
|
|
5
5
|
# command can never be installed against an sdmxlib it was not tested with.
|
|
6
|
-
version = "0.
|
|
7
|
-
description = "sdmxlib from the command line: check SDMX
|
|
6
|
+
version = "0.81.0"
|
|
7
|
+
description = "sdmxlib from the command line: check SDMX editions"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
license = "Apache-2.0"
|
|
10
10
|
# Its own copy, as PEP 639 keeps `license-files` inside the package directory;
|
|
@@ -22,7 +22,7 @@ classifiers = [
|
|
|
22
22
|
# A standalone install, so sdmxlib itself never depends on typer:
|
|
23
23
|
# `uv tool install sdmxlib-cli` gives an `sdmxlib` command.
|
|
24
24
|
dependencies = [
|
|
25
|
-
"sdmxlib==0.
|
|
25
|
+
"sdmxlib==0.81.0",
|
|
26
26
|
# Pre-1.0, so capped at the minor.
|
|
27
27
|
"typer>=0.27.3,<0.28",
|
|
28
28
|
]
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
The `sdmxlib` command, a typer app shipped as the separate `sdmxlib-cli`
|
|
6
6
|
distribution so that `sdmxlib` itself never depends on typer (GH-67). Each
|
|
7
|
-
command is a thin wrapper over `sdmxlib.
|
|
7
|
+
command is a thin wrapper over `sdmxlib.edition`: the module parses arguments,
|
|
8
8
|
calls one library function, and prints its result. The library tests the
|
|
9
9
|
behaviour behind each command; `tests/unit/test_cli.py` tests the wrapping.
|
|
10
10
|
|
|
@@ -12,24 +12,24 @@ behaviour behind each command; `tests/unit/test_cli.py` tests the wrapping.
|
|
|
12
12
|
|
|
13
13
|
- `app` — the root `typer.Typer`; the console script `sdmxlib = "sdmxlib_cli:app"`
|
|
14
14
|
in `cli/pyproject.toml`. It holds one sub-app, `bundle`.
|
|
15
|
-
- `sdmxlib
|
|
16
|
-
`check(path, *, at, expect)` calls `
|
|
15
|
+
- `sdmxlib edition check PATH --at {publish,receive,open} [--expect EARLIER]` —
|
|
16
|
+
`check(path, *, at, expect)` calls `check_edition(path, at=..., expect=...)`,
|
|
17
17
|
prints each finding and a summary line
|
|
18
18
|
(`<path>: N finding(s); checked ...`), and exits 1 when the report is not
|
|
19
19
|
`ok`, 0 otherwise. `--at` is required.
|
|
20
|
-
- `sdmxlib
|
|
20
|
+
- `sdmxlib edition fetch SOURCE FLOW PATH [--key] [--start] [--end]
|
|
21
21
|
[--structures-only] [--api 2.1] [--source-id]` — `fetch(...)` calls
|
|
22
|
-
`
|
|
23
|
-
`PATH` must be absent or empty (`
|
|
24
|
-
otherwise); the
|
|
22
|
+
`fetch_edition` and prints `<path>/<edition_id>: <product_id>, <counts>; edition id <edition_id>`.
|
|
23
|
+
`PATH` must be absent or empty (`fetch_edition` raises `FileExistsError`
|
|
24
|
+
otherwise); the edition lands in `<path>/<edition_id>/` and its data files in
|
|
25
25
|
`<path>/data/`. `--api` and `--source-id` apply only to a URL `SOURCE`; a
|
|
26
26
|
provider carries its own API version.
|
|
27
|
-
- `sdmxlib
|
|
28
|
-
`
|
|
29
|
-
- `sdmxlib
|
|
30
|
-
reads the manifest with `read_manifest` and prints `
|
|
27
|
+
- `sdmxlib edition copy SOURCE DESTINATION [--tiers 1,2,3]` — `copy(...)` calls
|
|
28
|
+
`copy_edition` and prints the destination, product id, edition id and file count.
|
|
29
|
+
- `sdmxlib edition files MANIFEST [--tiers 1,2,3] [--manifest]` — `files(...)`
|
|
30
|
+
reads the manifest with `read_manifest` and prints `edition_files(...)` one
|
|
31
31
|
path per line, for `rclone --files-from -` or azcopy; `--manifest` prints
|
|
32
|
-
only `<
|
|
32
|
+
only `<edition_id>/manifest.json`.
|
|
33
33
|
- `At` — `StrEnum` of `--at`'s choices (`publish`, `receive`, `open`), mapped
|
|
34
34
|
to the library's `Profile` literals by `_PROFILES`.
|
|
35
35
|
- Private parsers: `_source(text)` (a `sl.Provider` by case-insensitive name,
|
|
@@ -40,14 +40,14 @@ behaviour behind each command; `tests/unit/test_cli.py` tests the wrapping.
|
|
|
40
40
|
## Invariants
|
|
41
41
|
|
|
42
42
|
- Commands hold no logic of their own beyond argument parsing and printing;
|
|
43
|
-
behaviour changes belong in `sdmxlib.
|
|
43
|
+
behaviour changes belong in `sdmxlib.edition`.
|
|
44
44
|
- A bad `SOURCE`, `FLOW` or tier raises `typer.BadParameter` naming the
|
|
45
45
|
accepted forms, so the CLI prints usage rather than a traceback. `_flow`
|
|
46
46
|
converts the library's `SdmxParseError` (a malformed URN, agency or id) and
|
|
47
47
|
refuses a version that is neither `latest` nor an SDMX version
|
|
48
48
|
(`model.version.compliance`), in either form (GH-265).
|
|
49
|
-
- `
|
|
50
|
-
`
|
|
49
|
+
- `edition files` accepts either an edition directory or a
|
|
50
|
+
`manifest.json` staged elsewhere (its parent is used). Its listing
|
|
51
51
|
leaves the manifest out and `--manifest` prints the manifest's path alone,
|
|
52
52
|
so a copy tool moves the manifest in a second step, after every other file.
|
|
53
53
|
- `cli/pyproject.toml`'s version and its `sdmxlib==` pin equal sdmxlib's
|
|
@@ -57,10 +57,10 @@ behaviour behind each command; `tests/unit/test_cli.py` tests the wrapping.
|
|
|
57
57
|
|
|
58
58
|
## Side Effects
|
|
59
59
|
|
|
60
|
-
- `check` and `files` read the
|
|
60
|
+
- `check` and `files` read the edition (manifest, files, DuckDB catalog) and
|
|
61
61
|
write nothing.
|
|
62
62
|
- `fetch` makes HTTP requests to the SDMX REST source and creates a new
|
|
63
|
-
|
|
63
|
+
edition directory under `PATH`.
|
|
64
64
|
- `copy` writes files to `DESTINATION` and the shared data directory beside
|
|
65
65
|
it, verifies them, and writes the manifest last.
|
|
66
66
|
- All commands write to stdout; `check` sets the process exit status.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""``sdmxlib``: the command line over the library's
|
|
1
|
+
"""``sdmxlib``: the command line over the library's edition tools (GH-67).
|
|
2
2
|
|
|
3
3
|
A separate distribution, ``sdmxlib-cli``, so ``sdmxlib`` itself never depends on
|
|
4
4
|
typer. Each command is a thin wrapper: the work is the library's, and is
|
|
@@ -13,14 +13,14 @@ import typer
|
|
|
13
13
|
|
|
14
14
|
import sdmxlib as sl
|
|
15
15
|
from sdmxlib.api.providers import ProviderInfo
|
|
16
|
-
from sdmxlib.
|
|
16
|
+
from sdmxlib.edition import (
|
|
17
17
|
MANIFEST_NAME,
|
|
18
18
|
Profile,
|
|
19
19
|
Tier,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
edition_files,
|
|
21
|
+
check_edition,
|
|
22
|
+
copy_edition,
|
|
23
|
+
fetch_edition,
|
|
24
24
|
read_manifest,
|
|
25
25
|
)
|
|
26
26
|
from sdmxlib.model.dataflow import Dataflow
|
|
@@ -39,13 +39,13 @@ class At(StrEnum):
|
|
|
39
39
|
_PROFILES: dict[At, Profile] = {At.PUBLISH: "publish", At.RECEIVE: "receive", At.OPEN: "open"}
|
|
40
40
|
|
|
41
41
|
app = typer.Typer(help="sdmxlib from the command line.", no_args_is_help=True)
|
|
42
|
-
|
|
43
|
-
app.add_typer(
|
|
42
|
+
edition = typer.Typer(help="Sealed editions of SDMX products.", no_args_is_help=True)
|
|
43
|
+
app.add_typer(edition, name="edition")
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
@
|
|
46
|
+
@edition.command("check")
|
|
47
47
|
def check(
|
|
48
|
-
path: Annotated[Path, typer.Argument(help="The
|
|
48
|
+
path: Annotated[Path, typer.Argument(help="The edition directory.")],
|
|
49
49
|
*,
|
|
50
50
|
at: Annotated[
|
|
51
51
|
At,
|
|
@@ -57,20 +57,20 @@ def check(
|
|
|
57
57
|
expect: Annotated[
|
|
58
58
|
Path | None,
|
|
59
59
|
typer.Option(
|
|
60
|
-
help="An earlier
|
|
60
|
+
help="An earlier edition whose content this one must have: each fingerprint that differs is a finding.",
|
|
61
61
|
),
|
|
62
62
|
] = None,
|
|
63
63
|
) -> None:
|
|
64
|
-
"""Check a
|
|
64
|
+
"""Check a sealed edition against its manifest and against itself.
|
|
65
65
|
|
|
66
66
|
Prints each finding and what was checked. Exits 1 if anything was found.
|
|
67
67
|
``--expect`` guards a republish that is to change no content, such as a
|
|
68
68
|
rebuild at a new store schema.
|
|
69
69
|
|
|
70
70
|
Raises:
|
|
71
|
-
Exit: With status 1 when the
|
|
71
|
+
Exit: With status 1 when the edition has findings, 0 otherwise.
|
|
72
72
|
"""
|
|
73
|
-
report =
|
|
73
|
+
report = check_edition(path, at=_PROFILES[at], expect=expect)
|
|
74
74
|
for finding in report.findings:
|
|
75
75
|
typer.echo(str(finding))
|
|
76
76
|
found = len(report.findings)
|
|
@@ -118,11 +118,11 @@ def _flow(text: str) -> SdmxUrn[Dataflow]:
|
|
|
118
118
|
return urn
|
|
119
119
|
|
|
120
120
|
|
|
121
|
-
@
|
|
121
|
+
@edition.command("fetch")
|
|
122
122
|
def fetch(
|
|
123
123
|
source: Annotated[str, typer.Argument(help="A provider (ECB, ESTAT, BIS, OECD, ...) or a REST endpoint URL.")],
|
|
124
124
|
flow: Annotated[str, typer.Argument(help="The dataflow: AGENCY:ID(VERSION), AGENCY:ID, or a URN.")],
|
|
125
|
-
path: Annotated[Path, typer.Argument(help="The
|
|
125
|
+
path: Annotated[Path, typer.Argument(help="The product directory; the edition is created inside it.")],
|
|
126
126
|
*,
|
|
127
127
|
key: Annotated[str | None, typer.Option(help="SDMX key, e.g. M.USD+GBP.EUR.SP00.A.")] = None,
|
|
128
128
|
start: Annotated[str | None, typer.Option(help="Inclusive startPeriod.")] = None,
|
|
@@ -131,11 +131,11 @@ def fetch(
|
|
|
131
131
|
api: Annotated[str, typer.Option(help="REST API version of a URL source.")] = "2.1",
|
|
132
132
|
source_id: Annotated[str | None, typer.Option(help="Registry id of a URL source, recorded as provenance.")] = None,
|
|
133
133
|
) -> None:
|
|
134
|
-
"""Fetch one dataflow, narrowed by key and period, into a new
|
|
134
|
+
"""Fetch one dataflow, narrowed by key and period, into a new sealed edition.
|
|
135
135
|
|
|
136
|
-
Prints the
|
|
136
|
+
Prints the edition directory, its product and what it holds.
|
|
137
137
|
"""
|
|
138
|
-
manifest =
|
|
138
|
+
manifest = fetch_edition(
|
|
139
139
|
_source(source),
|
|
140
140
|
_flow(flow),
|
|
141
141
|
path,
|
|
@@ -147,61 +147,59 @@ def fetch(
|
|
|
147
147
|
source_id=source_id,
|
|
148
148
|
)
|
|
149
149
|
counts = ", ".join(f"{b.observations} observations" for b in manifest.bindings) or "structures only"
|
|
150
|
-
typer.echo(f"{path / manifest.
|
|
150
|
+
typer.echo(f"{path / manifest.edition_id}: {manifest.product_id}, {counts}")
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
@
|
|
153
|
+
@edition.command("copy")
|
|
154
154
|
def copy(
|
|
155
|
-
source: Annotated[Path, typer.Argument(help="The
|
|
156
|
-
destination: Annotated[Path, typer.Argument(help="The
|
|
155
|
+
source: Annotated[Path, typer.Argument(help="The sealed edition directory.")],
|
|
156
|
+
destination: Annotated[Path, typer.Argument(help="The edition directory to create.")],
|
|
157
157
|
*,
|
|
158
158
|
tiers: Annotated[
|
|
159
|
-
str, typer.Option(help="Placement tiers to copy, comma-separated:
|
|
160
|
-
] = "
|
|
159
|
+
str, typer.Option(help="Placement tiers to copy, comma-separated: required,lazy for what a server holds.")
|
|
160
|
+
] = "required,lazy,remote",
|
|
161
161
|
) -> None:
|
|
162
|
-
"""Copy
|
|
162
|
+
"""Copy an edition's listed files, verify them, and write its manifest last.
|
|
163
163
|
|
|
164
164
|
Data files go to the shared data directory beside the destination, and one
|
|
165
|
-
already there at the listed digest is kept. Prints the
|
|
165
|
+
already there at the listed digest is kept. Prints the edition copied.
|
|
166
166
|
|
|
167
167
|
Raises:
|
|
168
|
-
BadParameter: If a tier is not
|
|
168
|
+
BadParameter: If a tier is not required, lazy or remote.
|
|
169
169
|
"""
|
|
170
|
-
manifest =
|
|
171
|
-
typer.echo(f"{destination}: {manifest.
|
|
170
|
+
manifest = copy_edition(source, destination, tiers=_tiers(tiers))
|
|
171
|
+
typer.echo(f"{destination}: {manifest.product_id}, edition {manifest.edition_id}; {len(manifest.files)} files")
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
@
|
|
174
|
+
@edition.command("files")
|
|
175
175
|
def files(
|
|
176
|
-
manifest: Annotated[
|
|
177
|
-
Path, typer.Argument(help="A publication directory, or its bundle.manifest.json wherever it is staged.")
|
|
178
|
-
],
|
|
176
|
+
manifest: Annotated[Path, typer.Argument(help="An edition directory, or its manifest.json wherever it is staged.")],
|
|
179
177
|
*,
|
|
180
178
|
tiers: Annotated[
|
|
181
|
-
str, typer.Option(help="Placement tiers to list, comma-separated:
|
|
182
|
-
] = "
|
|
179
|
+
str, typer.Option(help="Placement tiers to list, comma-separated: required,lazy for what a server holds.")
|
|
180
|
+
] = "required,lazy,remote",
|
|
183
181
|
manifest_only: Annotated[
|
|
184
182
|
bool, typer.Option("--manifest", help="Print only the manifest's path, for the copy's second step.")
|
|
185
183
|
] = False,
|
|
186
184
|
) -> None:
|
|
187
|
-
r"""Print the files a copy of
|
|
185
|
+
r"""Print the files a copy of an edition needs, one path per line, for rclone or azcopy.
|
|
188
186
|
|
|
189
|
-
Paths are under the
|
|
187
|
+
Paths are under the product directory: ``<edition_id>/metadata.duckdb``,
|
|
190
188
|
``data/<schema>/<table>/ducklake-….parquet``. The manifest is left out,
|
|
191
189
|
and ``--manifest`` prints its path alone: copy tools move several files at
|
|
192
190
|
once, so the manifest is copied in a second step, after every other file.
|
|
193
191
|
|
|
194
|
-
sdmxlib
|
|
195
|
-
| rclone copy --files-from - store:
|
|
196
|
-
sdmxlib
|
|
197
|
-
| rclone copy --files-from - store:
|
|
192
|
+
sdmxlib edition files /stage/census --tiers required,lazy \
|
|
193
|
+
| rclone copy --files-from - store:products/census /var/products/census
|
|
194
|
+
sdmxlib edition files /stage/census --manifest \
|
|
195
|
+
| rclone copy --files-from - store:products/census /var/products/census
|
|
198
196
|
|
|
199
197
|
Raises:
|
|
200
|
-
BadParameter: If a tier is not
|
|
198
|
+
BadParameter: If a tier is not required, lazy or remote.
|
|
201
199
|
"""
|
|
202
200
|
root = manifest.parent if manifest.name == MANIFEST_NAME else manifest
|
|
203
201
|
read = read_manifest(root)
|
|
204
|
-
listed = [f"{read.
|
|
202
|
+
listed = [f"{read.edition_id}/{MANIFEST_NAME}"] if manifest_only else edition_files(read, tiers=_tiers(tiers))
|
|
205
203
|
for path in listed:
|
|
206
204
|
typer.echo(path)
|
|
207
205
|
|
|
@@ -210,18 +208,18 @@ def _tiers(text: str) -> list[Tier]:
|
|
|
210
208
|
"""The placement tiers `text` names, comma-separated.
|
|
211
209
|
|
|
212
210
|
Raises:
|
|
213
|
-
BadParameter: If one is not
|
|
211
|
+
BadParameter: If one is not required, lazy or remote.
|
|
214
212
|
"""
|
|
215
213
|
chosen: list[Tier] = []
|
|
216
214
|
for part in text.split(","):
|
|
217
215
|
match part.strip():
|
|
218
|
-
case "
|
|
219
|
-
chosen.append(
|
|
220
|
-
case "
|
|
221
|
-
chosen.append(
|
|
222
|
-
case "
|
|
223
|
-
chosen.append(
|
|
216
|
+
case "required":
|
|
217
|
+
chosen.append("required")
|
|
218
|
+
case "lazy":
|
|
219
|
+
chosen.append("lazy")
|
|
220
|
+
case "remote":
|
|
221
|
+
chosen.append("remote")
|
|
224
222
|
case other:
|
|
225
|
-
msg = f"{other!r} is not a tier; give
|
|
223
|
+
msg = f"{other!r} is not a tier; give required, lazy or remote, comma-separated"
|
|
226
224
|
raise typer.BadParameter(msg)
|
|
227
225
|
return chosen
|
|
File without changes
|