datamonger 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.
Files changed (37) hide show
  1. datamonger-0.1.0/.gitignore +110 -0
  2. datamonger-0.1.0/CHANGELOG.md +35 -0
  3. datamonger-0.1.0/LICENSE +21 -0
  4. datamonger-0.1.0/PKG-INFO +319 -0
  5. datamonger-0.1.0/README.md +301 -0
  6. datamonger-0.1.0/pyproject.toml +65 -0
  7. datamonger-0.1.0/src/datamonger/__init__.py +41 -0
  8. datamonger-0.1.0/src/datamonger/_api.py +589 -0
  9. datamonger-0.1.0/src/datamonger/_cache.py +557 -0
  10. datamonger-0.1.0/src/datamonger/_cache_management.py +258 -0
  11. datamonger-0.1.0/src/datamonger/_canonical.py +235 -0
  12. datamonger-0.1.0/src/datamonger/_data/__init__.py +1 -0
  13. datamonger-0.1.0/src/datamonger/_data/index.json +1 -0
  14. datamonger-0.1.0/src/datamonger/_decode.py +337 -0
  15. datamonger-0.1.0/src/datamonger/_decode_libsvm.py +275 -0
  16. datamonger-0.1.0/src/datamonger/_errors.py +73 -0
  17. datamonger-0.1.0/src/datamonger/_models.py +296 -0
  18. datamonger-0.1.0/src/datamonger/_registry.py +331 -0
  19. datamonger-0.1.0/src/datamonger/_selection.py +84 -0
  20. datamonger-0.1.0/src/datamonger/_validate.py +34 -0
  21. datamonger-0.1.0/src/datamonger/errors.py +43 -0
  22. datamonger-0.1.0/src/datamonger/py.typed +1 -0
  23. datamonger-0.1.0/tests/conftest.py +38 -0
  24. datamonger-0.1.0/tests/test_cache.py +277 -0
  25. datamonger-0.1.0/tests/test_canonical.py +295 -0
  26. datamonger-0.1.0/tests/test_conformance.py +301 -0
  27. datamonger-0.1.0/tests/test_decoder.py +400 -0
  28. datamonger-0.1.0/tests/test_dm_add.py +491 -0
  29. datamonger-0.1.0/tests/test_dm_canary.py +381 -0
  30. datamonger-0.1.0/tests/test_dm_index.py +812 -0
  31. datamonger-0.1.0/tests/test_fetch.py +1696 -0
  32. datamonger-0.1.0/tests/test_metadata.py +124 -0
  33. datamonger-0.1.0/tests/test_registry.py +297 -0
  34. datamonger-0.1.0/tests/test_selection.py +185 -0
  35. datamonger-0.1.0/tests/typing/api.py +49 -0
  36. datamonger-0.1.0/tests_live/test_proof_registry.py +59 -0
  37. datamonger-0.1.0/uv.lock +1365 -0
