sourceledger 0.3.1__tar.gz → 0.5.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.
- sourceledger-0.5.0/PKG-INFO +184 -0
- sourceledger-0.5.0/README.md +152 -0
- {sourceledger-0.3.1 → sourceledger-0.5.0}/pyproject.toml +44 -10
- {sourceledger-0.3.1 → sourceledger-0.5.0}/pyproject.toml.orig +42 -15
- sourceledger-0.5.0/src/sourceledger/__init__.py +60 -0
- sourceledger-0.5.0/src/sourceledger/builder.py +629 -0
- sourceledger-0.5.0/src/sourceledger/cli.py +639 -0
- sourceledger-0.5.0/src/sourceledger/fetcher.py +472 -0
- sourceledger-0.5.0/src/sourceledger/ledger.py +685 -0
- sourceledger-0.5.0/src/sourceledger/manifest.py +368 -0
- sourceledger-0.5.0/src/sourceledger/releaser.py +687 -0
- sourceledger-0.5.0/src/sourceledger/report.py +551 -0
- {sourceledger-0.3.1 → sourceledger-0.5.0}/src/sourceledger/sources.schema.json +51 -5
- sourceledger-0.3.1/PKG-INFO +0 -315
- sourceledger-0.3.1/README.md +0 -289
- sourceledger-0.3.1/src/sourceledger/__init__.py +0 -54
- sourceledger-0.3.1/src/sourceledger/cli.py +0 -155
- sourceledger-0.3.1/src/sourceledger/ledger.py +0 -1440
- {sourceledger-0.3.1 → sourceledger-0.5.0}/LICENSE +0 -0
- {sourceledger-0.3.1 → sourceledger-0.5.0}/src/sourceledger/py.typed +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sourceledger
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Fetch or record a dataset's public files with provenance, and release it without files whose terms forbid it
|
|
5
|
+
Keywords: provenance,data pipeline,reproducibility,open data,research software,FAIR
|
|
6
|
+
Author: Simon van Lierde
|
|
7
|
+
Author-email: Simon van Lierde <code@duinlab.nl>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Dist: pyarrow>=23 ; extra == 'parquet'
|
|
21
|
+
Requires-Dist: mlcroissant>=1.1.1 ; extra == 'release'
|
|
22
|
+
Requires-Dist: roc-validator>=0.13.1 ; extra == 'release'
|
|
23
|
+
Requires-Dist: openpyxl>=3.1 ; extra == 'xlsx'
|
|
24
|
+
Requires-Python: >=3.12
|
|
25
|
+
Project-URL: Homepage, https://github.com/simonvanlierde/sourceledger
|
|
26
|
+
Project-URL: Issues, https://github.com/simonvanlierde/sourceledger/issues
|
|
27
|
+
Project-URL: Changelog, https://github.com/simonvanlierde/sourceledger/blob/main/CHANGELOG.md
|
|
28
|
+
Provides-Extra: parquet
|
|
29
|
+
Provides-Extra: release
|
|
30
|
+
Provides-Extra: xlsx
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# sourceledger
|
|
34
|
+
|
|
35
|
+
[](https://github.com/simonvanlierde/sourceledger/actions/workflows/python.yml)
|
|
36
|
+
[](LICENSE)
|
|
37
|
+
[](https://doi.org/10.5281/zenodo.23460694)
|
|
38
|
+
[](https://scorecard.dev/viewer/?uri=github.com/simonvanlierde/sourceledger)
|
|
39
|
+
[](https://www.bestpractices.dev/projects/16545)
|
|
40
|
+
[](https://app.codspeed.io/simonvanlierde/sourceledger?utm_source=badge)
|
|
41
|
+
|
|
42
|
+
Build a dataset from published sources and keep a record of the downloads behind it.
|
|
43
|
+
|
|
44
|
+
sourceledger is a Python library and command for researchers who combine other people's
|
|
45
|
+
CSV, JSON, Excel or binary files. List the sources and reuse terms in `sources.toml`, then:
|
|
46
|
+
|
|
47
|
+
- `fetch` downloads the files and records their URLs, dates and SHA-256 checksums.
|
|
48
|
+
- `build` writes tables with provenance columns, or copies file sources unchanged.
|
|
49
|
+
- `validate` checks the outputs against the downloads and the manifest.
|
|
50
|
+
- `release` writes the folder to publish, without the sources whose terms forbid it, and
|
|
51
|
+
checks it.
|
|
52
|
+
|
|
53
|
+
Each table row identifies its download. A `datapackage.json` describes the outputs.
|
|
54
|
+
The [documentation website](https://simonvanlierde.com/sourceledger/) follows a source through a publisher's revision.
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
uv tool install sourceledger
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For a Python project that imports the library, use `uv add sourceledger` instead.
|
|
63
|
+
Use `sourceledger[xlsx]` in either command to read Excel files, `sourceledger[parquet]`
|
|
64
|
+
to write Parquet outputs, or `sourceledger[release]` to check RO-Crate and Croissant metadata.
|
|
65
|
+
Python 3.12 or later is required; Linux, macOS and Windows are supported.
|
|
66
|
+
This README follows `main`, including [unreleased features](CHANGELOG.md#unreleased).
|
|
67
|
+
|
|
68
|
+
## Quick start
|
|
69
|
+
|
|
70
|
+
Write a `sources.toml` in the project root (`sourceledger init` writes a starter):
|
|
71
|
+
|
|
72
|
+
```toml
|
|
73
|
+
[[source]]
|
|
74
|
+
id = "co2"
|
|
75
|
+
status = "implemented"
|
|
76
|
+
url = "https://raw.githubusercontent.com/datasets/co2-ppm/main/data/co2-annmean-mlo.csv"
|
|
77
|
+
vintage = "main branch, unversioned"
|
|
78
|
+
terms = "ODC-PDDL-1.0 (datasets/co2-ppm package; original data from NOAA GML)"
|
|
79
|
+
terms_url = "https://opendatacommons.org/licenses/pddl/"
|
|
80
|
+
license = "PDDL-1.0"
|
|
81
|
+
redistribute = true
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Then run the stages from that directory:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
sourceledger fetch
|
|
88
|
+
sourceledger build
|
|
89
|
+
sourceledger validate
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`sourceledger fetch --help` lists one stage's options, and `--dry-run` on `fetch`, `record`
|
|
93
|
+
and `build` shows what they would write. Exit code 1 means `validate` or `release` found problems, 2 a
|
|
94
|
+
usage error and 3 that a stage could not run; see [options and exit codes](docs/reference.md#options-output-and-exit-codes).
|
|
95
|
+
|
|
96
|
+
For [Parquet outputs](docs/reference.md#sourcestoml), set `output_format = "parquet"`
|
|
97
|
+
before the first `[[source]]` table in `sources.toml`, after installing the Parquet extra above.
|
|
98
|
+
CSV remains the default. Parquet writing and validation use batches of at most 10,000 rows;
|
|
99
|
+
see [table memory limits](docs/reference.md#sourcestoml).
|
|
100
|
+
|
|
101
|
+
`sourceledger` reads CSV (gzipped or not), JSON and Excel, by each source's `format` or its
|
|
102
|
+
URL's extension. Set `format = "file"` to keep a raster, archive or other file unchanged.
|
|
103
|
+
For another table format, see [custom readers](docs/recipes.md#write-a-custom-reader).
|
|
104
|
+
If another tool downloads a source, [record its file](docs/recipes.md#record-a-file-another-tool-downloaded)
|
|
105
|
+
instead of fetching it.
|
|
106
|
+
|
|
107
|
+
### What to commit
|
|
108
|
+
|
|
109
|
+
Commit `sources.toml` and `data/fetches.jsonl`. The log holds checksums and URLs, not
|
|
110
|
+
data: it's the history of every version you have fetched.
|
|
111
|
+
|
|
112
|
+
Build output is a local working dataset. A file source is copied unchanged, including
|
|
113
|
+
when `redistribute = false`. Check [reuse terms before publication](docs/secure-use.md#check-redistribute-before-you-publish-raw-files).
|
|
114
|
+
|
|
115
|
+
Keep `data/raw/` and `data/processed/` out of git, so the repository never redistributes
|
|
116
|
+
a publisher's data. The `.fetch.json` records live in `data/raw/` too, so a fresh clone
|
|
117
|
+
runs `fetch` before `build` and `validate`.
|
|
118
|
+
|
|
119
|
+
## Documentation
|
|
120
|
+
|
|
121
|
+
- **Get started:** follow the [worked example](docs/getting-started.md) to notice a revised
|
|
122
|
+
source and rebuild the dataset.
|
|
123
|
+
- **Configure and run:** use the [manifest and command reference](docs/reference.md),
|
|
124
|
+
[download limits and retries](docs/fetching.md), and [recipes](docs/recipes.md) for
|
|
125
|
+
pooch, DVC, dlt, your own fetcher and custom readers.
|
|
126
|
+
- **Inspect and share:** consume [JSON reports](docs/reference.md#json-reports) in CI, or create a
|
|
127
|
+
[standalone HTML provenance report](docs/reference.md#html-provenance-report) for dataset recipients
|
|
128
|
+
with `sourceledger report > provenance.html`.
|
|
129
|
+
- **Understand the checks:** read [how it works](docs/architecture.md),
|
|
130
|
+
[safe use](docs/secure-use.md), and [what the checks establish](docs/assurance-case.md).
|
|
131
|
+
- **Choose and verify:** see [where sourceledger fits](docs/where-it-fits.md) among related
|
|
132
|
+
tools, or check a sourceledger release's
|
|
133
|
+
[signed provenance and reproducible build](docs/secure-use.md#check-a-sourceledger-release).
|
|
134
|
+
|
|
135
|
+
## Project status
|
|
136
|
+
|
|
137
|
+
### Stability
|
|
138
|
+
|
|
139
|
+
Until 1.0, the public API is `sourceledger`'s `__all__`, the keys of `sources.toml`, the
|
|
140
|
+
format of fetch records and the log, and the CLI's stages, options, exit codes and `--json`
|
|
141
|
+
reports. A breaking change to any of them comes only in a
|
|
142
|
+
minor version, listed in [CHANGELOG.md](CHANGELOG.md), with a warning first where that's
|
|
143
|
+
cheap. Older fetch logs stay readable. A record written by `record()`, or with
|
|
144
|
+
`parameters`, is not readable by 0.4.0: after a downgrade, run `fetch` again.
|
|
145
|
+
|
|
146
|
+
### Roadmap
|
|
147
|
+
|
|
148
|
+
- An error class per kind of failure in the other stages, under `ValueError` and `OSError`,
|
|
149
|
+
once a caller needs to tell them apart. This will not break code that catches the base classes.
|
|
150
|
+
- Comparing two versions of a table row by row, with the row keys the caller names, so a
|
|
151
|
+
revision shows which values changed and not only that the bytes did. It starts as a pilot on
|
|
152
|
+
real data, the archived World Development Indicators releases, before it becomes an API.
|
|
153
|
+
- A review by [pyOpenSci](https://www.pyopensci.org) once the project has users besides
|
|
154
|
+
its own template.
|
|
155
|
+
|
|
156
|
+
Not planned:
|
|
157
|
+
|
|
158
|
+
- Templated, paginated or parallel downloads, an `update` command, or a plugin per download
|
|
159
|
+
tool. Other tools fetch those files, and `record` logs them
|
|
160
|
+
([0005](docs/decisions/0005-provenance-core.md)).
|
|
161
|
+
|
|
162
|
+
Ideas and requests are welcome as [issues](https://github.com/simonvanlierde/sourceledger/issues).
|
|
163
|
+
|
|
164
|
+
## Development
|
|
165
|
+
|
|
166
|
+
You need [uv](https://docs.astral.sh/uv/), [just](https://just.systems), and Node 26 with
|
|
167
|
+
[pnpm](https://pnpm.io) for the documentation site, which `just check` also builds.
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
uv sync
|
|
171
|
+
just check
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The site is built with Astro from the Markdown in `docs/`. `just site` builds it into
|
|
175
|
+
`site/dist/`, and every push to `main` deploys it to GitHub Pages at
|
|
176
|
+
<https://simonvanlierde.com/sourceledger/>.
|
|
177
|
+
|
|
178
|
+
[Contributing](.github/CONTRIBUTING.md) covers hooks, coding standards and tests.
|
|
179
|
+
[Governance](GOVERNANCE.md) explains project decisions. Report vulnerabilities through
|
|
180
|
+
[Security](.github/SECURITY.md).
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# sourceledger
|
|
2
|
+
|
|
3
|
+
[](https://github.com/simonvanlierde/sourceledger/actions/workflows/python.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://doi.org/10.5281/zenodo.23460694)
|
|
6
|
+
[](https://scorecard.dev/viewer/?uri=github.com/simonvanlierde/sourceledger)
|
|
7
|
+
[](https://www.bestpractices.dev/projects/16545)
|
|
8
|
+
[](https://app.codspeed.io/simonvanlierde/sourceledger?utm_source=badge)
|
|
9
|
+
|
|
10
|
+
Build a dataset from published sources and keep a record of the downloads behind it.
|
|
11
|
+
|
|
12
|
+
sourceledger is a Python library and command for researchers who combine other people's
|
|
13
|
+
CSV, JSON, Excel or binary files. List the sources and reuse terms in `sources.toml`, then:
|
|
14
|
+
|
|
15
|
+
- `fetch` downloads the files and records their URLs, dates and SHA-256 checksums.
|
|
16
|
+
- `build` writes tables with provenance columns, or copies file sources unchanged.
|
|
17
|
+
- `validate` checks the outputs against the downloads and the manifest.
|
|
18
|
+
- `release` writes the folder to publish, without the sources whose terms forbid it, and
|
|
19
|
+
checks it.
|
|
20
|
+
|
|
21
|
+
Each table row identifies its download. A `datapackage.json` describes the outputs.
|
|
22
|
+
The [documentation website](https://simonvanlierde.com/sourceledger/) follows a source through a publisher's revision.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
uv tool install sourceledger
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
For a Python project that imports the library, use `uv add sourceledger` instead.
|
|
31
|
+
Use `sourceledger[xlsx]` in either command to read Excel files, `sourceledger[parquet]`
|
|
32
|
+
to write Parquet outputs, or `sourceledger[release]` to check RO-Crate and Croissant metadata.
|
|
33
|
+
Python 3.12 or later is required; Linux, macOS and Windows are supported.
|
|
34
|
+
This README follows `main`, including [unreleased features](CHANGELOG.md#unreleased).
|
|
35
|
+
|
|
36
|
+
## Quick start
|
|
37
|
+
|
|
38
|
+
Write a `sources.toml` in the project root (`sourceledger init` writes a starter):
|
|
39
|
+
|
|
40
|
+
```toml
|
|
41
|
+
[[source]]
|
|
42
|
+
id = "co2"
|
|
43
|
+
status = "implemented"
|
|
44
|
+
url = "https://raw.githubusercontent.com/datasets/co2-ppm/main/data/co2-annmean-mlo.csv"
|
|
45
|
+
vintage = "main branch, unversioned"
|
|
46
|
+
terms = "ODC-PDDL-1.0 (datasets/co2-ppm package; original data from NOAA GML)"
|
|
47
|
+
terms_url = "https://opendatacommons.org/licenses/pddl/"
|
|
48
|
+
license = "PDDL-1.0"
|
|
49
|
+
redistribute = true
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Then run the stages from that directory:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
sourceledger fetch
|
|
56
|
+
sourceledger build
|
|
57
|
+
sourceledger validate
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`sourceledger fetch --help` lists one stage's options, and `--dry-run` on `fetch`, `record`
|
|
61
|
+
and `build` shows what they would write. Exit code 1 means `validate` or `release` found problems, 2 a
|
|
62
|
+
usage error and 3 that a stage could not run; see [options and exit codes](docs/reference.md#options-output-and-exit-codes).
|
|
63
|
+
|
|
64
|
+
For [Parquet outputs](docs/reference.md#sourcestoml), set `output_format = "parquet"`
|
|
65
|
+
before the first `[[source]]` table in `sources.toml`, after installing the Parquet extra above.
|
|
66
|
+
CSV remains the default. Parquet writing and validation use batches of at most 10,000 rows;
|
|
67
|
+
see [table memory limits](docs/reference.md#sourcestoml).
|
|
68
|
+
|
|
69
|
+
`sourceledger` reads CSV (gzipped or not), JSON and Excel, by each source's `format` or its
|
|
70
|
+
URL's extension. Set `format = "file"` to keep a raster, archive or other file unchanged.
|
|
71
|
+
For another table format, see [custom readers](docs/recipes.md#write-a-custom-reader).
|
|
72
|
+
If another tool downloads a source, [record its file](docs/recipes.md#record-a-file-another-tool-downloaded)
|
|
73
|
+
instead of fetching it.
|
|
74
|
+
|
|
75
|
+
### What to commit
|
|
76
|
+
|
|
77
|
+
Commit `sources.toml` and `data/fetches.jsonl`. The log holds checksums and URLs, not
|
|
78
|
+
data: it's the history of every version you have fetched.
|
|
79
|
+
|
|
80
|
+
Build output is a local working dataset. A file source is copied unchanged, including
|
|
81
|
+
when `redistribute = false`. Check [reuse terms before publication](docs/secure-use.md#check-redistribute-before-you-publish-raw-files).
|
|
82
|
+
|
|
83
|
+
Keep `data/raw/` and `data/processed/` out of git, so the repository never redistributes
|
|
84
|
+
a publisher's data. The `.fetch.json` records live in `data/raw/` too, so a fresh clone
|
|
85
|
+
runs `fetch` before `build` and `validate`.
|
|
86
|
+
|
|
87
|
+
## Documentation
|
|
88
|
+
|
|
89
|
+
- **Get started:** follow the [worked example](docs/getting-started.md) to notice a revised
|
|
90
|
+
source and rebuild the dataset.
|
|
91
|
+
- **Configure and run:** use the [manifest and command reference](docs/reference.md),
|
|
92
|
+
[download limits and retries](docs/fetching.md), and [recipes](docs/recipes.md) for
|
|
93
|
+
pooch, DVC, dlt, your own fetcher and custom readers.
|
|
94
|
+
- **Inspect and share:** consume [JSON reports](docs/reference.md#json-reports) in CI, or create a
|
|
95
|
+
[standalone HTML provenance report](docs/reference.md#html-provenance-report) for dataset recipients
|
|
96
|
+
with `sourceledger report > provenance.html`.
|
|
97
|
+
- **Understand the checks:** read [how it works](docs/architecture.md),
|
|
98
|
+
[safe use](docs/secure-use.md), and [what the checks establish](docs/assurance-case.md).
|
|
99
|
+
- **Choose and verify:** see [where sourceledger fits](docs/where-it-fits.md) among related
|
|
100
|
+
tools, or check a sourceledger release's
|
|
101
|
+
[signed provenance and reproducible build](docs/secure-use.md#check-a-sourceledger-release).
|
|
102
|
+
|
|
103
|
+
## Project status
|
|
104
|
+
|
|
105
|
+
### Stability
|
|
106
|
+
|
|
107
|
+
Until 1.0, the public API is `sourceledger`'s `__all__`, the keys of `sources.toml`, the
|
|
108
|
+
format of fetch records and the log, and the CLI's stages, options, exit codes and `--json`
|
|
109
|
+
reports. A breaking change to any of them comes only in a
|
|
110
|
+
minor version, listed in [CHANGELOG.md](CHANGELOG.md), with a warning first where that's
|
|
111
|
+
cheap. Older fetch logs stay readable. A record written by `record()`, or with
|
|
112
|
+
`parameters`, is not readable by 0.4.0: after a downgrade, run `fetch` again.
|
|
113
|
+
|
|
114
|
+
### Roadmap
|
|
115
|
+
|
|
116
|
+
- An error class per kind of failure in the other stages, under `ValueError` and `OSError`,
|
|
117
|
+
once a caller needs to tell them apart. This will not break code that catches the base classes.
|
|
118
|
+
- Comparing two versions of a table row by row, with the row keys the caller names, so a
|
|
119
|
+
revision shows which values changed and not only that the bytes did. It starts as a pilot on
|
|
120
|
+
real data, the archived World Development Indicators releases, before it becomes an API.
|
|
121
|
+
- A review by [pyOpenSci](https://www.pyopensci.org) once the project has users besides
|
|
122
|
+
its own template.
|
|
123
|
+
|
|
124
|
+
Not planned:
|
|
125
|
+
|
|
126
|
+
- Templated, paginated or parallel downloads, an `update` command, or a plugin per download
|
|
127
|
+
tool. Other tools fetch those files, and `record` logs them
|
|
128
|
+
([0005](docs/decisions/0005-provenance-core.md)).
|
|
129
|
+
|
|
130
|
+
Ideas and requests are welcome as [issues](https://github.com/simonvanlierde/sourceledger/issues).
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
You need [uv](https://docs.astral.sh/uv/), [just](https://just.systems), and Node 26 with
|
|
135
|
+
[pnpm](https://pnpm.io) for the documentation site, which `just check` also builds.
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
uv sync
|
|
139
|
+
just check
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The site is built with Astro from the Markdown in `docs/`. `just site` builds it into
|
|
143
|
+
`site/dist/`, and every push to `main` deploys it to GitHub Pages at
|
|
144
|
+
<https://simonvanlierde.com/sourceledger/>.
|
|
145
|
+
|
|
146
|
+
[Contributing](.github/CONTRIBUTING.md) covers hooks, coding standards and tests.
|
|
147
|
+
[Governance](GOVERNANCE.md) explains project decisions. Report vulnerabilities through
|
|
148
|
+
[Security](.github/SECURITY.md).
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sourceledger"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "Fetch
|
|
3
|
+
version = "0.5.0"
|
|
4
|
+
description = "Fetch or record a dataset's public files with provenance, and release it without files whose terms forbid it"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
7
7
|
license = "MIT"
|
|
@@ -17,7 +17,7 @@ keywords = [
|
|
|
17
17
|
classifiers = [
|
|
18
18
|
"Development Status :: 3 - Alpha",
|
|
19
19
|
"Intended Audience :: Science/Research",
|
|
20
|
-
"Operating System ::
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
21
|
"Programming Language :: Python :: 3",
|
|
22
22
|
"Programming Language :: Python :: 3.12",
|
|
23
23
|
"Programming Language :: Python :: 3.13",
|
|
@@ -33,28 +33,38 @@ name = "Simon van Lierde"
|
|
|
33
33
|
email = "code@duinlab.nl"
|
|
34
34
|
|
|
35
35
|
[project.scripts]
|
|
36
|
-
sourceledger = "sourceledger.cli:
|
|
36
|
+
sourceledger = "sourceledger.cli:entry"
|
|
37
37
|
|
|
38
38
|
[project.urls]
|
|
39
39
|
Homepage = "https://github.com/simonvanlierde/sourceledger"
|
|
40
40
|
Issues = "https://github.com/simonvanlierde/sourceledger/issues"
|
|
41
|
+
Changelog = "https://github.com/simonvanlierde/sourceledger/blob/main/CHANGELOG.md"
|
|
41
42
|
|
|
42
43
|
[project.optional-dependencies]
|
|
43
44
|
xlsx = ["openpyxl>=3.1"]
|
|
45
|
+
parquet = ["pyarrow>=23"]
|
|
46
|
+
release = [
|
|
47
|
+
"mlcroissant>=1.1.1",
|
|
48
|
+
"roc-validator>=0.13.1",
|
|
49
|
+
]
|
|
44
50
|
|
|
45
51
|
[dependency-groups]
|
|
46
52
|
dev = [
|
|
47
53
|
"frictionless>=5.20",
|
|
48
|
-
"hypothesis>=6.170.
|
|
54
|
+
"hypothesis>=6.170.13",
|
|
49
55
|
"jsonschema>=4.26",
|
|
56
|
+
"mlcroissant>=1.1.1",
|
|
57
|
+
"mutmut>=3.8.1",
|
|
50
58
|
"openpyxl>=3.1",
|
|
51
|
-
"
|
|
59
|
+
"polars>=1.35",
|
|
60
|
+
"pyarrow>=23",
|
|
61
|
+
"pytest>=9.2.0",
|
|
52
62
|
"pytest-codspeed>=5.0.3",
|
|
53
63
|
"pytest-cov>=7.1.0",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
64
|
+
"roc-validator>=0.13.1",
|
|
65
|
+
"ruff>=0.17.3",
|
|
66
|
+
"ty>=0.0.93",
|
|
56
67
|
]
|
|
57
|
-
mutation = ["mutmut>=3.8.0"]
|
|
58
68
|
|
|
59
69
|
[build-system]
|
|
60
70
|
requires = ["uv_build>=0.12.19,<0.14.0"]
|
|
@@ -73,7 +83,12 @@ line-length = 120
|
|
|
73
83
|
docstring-code-format = true
|
|
74
84
|
|
|
75
85
|
[tool.ruff.lint]
|
|
76
|
-
|
|
86
|
+
preview = true
|
|
87
|
+
explicit-preview-rules = true
|
|
88
|
+
select = [
|
|
89
|
+
"ALL",
|
|
90
|
+
"PLW1514",
|
|
91
|
+
]
|
|
77
92
|
ignore = [
|
|
78
93
|
"ANN204",
|
|
79
94
|
"COM812",
|
|
@@ -92,6 +107,15 @@ ignore = [
|
|
|
92
107
|
"PLR2004",
|
|
93
108
|
"ANN201",
|
|
94
109
|
]
|
|
110
|
+
"docs/examples/**" = [
|
|
111
|
+
"T201",
|
|
112
|
+
"INP001",
|
|
113
|
+
"D1",
|
|
114
|
+
"ANN",
|
|
115
|
+
"E501",
|
|
116
|
+
"FBT003",
|
|
117
|
+
"B905",
|
|
118
|
+
]
|
|
95
119
|
"src/sourceledger/cli.py" = ["T201"]
|
|
96
120
|
|
|
97
121
|
[tool.ruff.lint.pydocstyle]
|
|
@@ -101,6 +125,12 @@ convention = "google"
|
|
|
101
125
|
allow-magic-value-types = ["int"]
|
|
102
126
|
max-args = 10
|
|
103
127
|
|
|
128
|
+
[tool.ty.src]
|
|
129
|
+
exclude = ["docs/examples"]
|
|
130
|
+
|
|
131
|
+
[tool.ty.terminal]
|
|
132
|
+
error-on-warning = false
|
|
133
|
+
|
|
104
134
|
[tool.pytest.ini_options]
|
|
105
135
|
addopts = [
|
|
106
136
|
"-ra",
|
|
@@ -112,6 +142,7 @@ addopts = [
|
|
|
112
142
|
]
|
|
113
143
|
markers = ["live: calls a real external service; deselected unless run with -m live"]
|
|
114
144
|
testpaths = ["tests"]
|
|
145
|
+
pythonpath = ["tests"]
|
|
115
146
|
|
|
116
147
|
[tool.coverage.run]
|
|
117
148
|
source = ["src"]
|
|
@@ -126,9 +157,12 @@ exclude_also = [
|
|
|
126
157
|
]
|
|
127
158
|
|
|
128
159
|
[tool.mutmut]
|
|
160
|
+
process_isolation = "forkserver"
|
|
129
161
|
source_paths = ["src"]
|
|
130
162
|
also_copy = [
|
|
131
163
|
"README.md",
|
|
132
164
|
"docs",
|
|
165
|
+
".github/scripts",
|
|
166
|
+
"src/sourceledger/sources.schema.json",
|
|
133
167
|
]
|
|
134
168
|
do_not_mutate_patterns = ['^\s*_logger\.\w+\(']
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sourceledger"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "Fetch
|
|
3
|
+
version = "0.5.0"
|
|
4
|
+
description = "Fetch or record a dataset's public files with provenance, and release it without files whose terms forbid it"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
7
7
|
authors = [{ name = "Simon van Lierde", email = "code@duinlab.nl" }]
|
|
8
8
|
license = "MIT"
|
|
9
9
|
license-files = ["LICENSE"]
|
|
10
|
+
# citesync compares keywords with CITATION.cff.
|
|
10
11
|
keywords = ["provenance", "data pipeline", "reproducibility", "open data", "research software", "FAIR"]
|
|
11
12
|
classifiers = [
|
|
12
13
|
"Development Status :: 3 - Alpha",
|
|
13
14
|
"Intended Audience :: Science/Research",
|
|
14
|
-
"Operating System ::
|
|
15
|
+
"Operating System :: OS Independent",
|
|
15
16
|
"Programming Language :: Python :: 3",
|
|
16
17
|
"Programming Language :: Python :: 3.12",
|
|
17
18
|
"Programming Language :: Python :: 3.13",
|
|
@@ -22,34 +23,44 @@ classifiers = [
|
|
|
22
23
|
]
|
|
23
24
|
dependencies = []
|
|
24
25
|
|
|
25
|
-
# `sourceledger
|
|
26
|
-
# with its own readers calls `sourceledger.
|
|
26
|
+
# The `sourceledger` command, reading each source by its format. A project
|
|
27
|
+
# with its own readers calls `sourceledger.entry` from its own entry point instead.
|
|
27
28
|
[project.scripts]
|
|
28
|
-
sourceledger = "sourceledger.cli:
|
|
29
|
+
sourceledger = "sourceledger.cli:entry"
|
|
29
30
|
|
|
30
31
|
[project.urls]
|
|
31
32
|
Homepage = "https://github.com/simonvanlierde/sourceledger"
|
|
32
33
|
Issues = "https://github.com/simonvanlierde/sourceledger/issues"
|
|
34
|
+
Changelog = "https://github.com/simonvanlierde/sourceledger/blob/main/CHANGELOG.md"
|
|
33
35
|
|
|
34
36
|
[project.optional-dependencies]
|
|
35
37
|
xlsx = [
|
|
36
38
|
"openpyxl>=3.1",
|
|
37
39
|
]
|
|
40
|
+
parquet = [
|
|
41
|
+
"pyarrow>=23",
|
|
42
|
+
]
|
|
43
|
+
release = [
|
|
44
|
+
"mlcroissant>=1.1.1",
|
|
45
|
+
"roc-validator>=0.13.1",
|
|
46
|
+
]
|
|
38
47
|
|
|
39
48
|
[dependency-groups]
|
|
40
49
|
dev = [
|
|
41
50
|
"frictionless>=5.20",
|
|
42
|
-
"hypothesis>=6.170.
|
|
51
|
+
"hypothesis>=6.170.13",
|
|
43
52
|
"jsonschema>=4.26",
|
|
53
|
+
"mlcroissant>=1.1.1",
|
|
54
|
+
"mutmut>=3.8.1",
|
|
44
55
|
"openpyxl>=3.1",
|
|
45
|
-
"
|
|
56
|
+
"polars>=1.35",
|
|
57
|
+
"pyarrow>=23",
|
|
58
|
+
"pytest>=9.2.0",
|
|
46
59
|
"pytest-codspeed>=5.0.3",
|
|
47
60
|
"pytest-cov>=7.1.0",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
mutation = [
|
|
52
|
-
"mutmut>=3.8.0",
|
|
61
|
+
"roc-validator>=0.13.1",
|
|
62
|
+
"ruff>=0.17.3",
|
|
63
|
+
"ty>=0.0.93",
|
|
53
64
|
]
|
|
54
65
|
|
|
55
66
|
[build-system]
|
|
@@ -76,7 +87,9 @@ line-length = 120
|
|
|
76
87
|
docstring-code-format = true
|
|
77
88
|
|
|
78
89
|
[tool.ruff.lint]
|
|
79
|
-
|
|
90
|
+
preview = true
|
|
91
|
+
explicit-preview-rules = true
|
|
92
|
+
select = ["ALL", "PLW1514"] # unspecified-encoding is preview-only, so ALL skips it
|
|
80
93
|
ignore = [
|
|
81
94
|
"ANN204", # missing-return-type-special-method
|
|
82
95
|
"COM812", # trailing-comma-missing: conflicts with the formatter
|
|
@@ -91,6 +104,8 @@ ignore = [
|
|
|
91
104
|
# annotations, or package __init__.py.
|
|
92
105
|
[tool.ruff.lint.per-file-ignores]
|
|
93
106
|
"**/tests/**" = ["S101", "D1", "INP001", "PLR2004", "ANN201"]
|
|
107
|
+
# A documentation script: it prints, is not a package, and carries no annotations.
|
|
108
|
+
"docs/examples/**" = ["T201", "INP001", "D1", "ANN", "E501", "FBT003", "B905"]
|
|
94
109
|
# The command line reports to the terminal.
|
|
95
110
|
"src/sourceledger/cli.py" = ["T201"]
|
|
96
111
|
|
|
@@ -101,11 +116,21 @@ convention = "google"
|
|
|
101
116
|
allow-magic-value-types = ["int"]
|
|
102
117
|
max-args = 10
|
|
103
118
|
|
|
119
|
+
# The example script imports pyarrow, which the project environment need not hold.
|
|
120
|
+
[tool.ty.src]
|
|
121
|
+
exclude = ["docs/examples"]
|
|
122
|
+
|
|
123
|
+
# A rule set to "warn" reports without failing: ty otherwise exits 1 on warnings too.
|
|
124
|
+
[tool.ty.terminal]
|
|
125
|
+
error-on-warning = false
|
|
126
|
+
|
|
104
127
|
[tool.pytest.ini_options]
|
|
105
128
|
# `live` tests reach real services; `pytest -m live` runs only them (the last -m wins).
|
|
106
129
|
addopts = ["-ra", "--strict-config", "--strict-markers", "--import-mode=importlib", "-m", "not live"]
|
|
107
130
|
markers = ["live: calls a real external service; deselected unless run with -m live"]
|
|
108
131
|
testpaths = ["tests"]
|
|
132
|
+
# The test modules import their shared helpers from tests/support.py.
|
|
133
|
+
pythonpath = ["tests"]
|
|
109
134
|
|
|
110
135
|
# Coverage is opt-in via `pytest --cov` (`just py-cov`), not addopts, because it
|
|
111
136
|
# slows every plain test run. CI's run fails under the fail_under below.
|
|
@@ -122,7 +147,9 @@ exclude_also = ["if TYPE_CHECKING:", "raise NotImplementedError"]
|
|
|
122
147
|
|
|
123
148
|
# `just py-mutation` runs it. The docs tests read the README and docs/ from the copy.
|
|
124
149
|
[tool.mutmut]
|
|
150
|
+
# Polars starts worker threads; forking after tests used them can deadlock a mutant.
|
|
151
|
+
process_isolation = "forkserver"
|
|
125
152
|
source_paths = ["src"]
|
|
126
|
-
also_copy = ["README.md", "docs"]
|
|
153
|
+
also_copy = ["README.md", "docs", ".github/scripts", "src/sourceledger/sources.schema.json"]
|
|
127
154
|
# Log calls only change diagnostics; their mutants would all survive.
|
|
128
155
|
do_not_mutate_patterns = ['^\s*_logger\.\w+\(']
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Fetch or record a dataset's public files with provenance, and release it without files whose terms forbid it.
|
|
2
|
+
|
|
3
|
+
Every file keeps a provenance record, and every output row names the bytes it came from.
|
|
4
|
+
|
|
5
|
+
The names below are the public API. Until 1.0, a breaking change to them, to the keys of
|
|
6
|
+
sources.toml, or to the fetch-record format comes only in a minor version, listed in the
|
|
7
|
+
changelog. The submodules, such as `sourceledger.ledger`, may change in any release.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from sourceledger.builder import Parser, build, parse_csv, parse_json, parse_source, parse_xlsx, read_output
|
|
11
|
+
from sourceledger.cli import entry, main
|
|
12
|
+
from sourceledger.fetcher import USER_AGENT, fetch
|
|
13
|
+
from sourceledger.ledger import FetchError, FetchRecord, record, revisions, verified
|
|
14
|
+
from sourceledger.manifest import Source, load_manifest, load_output_format, load_package_name, load_release_formats
|
|
15
|
+
from sourceledger.releaser import (
|
|
16
|
+
ReleaseError,
|
|
17
|
+
RestrictedSourceError,
|
|
18
|
+
ValidatorCouldNotRun,
|
|
19
|
+
ValidatorFailed,
|
|
20
|
+
ValidatorMissing,
|
|
21
|
+
check_release,
|
|
22
|
+
release,
|
|
23
|
+
)
|
|
24
|
+
from sourceledger.report import attribution, report, status, validate, verify
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"USER_AGENT",
|
|
28
|
+
"FetchError",
|
|
29
|
+
"FetchRecord",
|
|
30
|
+
"Parser",
|
|
31
|
+
"ReleaseError",
|
|
32
|
+
"RestrictedSourceError",
|
|
33
|
+
"Source",
|
|
34
|
+
"ValidatorCouldNotRun",
|
|
35
|
+
"ValidatorFailed",
|
|
36
|
+
"ValidatorMissing",
|
|
37
|
+
"attribution",
|
|
38
|
+
"build",
|
|
39
|
+
"check_release",
|
|
40
|
+
"entry",
|
|
41
|
+
"fetch",
|
|
42
|
+
"load_manifest",
|
|
43
|
+
"load_output_format",
|
|
44
|
+
"load_package_name",
|
|
45
|
+
"load_release_formats",
|
|
46
|
+
"main",
|
|
47
|
+
"parse_csv",
|
|
48
|
+
"parse_json",
|
|
49
|
+
"parse_source",
|
|
50
|
+
"parse_xlsx",
|
|
51
|
+
"read_output",
|
|
52
|
+
"record",
|
|
53
|
+
"release",
|
|
54
|
+
"report",
|
|
55
|
+
"revisions",
|
|
56
|
+
"status",
|
|
57
|
+
"validate",
|
|
58
|
+
"verified",
|
|
59
|
+
"verify",
|
|
60
|
+
]
|