sdmxlib-rest 0.1.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_rest-0.1.0/LICENSE +185 -0
- sdmxlib_rest-0.1.0/PKG-INFO +114 -0
- sdmxlib_rest-0.1.0/README.md +80 -0
- sdmxlib_rest-0.1.0/pyproject.toml +92 -0
- sdmxlib_rest-0.1.0/pyproject.toml.orig +95 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/__init__.py +19 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/app.py +388 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/availability_cache.py +80 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/data/__init__.py +94 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/data/encoding.py +153 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/data/paging.py +72 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/data/params.py +284 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/data/projection.py +240 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/data/sql.py +84 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/filter_shaper.py +78 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/localization.py +167 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/logging.py +28 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/message_annotator.py +68 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/metadata_store.py +81 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/middleware/__init__.py +6 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/middleware/compression.py +149 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/middleware/etag.py +175 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/middleware/head_method.py +76 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/middleware/lang_override.py +75 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/middleware/openapi_extensions.py +106 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/middleware/perf_log.py +140 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/middleware/query_param_guard.py +126 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/middleware/version_token.py +76 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/negotiation.py +146 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/provider.py +73 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/responses/__init__.py +6 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/responses/asof.py +49 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/responses/empty.py +99 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/responses/urn_injection.py +157 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/routes/__init__.py +7 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/routes/availability.py +793 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/routes/metadata.py +428 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/routes/structure.py +1205 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/runtime.py +176 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/splice.py +146 -0
- sdmxlib_rest-0.1.0/src/sdmxlib_rest/structure_cache.py +75 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and derivative works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
+
improving the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent claims licensable
|
|
76
|
+
by such Contributor that are necessarily infringed by their
|
|
77
|
+
Contribution(s) alone or by the combination of their Contribution(s)
|
|
78
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
+
institute patent litigation against any entity (including a cross-claim
|
|
80
|
+
or counterclaim in a lawsuit) alleging that the Work or any other
|
|
81
|
+
Contribution embodied within the Work constitutes patent or contributory
|
|
82
|
+
patent infringement, then any patent licenses granted to You under
|
|
83
|
+
this License for that Work shall terminate as of the date such
|
|
84
|
+
litigation is filed.
|
|
85
|
+
|
|
86
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
87
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
88
|
+
modifications, and in Source or Object form, provided that You
|
|
89
|
+
meet the following conditions:
|
|
90
|
+
|
|
91
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
92
|
+
Works a copy of this License; and
|
|
93
|
+
|
|
94
|
+
(b) You must cause any modified files to carry prominent notices
|
|
95
|
+
stating that You changed the files; and
|
|
96
|
+
|
|
97
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
98
|
+
that You distribute, all copyright, patent, trademark, and
|
|
99
|
+
attribution notices from the Source form of the Work,
|
|
100
|
+
excluding those notices that do not pertain to any part of
|
|
101
|
+
the Derivative Works; and
|
|
102
|
+
|
|
103
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
104
|
+
distribution, You must include a readable copy of the
|
|
105
|
+
attribution notices contained within such NOTICE file, in
|
|
106
|
+
at least one of the following places: within a NOTICE text
|
|
107
|
+
file distributed as part of the Derivative Works; within
|
|
108
|
+
the Source form or documentation, if provided along with the
|
|
109
|
+
Derivative Works; or, within a display generated by the
|
|
110
|
+
Derivative Works, if and wherever such third-party notices
|
|
111
|
+
normally appear. The contents of the NOTICE file are for
|
|
112
|
+
informational purposes only and do not modify the License.
|
|
113
|
+
You may add Your own attribution notices within Derivative
|
|
114
|
+
Works that You distribute, alongside or in addition to the
|
|
115
|
+
NOTICE text from the Work, provided that such additional
|
|
116
|
+
attribution notices cannot be construed as modifying the
|
|
117
|
+
License.
|
|
118
|
+
|
|
119
|
+
You may add Your own license statement for Your modifications and
|
|
120
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
121
|
+
publish, distribute, sublicense, and/or sell copies of the
|
|
122
|
+
Contribution, either on its own or as part of the combined Work,
|
|
123
|
+
and to grant a sublicense of the foregoing.
|
|
124
|
+
|
|
125
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
126
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
127
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
128
|
+
this License, without any additional terms or conditions.
|
|
129
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
130
|
+
the terms of any separate license agreement you may have executed
|
|
131
|
+
with Licensor regarding such Contributions.
|
|
132
|
+
|
|
133
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
134
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
135
|
+
except as required for reasonable and customary use in describing the
|
|
136
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
137
|
+
|
|
138
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
139
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
140
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
141
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
142
|
+
implied, including, without limitation, any conditions of TITLE,
|
|
143
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
|
|
144
|
+
PURPOSE. You are solely responsible for determining the
|
|
145
|
+
appropriateness of using or reproducing the Work and assume any
|
|
146
|
+
risks associated with Your exercise of permissions under this License.
|
|
147
|
+
|
|
148
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
149
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
150
|
+
unless required by applicable law (such as deliberate and grossly
|
|
151
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
152
|
+
liable to You for damages, including any direct, indirect, special,
|
|
153
|
+
incidental, or exemplary damages of any character arising as a
|
|
154
|
+
result of this License or out of the use or inability to use the
|
|
155
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
156
|
+
work stoppage, computer failure or malfunction, or all other
|
|
157
|
+
commercial damages or losses), even if such Contributor has been
|
|
158
|
+
advised of the possibility of such damages.
|
|
159
|
+
|
|
160
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
161
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
162
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
163
|
+
or other liability obligations and/or rights consistent with this
|
|
164
|
+
License. However, in accepting such obligations, You may act only
|
|
165
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
166
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
167
|
+
defend, and hold each Contributor harmless for any liability
|
|
168
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
169
|
+
of your accepting any such warranty or additional liability.
|
|
170
|
+
|
|
171
|
+
END OF TERMS AND CONDITIONS
|
|
172
|
+
|
|
173
|
+
Copyright 2026 gabrielgellner
|
|
174
|
+
|
|
175
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
176
|
+
you may not use this file except in compliance with the License.
|
|
177
|
+
You may obtain a copy of the License at
|
|
178
|
+
|
|
179
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
180
|
+
|
|
181
|
+
Unless required by applicable law or agreed to in writing, software
|
|
182
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
183
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
184
|
+
See the License for the specific language governing permissions and
|
|
185
|
+
limitations under the License.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sdmxlib-rest
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generic SDMX-REST HTTP surface over a sdmxlib FederatedCatalog
|
|
5
|
+
Keywords: sdmx,sdmx-rest,fastapi,statistical-data,api
|
|
6
|
+
Author: gabrielgellner
|
|
7
|
+
Author-email: gabrielgellner <gabrielgellner@gmail.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Framework :: FastAPI
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
17
|
+
Requires-Dist: sdmxlib>=0.48.0
|
|
18
|
+
Requires-Dist: attrs>=24
|
|
19
|
+
Requires-Dist: fastapi>=0.115
|
|
20
|
+
Requires-Dist: starlette>=0.40
|
|
21
|
+
Requires-Dist: duckdb>=1.1
|
|
22
|
+
Requires-Dist: polars>=1.39
|
|
23
|
+
Requires-Dist: pyarrow>=18
|
|
24
|
+
Requires-Dist: orjson>=3.11
|
|
25
|
+
Requires-Dist: loguru>=0.7
|
|
26
|
+
Requires-Dist: isal>=1.8.0
|
|
27
|
+
Requires-Dist: zipstream-ng>=1.9.2
|
|
28
|
+
Requires-Python: >=3.13
|
|
29
|
+
Project-URL: Homepage, https://gitlab.com/pinax-suite/sdmxlib-rest
|
|
30
|
+
Project-URL: Repository, https://gitlab.com/pinax-suite/sdmxlib-rest
|
|
31
|
+
Project-URL: Issue Tracker, https://gitlab.com/pinax-suite/sdmxlib-rest/-/issues
|
|
32
|
+
Project-URL: Changelog, https://gitlab.com/pinax-suite/sdmxlib-rest/-/blob/main/CHANGELOG.md
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# sdmxlib-rest
|
|
36
|
+
|
|
37
|
+
A generic [SDMX-REST](https://github.com/sdmx-twg/sdmx-rest) HTTP surface over a
|
|
38
|
+
[sdmxlib](https://gitlab.com/pinax-suite/sdmxlib) `FederatedCatalog`.
|
|
39
|
+
|
|
40
|
+
It owns the parts of an SDMX-REST service that are the same everywhere — URL
|
|
41
|
+
grammar, content negotiation, localisation, streaming, response assembly — and
|
|
42
|
+
leaves everything catalog-specific to the consumer, behind explicit seams.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from sdmxlib_rest.app import RestSettings, create_app, library_routers
|
|
46
|
+
from sdmxlib_rest.runtime import CatalogRuntime
|
|
47
|
+
|
|
48
|
+
runtime = CatalogRuntime(MyCatalogProvider())
|
|
49
|
+
app = create_app(
|
|
50
|
+
runtime,
|
|
51
|
+
RestSettings(title="my-sdmx-api", version="1.0.0"),
|
|
52
|
+
routers=list(library_routers()),
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
That serves the structure, metadata and availability planes. Serving data is the
|
|
57
|
+
consumer's job — see *Why there is no data route* below.
|
|
58
|
+
|
|
59
|
+
## What you supply
|
|
60
|
+
|
|
61
|
+
Everything catalog-shaped is a Protocol on `CatalogRuntime`, each with a no-op
|
|
62
|
+
default. A bare consumer implements only the first one.
|
|
63
|
+
|
|
64
|
+
| Seam | Purpose | Default |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| `CatalogProvider` | how the catalog is opened | **required** |
|
|
67
|
+
| `SpliceRegistry` | post-serialise JSON transforms | empty |
|
|
68
|
+
| `StructureCache` | cache rendered structure responses | never caches |
|
|
69
|
+
| `AvailabilityCache` | cache rendered availability responses | never caches |
|
|
70
|
+
| `MetadataStore` | reference-metadata lookups | returns nothing |
|
|
71
|
+
| `ComponentFilterShaper` | rewrite a parsed filter before SQL | identity |
|
|
72
|
+
| `MessageAnnotator` | pre-serialise message annotation | no-op |
|
|
73
|
+
|
|
74
|
+
The defaults are all *inert*, not *broken*: a consumer that installs none of
|
|
75
|
+
them gets a correct service, just one that recomputes more than it needs to.
|
|
76
|
+
|
|
77
|
+
## What `create_app` gives you
|
|
78
|
+
|
|
79
|
+
Routes are the easy part. The assembly is what's worth not rewriting:
|
|
80
|
+
|
|
81
|
+
- **The middleware stack, in the one order that works.** The chain has real
|
|
82
|
+
adjacency constraints — the ETag has to hash uncompressed bytes, so it runs
|
|
83
|
+
inside compression; `?lang=` has to rewrite the header before the ETag layer
|
|
84
|
+
reads it; CORS has to be outermost or preflights fall through to a 404 that
|
|
85
|
+
browsers report as a CORS failure. Each constraint is documented at
|
|
86
|
+
`_install_middleware`.
|
|
87
|
+
- **Runtime sharing across mounts**, so a service exposing several surfaces
|
|
88
|
+
(a canonical one plus compatibility variants) opens the catalog once.
|
|
89
|
+
- **A multi-spec docs page**, which has to be hand-rolled because FastAPI's
|
|
90
|
+
helper emits a single-spec page and Swagger UI renders nothing when given
|
|
91
|
+
both `url` and `urls`.
|
|
92
|
+
|
|
93
|
+
## Why there is no data route
|
|
94
|
+
|
|
95
|
+
The library owns data-plane *helpers* — key and query-parameter parsing,
|
|
96
|
+
projection, paging headers, binding-driven SQL fragments, and the
|
|
97
|
+
arrow→CSV/parquet encoders, all under `sdmxlib_rest.data`. It does not own the
|
|
98
|
+
`/data` route itself.
|
|
99
|
+
|
|
100
|
+
That is deliberate. Orchestration is where response caching, partition pushdown
|
|
101
|
+
and vendor extensions live, and every catalog shapes those differently — one
|
|
102
|
+
catalog's hierarchy descent and partition-pruning tricks are noise to the next.
|
|
103
|
+
A second consumer gets the hard, fiddly parts and writes its own handler around
|
|
104
|
+
them.
|
|
105
|
+
|
|
106
|
+
## Status
|
|
107
|
+
|
|
108
|
+
Extracted from a production SDMX-REST service and versioned independently from
|
|
109
|
+
`0.1.0`. The seam set is settled; the `create_app` signature may still move
|
|
110
|
+
before `1.0`.
|
|
111
|
+
|
|
112
|
+
## Licence
|
|
113
|
+
|
|
114
|
+
Apache-2.0.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# sdmxlib-rest
|
|
2
|
+
|
|
3
|
+
A generic [SDMX-REST](https://github.com/sdmx-twg/sdmx-rest) HTTP surface over a
|
|
4
|
+
[sdmxlib](https://gitlab.com/pinax-suite/sdmxlib) `FederatedCatalog`.
|
|
5
|
+
|
|
6
|
+
It owns the parts of an SDMX-REST service that are the same everywhere — URL
|
|
7
|
+
grammar, content negotiation, localisation, streaming, response assembly — and
|
|
8
|
+
leaves everything catalog-specific to the consumer, behind explicit seams.
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
from sdmxlib_rest.app import RestSettings, create_app, library_routers
|
|
12
|
+
from sdmxlib_rest.runtime import CatalogRuntime
|
|
13
|
+
|
|
14
|
+
runtime = CatalogRuntime(MyCatalogProvider())
|
|
15
|
+
app = create_app(
|
|
16
|
+
runtime,
|
|
17
|
+
RestSettings(title="my-sdmx-api", version="1.0.0"),
|
|
18
|
+
routers=list(library_routers()),
|
|
19
|
+
)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
That serves the structure, metadata and availability planes. Serving data is the
|
|
23
|
+
consumer's job — see *Why there is no data route* below.
|
|
24
|
+
|
|
25
|
+
## What you supply
|
|
26
|
+
|
|
27
|
+
Everything catalog-shaped is a Protocol on `CatalogRuntime`, each with a no-op
|
|
28
|
+
default. A bare consumer implements only the first one.
|
|
29
|
+
|
|
30
|
+
| Seam | Purpose | Default |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `CatalogProvider` | how the catalog is opened | **required** |
|
|
33
|
+
| `SpliceRegistry` | post-serialise JSON transforms | empty |
|
|
34
|
+
| `StructureCache` | cache rendered structure responses | never caches |
|
|
35
|
+
| `AvailabilityCache` | cache rendered availability responses | never caches |
|
|
36
|
+
| `MetadataStore` | reference-metadata lookups | returns nothing |
|
|
37
|
+
| `ComponentFilterShaper` | rewrite a parsed filter before SQL | identity |
|
|
38
|
+
| `MessageAnnotator` | pre-serialise message annotation | no-op |
|
|
39
|
+
|
|
40
|
+
The defaults are all *inert*, not *broken*: a consumer that installs none of
|
|
41
|
+
them gets a correct service, just one that recomputes more than it needs to.
|
|
42
|
+
|
|
43
|
+
## What `create_app` gives you
|
|
44
|
+
|
|
45
|
+
Routes are the easy part. The assembly is what's worth not rewriting:
|
|
46
|
+
|
|
47
|
+
- **The middleware stack, in the one order that works.** The chain has real
|
|
48
|
+
adjacency constraints — the ETag has to hash uncompressed bytes, so it runs
|
|
49
|
+
inside compression; `?lang=` has to rewrite the header before the ETag layer
|
|
50
|
+
reads it; CORS has to be outermost or preflights fall through to a 404 that
|
|
51
|
+
browsers report as a CORS failure. Each constraint is documented at
|
|
52
|
+
`_install_middleware`.
|
|
53
|
+
- **Runtime sharing across mounts**, so a service exposing several surfaces
|
|
54
|
+
(a canonical one plus compatibility variants) opens the catalog once.
|
|
55
|
+
- **A multi-spec docs page**, which has to be hand-rolled because FastAPI's
|
|
56
|
+
helper emits a single-spec page and Swagger UI renders nothing when given
|
|
57
|
+
both `url` and `urls`.
|
|
58
|
+
|
|
59
|
+
## Why there is no data route
|
|
60
|
+
|
|
61
|
+
The library owns data-plane *helpers* — key and query-parameter parsing,
|
|
62
|
+
projection, paging headers, binding-driven SQL fragments, and the
|
|
63
|
+
arrow→CSV/parquet encoders, all under `sdmxlib_rest.data`. It does not own the
|
|
64
|
+
`/data` route itself.
|
|
65
|
+
|
|
66
|
+
That is deliberate. Orchestration is where response caching, partition pushdown
|
|
67
|
+
and vendor extensions live, and every catalog shapes those differently — one
|
|
68
|
+
catalog's hierarchy descent and partition-pruning tricks are noise to the next.
|
|
69
|
+
A second consumer gets the hard, fiddly parts and writes its own handler around
|
|
70
|
+
them.
|
|
71
|
+
|
|
72
|
+
## Status
|
|
73
|
+
|
|
74
|
+
Extracted from a production SDMX-REST service and versioned independently from
|
|
75
|
+
`0.1.0`. The seam set is settled; the `create_app` signature may still move
|
|
76
|
+
before `1.0`.
|
|
77
|
+
|
|
78
|
+
## Licence
|
|
79
|
+
|
|
80
|
+
Apache-2.0.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sdmxlib-rest"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Generic SDMX-REST HTTP surface over a sdmxlib FederatedCatalog"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.13"
|
|
9
|
+
keywords = [
|
|
10
|
+
"sdmx",
|
|
11
|
+
"sdmx-rest",
|
|
12
|
+
"fastapi",
|
|
13
|
+
"statistical-data",
|
|
14
|
+
"api",
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Framework :: FastAPI",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"sdmxlib>=0.48.0",
|
|
27
|
+
"attrs>=24",
|
|
28
|
+
"fastapi>=0.115",
|
|
29
|
+
"starlette>=0.40",
|
|
30
|
+
"duckdb>=1.1",
|
|
31
|
+
"polars>=1.39",
|
|
32
|
+
"pyarrow>=18",
|
|
33
|
+
"orjson>=3.11",
|
|
34
|
+
"loguru>=0.7",
|
|
35
|
+
"isal>=1.8.0",
|
|
36
|
+
"zipstream-ng>=1.9.2",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[[project.authors]]
|
|
40
|
+
name = "gabrielgellner"
|
|
41
|
+
email = "gabrielgellner@gmail.com"
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://gitlab.com/pinax-suite/sdmxlib-rest"
|
|
45
|
+
Repository = "https://gitlab.com/pinax-suite/sdmxlib-rest"
|
|
46
|
+
"Issue Tracker" = "https://gitlab.com/pinax-suite/sdmxlib-rest/-/issues"
|
|
47
|
+
Changelog = "https://gitlab.com/pinax-suite/sdmxlib-rest/-/blob/main/CHANGELOG.md"
|
|
48
|
+
|
|
49
|
+
[build-system]
|
|
50
|
+
requires = ["uv_build>=0.11.6,<0.12.0"]
|
|
51
|
+
build-backend = "uv_build"
|
|
52
|
+
|
|
53
|
+
[[tool.uv.index]]
|
|
54
|
+
name = "pypi"
|
|
55
|
+
url = "https://pypi.org/simple"
|
|
56
|
+
default = true
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
testpaths = ["tests"]
|
|
60
|
+
markers = [
|
|
61
|
+
"unit: fast unit tests (no I/O)",
|
|
62
|
+
"integration: tests that use real DuckDB but no network",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[tool.coverage.run]
|
|
66
|
+
source = ["src/sdmxlib_rest"]
|
|
67
|
+
|
|
68
|
+
[tool.coverage.report]
|
|
69
|
+
show_missing = true
|
|
70
|
+
skip_covered = false
|
|
71
|
+
|
|
72
|
+
[tool.basedpyright]
|
|
73
|
+
pythonVersion = "3.13"
|
|
74
|
+
typeCheckingMode = "standard"
|
|
75
|
+
venvPath = "."
|
|
76
|
+
venv = ".venv"
|
|
77
|
+
exclude = [".venv"]
|
|
78
|
+
reportAny = "none"
|
|
79
|
+
reportExplicitAny = "none"
|
|
80
|
+
reportUnknownVariableType = "none"
|
|
81
|
+
reportUnknownMemberType = "none"
|
|
82
|
+
reportUnknownArgumentType = "none"
|
|
83
|
+
|
|
84
|
+
[dependency-groups]
|
|
85
|
+
dev = [
|
|
86
|
+
"basedpyright>=1.38.4",
|
|
87
|
+
"pytest>=9.0.3",
|
|
88
|
+
"pytest-asyncio>=0.24",
|
|
89
|
+
"httpx>=0.28",
|
|
90
|
+
"ruff>=0.15.8",
|
|
91
|
+
"pyrefly>=1.2.0",
|
|
92
|
+
]
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sdmxlib-rest"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Generic SDMX-REST HTTP surface over a sdmxlib FederatedCatalog"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
# PEP 639 form. The deprecated `license = { text = ... }` table populates the
|
|
7
|
+
# legacy `License:` field that some per-component scanners still read, but it is
|
|
8
|
+
# mutually exclusive with `license-files` — and Apache-2.0 §4 requires shipping
|
|
9
|
+
# the license text, which only `license-files` does. Compliance wins; scanners
|
|
10
|
+
# that need the legacy field can read `License-Expression:` or the classifier.
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "gabrielgellner", email = "gabrielgellner@gmail.com" }]
|
|
14
|
+
requires-python = ">=3.13"
|
|
15
|
+
keywords = ["sdmx", "sdmx-rest", "fastapi", "statistical-data", "api"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Framework :: FastAPI",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
24
|
+
]
|
|
25
|
+
# Derived from what the package actually imports, not inherited from the
|
|
26
|
+
# service it was extracted from: no pinaxlib (the catalog is reached through
|
|
27
|
+
# the CatalogProvider seam), no uvicorn (serving is the consumer's job).
|
|
28
|
+
dependencies = [
|
|
29
|
+
"sdmxlib>=0.48.0",
|
|
30
|
+
"attrs>=24",
|
|
31
|
+
"fastapi>=0.115",
|
|
32
|
+
"starlette>=0.40",
|
|
33
|
+
"duckdb>=1.1",
|
|
34
|
+
"polars>=1.39",
|
|
35
|
+
"pyarrow>=18",
|
|
36
|
+
"orjson>=3.11",
|
|
37
|
+
"loguru>=0.7",
|
|
38
|
+
# Streaming zip + a faster DEFLATE backend for the CSV export path.
|
|
39
|
+
"isal>=1.8.0",
|
|
40
|
+
"zipstream-ng>=1.9.2",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://gitlab.com/pinax-suite/sdmxlib-rest"
|
|
45
|
+
Repository = "https://gitlab.com/pinax-suite/sdmxlib-rest"
|
|
46
|
+
"Issue Tracker" = "https://gitlab.com/pinax-suite/sdmxlib-rest/-/issues"
|
|
47
|
+
Changelog = "https://gitlab.com/pinax-suite/sdmxlib-rest/-/blob/main/CHANGELOG.md"
|
|
48
|
+
|
|
49
|
+
[build-system]
|
|
50
|
+
requires = ["uv_build>=0.11.6,<0.12.0"]
|
|
51
|
+
build-backend = "uv_build"
|
|
52
|
+
|
|
53
|
+
# Pin the index to public PyPI at the project level so the lock file is
|
|
54
|
+
# portable — a host's user-level uv.toml may point at an authenticated mirror,
|
|
55
|
+
# which is fine interactively but absent in CI and container builds.
|
|
56
|
+
[[tool.uv.index]]
|
|
57
|
+
name = "pypi"
|
|
58
|
+
url = "https://pypi.org/simple"
|
|
59
|
+
default = true
|
|
60
|
+
|
|
61
|
+
[tool.pytest.ini_options]
|
|
62
|
+
testpaths = ["tests"]
|
|
63
|
+
markers = [
|
|
64
|
+
"unit: fast unit tests (no I/O)",
|
|
65
|
+
"integration: tests that use real DuckDB but no network",
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
[tool.coverage.run]
|
|
69
|
+
source = ["src/sdmxlib_rest"]
|
|
70
|
+
|
|
71
|
+
[tool.coverage.report]
|
|
72
|
+
show_missing = true
|
|
73
|
+
skip_covered = false
|
|
74
|
+
|
|
75
|
+
[tool.basedpyright]
|
|
76
|
+
pythonVersion = "3.13"
|
|
77
|
+
typeCheckingMode = "standard"
|
|
78
|
+
venvPath = "."
|
|
79
|
+
venv = ".venv"
|
|
80
|
+
exclude = [".venv"]
|
|
81
|
+
reportAny = "none"
|
|
82
|
+
reportExplicitAny = "none"
|
|
83
|
+
reportUnknownVariableType = "none"
|
|
84
|
+
reportUnknownMemberType = "none"
|
|
85
|
+
reportUnknownArgumentType = "none"
|
|
86
|
+
|
|
87
|
+
[dependency-groups]
|
|
88
|
+
dev = [
|
|
89
|
+
"basedpyright>=1.38.4",
|
|
90
|
+
"pytest>=9.0.3",
|
|
91
|
+
"pytest-asyncio>=0.24",
|
|
92
|
+
"httpx>=0.28",
|
|
93
|
+
"ruff>=0.15.8",
|
|
94
|
+
"pyrefly>=1.2.0",
|
|
95
|
+
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""sdmxlib-rest — generic SDMX-REST HTTP surface over a sdmxlib ``FederatedCatalog``.
|
|
2
|
+
|
|
3
|
+
This package is being extracted in place from ``cpt_sdmx_api`` (see
|
|
4
|
+
``~/.claude/plans/so-as-this-project-misty-pond.md``). It owns the generic
|
|
5
|
+
HTTP shape of SDMX-REST — URLs, content negotiation, streaming, and
|
|
6
|
+
formatting delegation to sdmxlib — over an abstract catalog. Consumers
|
|
7
|
+
supply how the catalog is opened, what gets spliced into responses, and any
|
|
8
|
+
catalog-specific speedups.
|
|
9
|
+
|
|
10
|
+
During the in-place phase it ships as a second module inside the
|
|
11
|
+
``cpt-sdmx-api`` distribution; Phase 5 moves it to its own sibling repo
|
|
12
|
+
(``gitlab.com/pinax-suite/sdmxlib-rest``). It MUST NOT import ``cpt_sdmx_api``
|
|
13
|
+
or ``pinax`` — that separation is the whole point of the boundary, and
|
|
14
|
+
``tests/test_library_import_boundary.py`` fails the build if it slips.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
__all__: list[str] = []
|