@@ -0,0 +1,110 @@
1
+ # Devenv
2
+ .devenv*
3
+ devenv.local.nix
4
+ devenv.local.yaml
5
+
6
+ # direnv
7
+ .direnv
8
+
9
+ # pre-commit
10
+ .pre-commit-config.yaml
11
+
12
+ # Python --------------------------------------------
13
+ __pycache__/
14
+ *.py[cod]
15
+ *.egg-info/
16
+ .mypy_cache/
17
+ .pytest_cache/
18
+ .ruff_cache/
19
+ .venv/
20
+ dist/
21
+ build/
22
+
23
+ # julia -----------------------------------------------
24
+
25
+ # Files generated by invoking Julia with --code-coverage
26
+ *.jl.cov
27
+ *.jl.*.cov
28
+
29
+ # Files generated by invoking Julia with --track-allocation
30
+ *.jl.mem
31
+
32
+ # System-specific files and directories generated by the BinaryProvider and BinDeps packages
33
+ # They contain absolute paths specific to the host computer, and so should not be committed
34
+ deps/deps.jl
35
+ deps/build.log
36
+ deps/downloads/
37
+ deps/usr/
38
+ deps/src/
39
+
40
+ # Build artifacts for creating documentation generated by the Documenter package
41
+ docs/build/
42
+ docs/site/
43
+
44
+ # File generated by Pkg, the package manager, based on a corresponding Project.toml
45
+ # It records a fixed state of all packages used by the project. As such, it should not be
46
+ # committed for packages, but should be committed for applications that require a static
47
+ # environment.
48
+ Manifest.toml
49
+
50
+ # R -----------------------------------------------
51
+
52
+ # History files
53
+ .Rhistory
54
+ .Rapp.history
55
+
56
+ # Session Data files
57
+ .RData
58
+ .RDataTmp
59
+
60
+ # User-specific files
61
+ .Ruserdata
62
+
63
+ # Example code in package build process
64
+ *-Ex.R
65
+
66
+ # Output files from R CMD build
67
+ /*.tar.gz
68
+
69
+ # Output files from R CMD check
70
+ /*.Rcheck/
71
+
72
+ # Compiled R package objects
73
+ packages/r/src/*.o
74
+ packages/r/src/*.so
75
+ packages/r/src/*.dll
76
+
77
+ # RStudio files
78
+ .Rproj.user/
79
+
80
+ # produced vignettes
81
+ vignettes/*.html
82
+ vignettes/*.pdf
83
+
84
+ # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
85
+ .httr-oauth
86
+
87
+ # knitr and R markdown default cache directories
88
+ *_cache/
89
+ /cache/
90
+
91
+ # Temporary files created by R markdown
92
+ *.utf8.md
93
+ *.knit.md
94
+
95
+ # R Environment Variables
96
+ .Renviron
97
+
98
+ # pkgdown site
99
+ docs/
100
+
101
+ # translation temp files
102
+ po/*~
103
+
104
+ # RStudio Connect folder
105
+ rsconnect/
106
+
107
+ # autoconf files
108
+ config.log
109
+ config.status
110
+ configure
@@ -0,0 +1,35 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0](https://github.com/jolars/datamonger/compare/datamonger-python-v0.0.0...datamonger-python-v0.1.0) (2026-09-07)
4
+
5
+ ### Features
6
+ - freeze revision 1 contracts ([`fdcd6fe`](https://github.com/jolars/datamonger/commit/fdcd6fe40f7e974366952bd0e284de001e1e730a))
7
+ - publish candidate registry ([`d5afe43`](https://github.com/jolars/datamonger/commit/d5afe43c5f6e52b0717dca73ea996f1830356e1b))
8
+ - curate candidate datasets ([`7a577af`](https://github.com/jolars/datamonger/commit/7a577af1059b21a522ee24ad23f36e79a6b7883c))
9
+ - add upstream canary ([`8c78022`](https://github.com/jolars/datamonger/commit/8c7802234a4f34ff630f81abd336d16643c1e460))
10
+ - add manifest authoring tool ([`99dbe00`](https://github.com/jolars/datamonger/commit/99dbe00245ff0248f69e5951e90e14d3885c2e93))
11
+ - complete Python decoding milestone ([`bba391c`](https://github.com/jolars/datamonger/commit/bba391c6ab9a186b384d8d572b44909c8c10f92e))
12
+ - stabilize Python return types ([`665b469`](https://github.com/jolars/datamonger/commit/665b469883e72ffd6e8fde37161c4bf9e01afe35))
13
+ - complete LIBSVM conformance ([`292df84`](https://github.com/jolars/datamonger/commit/292df84c69263178e1e102c60abff0d98c784601))
14
+ - complete delimited-text conformance ([`9a69450`](https://github.com/jolars/datamonger/commit/9a6945025912ca65f184a1dc1ec58a5550ffc44f))
15
+ - complete semantic error taxonomy ([`b3e26fc`](https://github.com/jolars/datamonger/commit/b3e26fc959cf25543cd4a920f6dc7e2185c528ba))
16
+ - add offline cache management ([`7a7b882`](https://github.com/jolars/datamonger/commit/7a7b882ef7ca774f240b00b737498b9026f4ff28))
17
+ - add concurrent cache leases ([`f08f109`](https://github.com/jolars/datamonger/commit/f08f1096bc272f4eac4f4715bace821adc133a58))
18
+ - complete HTTP retrieval semantics ([`0449429`](https://github.com/jolars/datamonger/commit/0449429a51619fe4115234c926f8ae2207ba4339))
19
+ - add artifact retrieval API ([`7cd54a7`](https://github.com/jolars/datamonger/commit/7cd54a7d45e63344b5933a5f03b27dcb69c9b067))
20
+ - add registry catalog lookup ([`881cd66`](https://github.com/jolars/datamonger/commit/881cd66b222c4d02f3176f0a6e7578e67665a404))
21
+ - support scoped registry selectors ([`34649b8`](https://github.com/jolars/datamonger/commit/34649b87d86bf7cee996884b02085a7f8e431074))
22
+ - bundle default registry snapshot ([`4f17c7c`](https://github.com/jolars/datamonger/commit/4f17c7c7c3fed801b4f9ee685180c73ece886e11))
23
+ - complete specification registry milestone ([`8d25760`](https://github.com/jolars/datamonger/commit/8d25760caf38d6281d57585514fad813df15cf35))
24
+ - complete sparse vertical proof ([`1af37bc`](https://github.com/jolars/datamonger/commit/1af37bc632ebc23c3a79b19cdf522cd98106e165))
25
+ - build Python CSV vertical slice ([`ca1e6d7`](https://github.com/jolars/datamonger/commit/ca1e6d77995afe4f0b9fa485ee8e1d9bc743c708))
26
+
27
+ ### Bug Fixes
28
+ - validate manifests at registry build time ([`0ad7d89`](https://github.com/jolars/datamonger/commit/0ad7d896ebf42c59dea71ed38266b6072b10534b))
29
+ - harden retrieval and registry validation ([`f265a8a`](https://github.com/jolars/datamonger/commit/f265a8a830ab372ff31692ad83f34fb453fc869d))
30
+ - enforce explicit delimited-text record grammar ([`a7a8a38`](https://github.com/jolars/datamonger/commit/a7a8a38f8acb2ec797638d14720aff2bf76815e1))
31
+ - declare Ruff for CI ([`2f03c6c`](https://github.com/jolars/datamonger/commit/2f03c6c8702f583db014d6b582ae17426c805021))
32
+
33
+ ### Performance Improvements
34
+ - store logical vectors unboxed ([`3b66850`](https://github.com/jolars/datamonger/commit/3b66850681f55a39b3019f6d8045127710be6bc9))
35
+ - hash sparse matrices from unboxed arrays ([`68fe671`](https://github.com/jolars/datamonger/commit/68fe6716a2c20c7396982a4f8afd13f09ad0010e))
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Datamonger contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,319 @@
1
+ Metadata-Version: 2.5
2
+ Name: datamonger
3
+ Version: 0.1.0
4
+ Summary: Reproducible retrieval and decoding of public research datasets
5
+ Project-URL: Documentation, https://github.com/jolars/datamonger#documentation
6
+ Project-URL: Issues, https://github.com/jolars/datamonger/issues
7
+ Project-URL: Repository, https://github.com/jolars/datamonger
8
+ Author: Johan Larsson
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Requires-Python: >=3.11
12
+ Requires-Dist: numpy>=2.0
13
+ Requires-Dist: pandas>=2.2
14
+ Requires-Dist: platformdirs>=4.3
15
+ Requires-Dist: portalocker[win32]>=4.3
16
+ Requires-Dist: scipy>=1.14
17
+ Description-Content-Type: text/markdown
18
+
19
+ # Datamonger Python client
20
+
21
+ This package is the Python reference client for Datamonger's feature-frozen
22
+ revision 1 contracts. Its public interfaces may change until specification
23
+ revision 1 is independently certified.
24
+
25
+ ## Installation and status
26
+
27
+ The package requires Python 3.11 or newer and has not yet been published to
28
+ PyPI. Install it from the repository root with:
29
+
30
+ ```console
31
+ python -m pip install ./packages/python
32
+ ```
33
+
34
+ For development, enter the repository's devenv shell and use the locked
35
+ environment documented in the
36
+ [contributor guide](https://github.com/jolars/datamonger/blob/main/CONTRIBUTING.md).
37
+
38
+ The package requires pandas, NumPy, SciPy, platformdirs, and portalocker. The
39
+ project code is MIT-licensed; datasets retain their own licenses and terms. See
40
+ the repository's
41
+ [trust model](https://github.com/jolars/datamonger/blob/main/TRUST.md) before
42
+ relying on registry license, distribution, or preservation metadata.
43
+
44
+ ## Quick start
45
+
46
+ The client bundles the immutable `proof-0001` registry snapshot and verifies it
47
+ against a trusted digest shipped in the package. It is the default registry, so
48
+ the index remains available without network access:
49
+
50
+ ```python
51
+ from datamonger import fetch_data
52
+
53
+ iris = fetch_data("iris", source="uci")
54
+ heart = fetch_data("heart_scale", source="libsvm")
55
+ ```
56
+
57
+ Only the registry index is bundled; retrieving an uncached dataset artifact
58
+ still requires network access. The active registry is selected, in descending
59
+ precedence, by a `registry=` argument, a session setting, the nearest project
60
+ selector, and finally `BUNDLED_REGISTRY`. Updates are always explicit—none of
61
+ these scopes resolves a floating release name.
62
+
63
+ For a reproducible analysis, pass an explicit dataset `version` and use
64
+ `return_info=True`. Retain the resolved `dataset_id`, `registry_release`,
65
+ `registry_index_sha256`, artifact digests, verification level, canonical-form
66
+ version, and canonical digest.
67
+
68
+ ## Registry selection
69
+
70
+ To discover a published selector by its bare release name, make an explicit
71
+ catalog lookup:
72
+
73
+ ```python
74
+ from datamonger import fetch_data, resolve_registry
75
+
76
+ registry = resolve_registry("candidate-0002")
77
+ print(registry.index_sha256)
78
+ iris = fetch_data("iris", source="uci", registry=registry)
79
+ ```
80
+
81
+ `resolve_registry()` reads the mutable catalog over HTTPS and returns a frozen
82
+ `Registry` containing the resolved release, index digest, and index URL. The
83
+ lookup is trusted only as strongly as that TLS session. Record and reuse the
84
+ returned selector when reproducibility matters; looking up the same bare name
85
+ again is not a cryptographic pin. The API accepts a custom HTTPS `catalog_url`
86
+ for alternate registries. It does not support floating aliases such as
87
+ `latest`.
88
+
89
+ Pass a `Registry` for one call when the selection belongs to one operation:
90
+
91
+ ```python
92
+ from datamonger import Registry, fetch_data
93
+
94
+ registry = Registry(
95
+ release="2026.08",
96
+ index_sha256="0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
97
+ index_url="https://registry.example/2026.08/index.json",
98
+ )
99
+ iris = fetch_data("iris", source="uci", registry=registry)
100
+ ```
101
+
102
+ Use `set_registry(registry)` to keep that selector active for the Python
103
+ session, and use `set_registry(None)` to clear it. `active_registry()` reports
104
+ the selector that an unqualified call would use:
105
+
106
+ ```python
107
+ from datamonger import active_registry, set_registry
108
+
109
+ set_registry(registry)
110
+ assert active_registry() == registry
111
+ set_registry(None)
112
+ ```
113
+
114
+ To pin a project, check the selector into `.datamonger/selector.json` at the
115
+ project root:
116
+
117
+ ```json
118
+ {
119
+ "schema_version": 1,
120
+ "release": "2026.08",
121
+ "index_sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
122
+ "index_url": "https://registry.example/2026.08/index.json"
123
+ }
124
+ ```
125
+
126
+ Datamonger searches from the current working directory toward the filesystem
127
+ root and uses the nearest such file. A malformed project selector is an error;
128
+ it never causes a fallback to another registry. The release and digest form the
129
+ strong selector. The URL is only its retrieval location, and possession of a
130
+ digest authenticates nothing beyond the channel from which the selector came.
131
+
132
+ ## Return types and decoded verification
133
+
134
+ The decoded return type is fixed by the representation:
135
+
136
+ | Representation | Artifact formats | Python return type |
137
+ | --- | --- | --- |
138
+ | `delimited-text` | CSV or TSV | `pandas.DataFrame` |
139
+ | `libsvm` | LIBSVM or SVMLight | `SparseDataset` |
140
+ | `libsvm-split` | LIBSVM or SVMLight | `SparseDatasetSplit` |
141
+
142
+ Delimited frames use pandas' nullable `Float64`, `Int64`, `string`, and
143
+ `boolean` dtypes, according to the declared logical column types. A frozen
144
+ `SparseDataset` record contains a float64 SciPy CSR `features` matrix and an
145
+ int64 or float64 NumPy `response` vector, according to `label_type`. A frozen
146
+ `SparseDatasetSplit` has separate `train` and `test` fields containing those
147
+ same records, so neither input is concatenated or discarded. The public
148
+ `DatasetData` type alias is the union of these three return types.
149
+
150
+ `return_info=True` wraps the same decoded object in `FetchResult.data`; it does
151
+ not change its representation. Pandas, NumPy, and SciPy are required
152
+ dependencies, so return types never depend on which optional packages happen
153
+ to be installed.
154
+
155
+ CSV, TSV, LIBSVM, and SVMLight artifacts support manifest-declared `none`,
156
+ `gzip`, and `bzip2` compression. The client verifies and caches the exact
157
+ compressed artifact, then decompresses it for decoding; file names and URLs do
158
+ not determine the compression method.
159
+
160
+ Use `return_info=True` to receive a `FetchResult` containing the resolved
161
+ dataset identity, registry selector, artifact digests, and decoded-verification
162
+ record. Decoded verification is enabled by default for every representation.
163
+ It checks both the expected component shapes and the canonical SHA-256. For
164
+ diagnostic or performance-sensitive work, `verify_decoded=False` explicitly
165
+ skips those checks while retaining mandatory artifact size and SHA-256
166
+ verification; `FetchInfo.verification` then reports `"artifact"` rather than
167
+ `"decoded"`.
168
+
169
+ ## Metadata and artifact access
170
+
171
+ Inspect registry metadata without retrieving an artifact with `data_info()`, or
172
+ enumerate every version in the active immutable release with `list_data()`:
173
+
174
+ ```python
175
+ from datamonger import data_info, list_data
176
+
177
+ iris_info = data_info("iris", source="uci")
178
+ assert iris_info.dataset_id == "uci:iris@1"
179
+ for info in list_data():
180
+ print(info.dataset_id, info.modality, info.representation["expect"])
181
+ ```
182
+
183
+ Both operations use the same registry selection as `fetch_data()`, and
184
+ `data_info()` uses its default-version resolution. A `DataInfo` includes the
185
+ registry selector, provenance, licensing, artifacts and their distribution and
186
+ preservation records, the full representation, `expected_components`,
187
+ `verification_records`, related datasets, and task metadata. Pass
188
+ `offline=True` to require a bundled or already cached registry index.
189
+
190
+ To retrieve verified artifact bytes without decoding them, use
191
+ `fetch_artifact()`:
192
+
193
+ ```python
194
+ from datamonger import fetch_artifact
195
+
196
+ iris_csv = fetch_artifact("iris", source="uci")
197
+ ```
198
+
199
+ The function returns a `pathlib.Path` in the content-addressed cache. An
200
+ artifact name may be omitted only when the resolved dataset version has one
201
+ artifact; otherwise, pass it explicitly with `artifact="train"`. Retrieval
202
+ locations are tried in manifest order, and size and SHA-256 verification cannot
203
+ be disabled. The cached bytes retain any artifact compression declared by the
204
+ manifest—HTTP content coding is a separate transport detail.
205
+
206
+ Pass `offline=True` to `fetch_data()` or `fetch_artifact()` when network access
207
+ must not be attempted. The selected registry does not change in offline mode.
208
+ Remote registry indexes and artifacts must already be present and valid in the
209
+ cache; the package's bundled registry index remains available, but its dataset
210
+ artifacts are not bundled. Missing or corrupt cached content raises
211
+ `RegistryOfflineError` for an index and `OfflineError` for an artifact.
212
+
213
+ ## Error taxonomy
214
+
215
+ Expected failures derive from `DatamongerError` and are exported by
216
+ `datamonger.errors`. The shared semantic categories map to Python as follows:
217
+
218
+ | Category | Python type |
219
+ | --- | --- |
220
+ | `unknown-dataset` | `UnknownDatasetError` |
221
+ | `unsupported-registry` | `UnsupportedRegistryError` |
222
+ | `unsupported-decoder` | `UnsupportedDecoderError` |
223
+ | `artifact-unavailable` | `ArtifactUnavailableError` |
224
+ | `artifact-offline` | `OfflineError` |
225
+ | `retrieval-exhausted` | `RetrievalLocationsError` |
226
+ | `artifact-integrity` | `ArtifactIntegrityError` |
227
+ | `decoded-integrity` | `DecodedIntegrityError` |
228
+ | `cache` | `CacheError` |
229
+ | `decode` | `DecodeError` |
230
+
231
+ All artifact selection and retrieval failures derive from `RetrievalError`.
232
+ `ArtifactSelectionError` additionally distinguishes an omitted, ambiguous, or
233
+ unknown artifact name. `RegistryError` is the base for
234
+ `RegistryIntegrityError`, `RegistryOfflineError`, `RegistryReleaseError`, and
235
+ `RegistryRetrievalError`; `UnsupportedRegistryError` is also a registry failure.
236
+
237
+ ## Cache management
238
+
239
+ Inspect the cache with `cache_info()`:
240
+
241
+ ```python
242
+ from datamonger import cache_info
243
+
244
+ info = cache_info()
245
+ print(info.location, info.total_size)
246
+ for entry in info.entries:
247
+ print(entry.kind, entry.sha256, entry.size, entry.datasets, entry.valid)
248
+ ```
249
+
250
+ The inventory covers cached registry indexes and artifacts, hashes every entry,
251
+ and associates artifact digests with canonical dataset versions found in the
252
+ bundled and cached indexes. Use `cache_clean(dataset="uci:iris@1")` to remove
253
+ the artifacts referenced by one version, or use `older_than=timedelta(days=30)`
254
+ to remove old entries. The two filters intersect when combined. Calling
255
+ `cache_clean()` without filters selects the entire cache. Its result lists both
256
+ removed entries and entries skipped because another process is publishing or
257
+ reading them. Cache eviction is always explicit; the client never evicts data
258
+ automatically.
259
+
260
+ Every public operation that reads or changes the cache accepts `cache_dir=`.
261
+ Pass the same private directory consistently to isolate an application or test.
262
+ The platform-default location is reported by `cache_info().location`.
263
+
264
+ ## Cache coordination
265
+
266
+ The Python client coordinates each cached registry and artifact through an
267
+ operating-system file lease at
268
+ `.leases/<namespace>/sha256/<digest>.lock`. Publishers and readers take shared
269
+ leases. A cleaner tries the exclusive side without waiting and skips the object
270
+ when that attempt fails. A separate `<digest>.publish.lock` serializes the brief
271
+ validation and commit phases while allowing downloads for the same digest to
272
+ overlap.
273
+
274
+ Downloads remain in destination-directory `.download-*` files until they have
275
+ been flushed, size-checked, and hash-checked. Publication uses an atomic rename,
276
+ and a publisher rechecks the target under the publication lock so that it does
277
+ not replace a complete object committed by another publisher. Readers retain
278
+ their shared lease through registry parsing or dataset decoding.
279
+
280
+ Lease files deliberately remain on disk as rendezvous records. Their presence
281
+ does not indicate ownership; the operating system's lock state does. Process
282
+ termination releases that state, and a restarted host has no surviving lock
283
+ owners, so a stale record is immediately reclaimable without a timeout that
284
+ could misclassify a slow but live reader. The cache root is client-private and
285
+ must reside on a filesystem that implements local advisory file locking and
286
+ atomic replacement.
287
+
288
+ ## Public API summary
289
+
290
+ | Name | Purpose |
291
+ | --- | --- |
292
+ | `fetch_data()` | Resolve, retrieve, verify, and decode one dataset. |
293
+ | `fetch_artifact()` | Retrieve one verified artifact without decoding it. |
294
+ | `data_info()` | Inspect metadata for one resolved dataset version. |
295
+ | `list_data()` | List every version in the selected registry. |
296
+ | `resolve_registry()` | Discover a strong selector through an HTTPS catalog. |
297
+ | `active_registry()` | Report the selector an unqualified call will use. |
298
+ | `set_registry()` | Set or clear the process-local session selector. |
299
+ | `cache_info()` | Inspect cached indexes and artifacts without network access. |
300
+ | `cache_clean()` | Explicitly evict matching inactive cache entries. |
301
+
302
+ The package also exports these public values and immutable result types:
303
+
304
+ | Name | Contents |
305
+ | --- | --- |
306
+ | `BUNDLED_REGISTRY` | The package's default strong selector. |
307
+ | `Registry` | A selector's release, index digest, URL, and schema version. |
308
+ | `FetchResult` | Decoded `data` and its `FetchInfo`. |
309
+ | `FetchInfo` | Resolved identity, selector, artifact digests, and verification record. |
310
+ | `DataInfo` | Provenance, license, artifacts, representation, expectations, relations, and tasks. |
311
+ | `SparseDataset` | A CSR feature matrix and response vector. |
312
+ | `SparseDatasetSplit` | Separate train and test `SparseDataset` records. |
313
+ | `DatasetData` | The union of all decoded return types. |
314
+ | `CacheEntry` | One inspected registry or artifact cache object. |
315
+ | `CacheInfo` | Cache location, total size, and entries. |
316
+ | `CacheCleanResult` | Removed and skipped entries, plus `bytes_removed`. |
317
+
318
+ Expected public failures are exported from `datamonger.errors`; all derive from
319
+ `DatamongerError`.