ds-crawler
Build stable, queryable metadata for datasets whose structure is encoded in file paths.
ds-crawler scans directories or ZIP archives, extracts IDs, hierarchy, and
properties with regular expressions, and writes a small set of versioned JSON
artifacts. It also aligns modalities, creates reproducible splits, copies or
extracts subsets, and indexes generated outputs.
- Directory and
.zipinputs use the same API. - Regex capture groups define IDs, hierarchy, and file properties.
- Include/exclude filters keep irrelevant files out of the index.
- Named splits and metadata scopes are first-class artifacts.
- Dataset semantics live in the shared
euler-dataset-contractformat.
Installation
pip install ds-crawler
Progress bars are optional:
pip install "ds-crawler[progress]"
Python 3.9 or newer is required.
Quick start
Given this dataset:
foggy_rgb/
├── .ds_crawler/
│ ├── dataset-head.json
│ └── ds-crawler.json
├── scene_01/
│ ├── 0001.png
│ └── 0002.png
└── scene_02/
└── 0001.png
describe its semantic identity in .ds_crawler/dataset-head.json:
{
"contract": {"kind": "dataset_head", "version": "1.0"},
"dataset": {"id": "foggy_rgb", "name": "Foggy RGB"},
"modality": {
"key": "rgb",
"meta": {"range": [0, 255]}
},
"addons": {
"euler_train": {
"version": "1.0",
"used_as": "input",
"slot": "dehaze.input.rgb"
}
}
}
Then describe how paths become index entries in
.ds_crawler/ds-crawler.json:
{
"contract": {"kind": "ds_crawler_config", "version": "2.0"},
"head_file": "dataset-head.json",
"source": {"path": "."},
"indexing": {
"id": {
"regex": "^(?P<scene>[^/]+)/(?P<frame>\\d+)\\.png$",
"join_char": "+"
},
"hierarchy": {
"regex": "^(?P<scene>[^/]+)/",
"separator": ":"
},
"properties": {
"basename": {
"regex": "^(?P<frame>\\d+)\\.(?P<ext>png)$"
}
},
"files": {"extensions": [".png"]},
"constraints": {"flat_ids_unique": true}
}
}
Index and persist the dataset:
from ds_crawler import get_files, index_dataset_from_path
output = index_dataset_from_path("/data/foggy_rgb", save_index=True)
print(output["head"]["dataset"]["name"])
print(get_files(output))
The returned object is hydrated with the dataset head and indexing recipe for
convenience. The saved index.json stays minimal.
For a self-contained example that creates a temporary dataset, see
examples/basic_usage.py.
Artifact layout
For a physical root containing several logical modalities, prefer the scoped
layout. Each modality gets a complete, isolated artifact set and scopes.json
provides the discovery manifest:
foggy_rgb/
├── .ds_crawler/
│ ├── scopes.json
│ ├── rgb/
│ │ ├── dataset-head.json
│ │ ├── ds-crawler.json
│ │ ├── index.json
│ │ └── split_train.json
│ └── camera_extrinsics/
│ ├── dataset-head.json
│ ├── ds-crawler.json
│ └── index.json
└── ...
Pass metadata_scope="rgb" (or another safe modality name) to path-based APIs
to read and write .ds_crawler/rgb/. Scoped writes maintain scopes.json
automatically. When several writers share one root, give each a
path_prefix as well (e.g. DatasetWriter(root, ..., metadata_scope="rgb", path_prefix="rgb")): its files then go to rgb/... and the index paths say so,
so datasets with the same IDs and basenames do not overwrite each other.
For a root with just one logical dataset, the compact unscoped layout remains supported:
foggy_rgb/
├── .ds_crawler/
│ ├── dataset-head.json
│ ├── ds-crawler.json
│ ├── index.json
│ └── split_train.json
└── ...
The files in either artifact set are:
| File | Purpose |
|---|---|
dataset-head.json |
Dataset identity, modality metadata, and namespaced addons. |
ds-crawler.json |
Source and indexing recipe. |
index.json |
Materialized recursive file index. |
split_<name>.json |
A named, filtered index with provenance. |
See the configuration reference for every supported field, artifact shape, path filter, and hierarchy pattern.
Common workflows
Use the CLI
A CLI config can reference one or more datasets that already contain crawler metadata:
{
"datasets": [
{"path": "/data/foggy_rgb"},
{"path": "/data/foggy_depth"}
]
}
ds-crawler index datasets.json
index is optional for backwards compatibility, so ds-crawler datasets.json
is equivalent. Useful flags include:
| Flag | Effect |
|---|---|
--strict |
Abort on duplicate IDs. |
--sample N |
Keep every Nth matched file deterministically. |
--match-index PATH |
Keep only hierarchy-qualified IDs found in another index. |
--metadata-scope SCOPE |
Read and write a scoped artifact set. |
--workdir PATH |
Resolve relative dataset paths from a specific directory. |
--verbose |
Log each skipped file. |
Align modalities
from ds_crawler import align_datasets
aligned = align_datasets(
{"modality": "rgb", "source": "/data/foggy_rgb"},
{"modality": "depth", "source": "/data/foggy_depth"},
)
rgb_path = aligned["scene-scene_01+frame-0001"]["rgb"]["path"]
Alignment is by leaf ID. For modalities that apply at an ancestor hierarchy
level, preserve the hierarchy and join in the consumer instead; the runnable
augmented RGB example demonstrates that
layout.
Create reproducible splits
from ds_crawler import create_dataset_splits, load_dataset_split
create_dataset_splits(
"/data/foggy_rgb",
split_names=["train", "validation"],
ratios=[80, 20],
seed=42,
)
train = load_dataset_split("/data/foggy_rgb", "train")
Use create_aligned_dataset_splits for several modalities,
create_hierarchy_dataset_splits for hierarchy rules, or
create_mapped_dataset_splits for an explicit qualified-ID mapping.
copy_dataset_splits transfers an existing partition to a sibling dataset and
fails before writing if any target ID is missing.
Write generated data
from ds_crawler import DatasetWriter
head = {
"contract": {"kind": "dataset_head", "version": "1.0"},
"dataset": {"id": "predicted_rgb", "name": "Predicted RGB"},
"modality": {"key": "rgb", "meta": {"range": [0, 255]}},
}
writer = DatasetWriter("/data/predicted_rgb", head=head)
path = writer.get_path("/scene:scene_01/frame-0001", "0001.png")
path.write_bytes(encoded_image)
writer.save_index()
ZipDatasetWriter provides the same index-building behavior for a new ZIP
archive and accepts bytes or writable file-like objects.
Index existing files with IDs from elsewhere
When a dataset's IDs or hierarchy cannot be derived from its paths, for example when they come from the dataset's own metadata tables, build the index yourself and save it as a prebuilt index:
from ds_crawler import build_dataset_head, build_index_output, save_dataset_index
head = build_dataset_head(
dataset={"id": "demo_lidar", "name": "Demo lidar"},
modality={"key": "lidar_point_cloud"},
)
index = {"children": {"scene:a": {"files": [
{"path": "sweeps/lidar_100.bin", "id": "57",
"path_properties": {}, "basename_properties": {}},
]}}}
output = build_index_output(
head=head, index=index, generator={"name": "my-tool", "version": "1.0"}
)
save_dataset_index("/data/demo", output, metadata_scope="lidar")
The files must already exist below the dataset root; only metadata is
written. ds-crawler.json records source.prebuilt_index_file, so loading
reads the index back instead of crawling. save_dataset_index also persists
the output of index_dataset_from_files, keeping its regexes. That lets you
crawl one directory and write the index into another root holding the same
relative paths.
Migrate legacy metadata
Normal loading is intentionally strict about the current schema. Migrate older
output.json-based datasets explicitly:
ds-crawler migrate-metadata /data/legacy_dataset
ds-crawler migrate-metadata /data/archive.zip
ds-crawler migrate-metadata /data/datasets --scan-zips
Run ds-crawler migrate-metadata --help for archive scanning, inline split,
and metadata-scope options.
Python API
The main entry points are re-exported from ds_crawler:
| Area | Entry points |
|---|---|
| Build | build_dataset_head, build_crawler_config, build_dataset_artifacts_from_files, build_index_output |
| Index | index_dataset, index_dataset_from_files, index_dataset_from_path |
| Inspect | get_files, collect_qualified_ids, get_dataset_contract, get_dataset_properties |
| Split | create_dataset_splits, create_aligned_dataset_splits, create_hierarchy_dataset_splits, create_mapped_dataset_splits, load_dataset_split |
| Transform | align_datasets, copy_dataset, extract_datasets, split_dataset, split_datasets |
| Write | DatasetWriter, ZipDatasetWriter, save_dataset_index |
| Validate | validate_crawler_config, validate_dataset, validate_output |
All core path-based workflows support directories and ZIP archives. Scope-aware
operations accept metadata_scope; multi-source operations also expose
per-source scope arguments where needed.
Development
git clone https://github.com/d-rothen/ds-crawler.git
cd ds-crawler
uv sync --extra dev
uv run pytest
uv run ruff check .
uv build
Please read CONTRIBUTING.md before submitting a change. To report a vulnerability, follow SECURITY.md.
License
Licensed under the MIT License. Copyright © 2026 Daniel Rothenpieler rothenpielerdaniel@gmail.com.
See Phase 2 validated-publication for the opt-in captured spatial workflow (2.11.0, unreleased).
Metadata
Release files for ds-crawler 2.19.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ds_crawler-2.19.0.tar.gz | 100.4 kB | Without provenance | Details for ds_crawler-2.19.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ds_crawler-2.19.0-py3-none-any.whl | Python 3 | none | any | Details for ds_crawler-2.19.0-py3-none-any.whl |
Total release size: 186.1 kB
Release files / ds_crawler-2.19.0.tar.gz
| Download URL | ds_crawler-2.19.0.tar.gz |
|---|---|
| Size | 100.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c25042c37b93d1d8f238cc432724610b1a59fd60ef1edce901ef1b3ac6ee5fe9
|
|
BLAKE2b-256 checksum How to use checksums |
78235d48594dfd30d59fee9e1bc756371c310dd2e6b873a45b64ba17f7c93b12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ds_crawler-2.19.0-py3-none-any.whl
| Download URL | ds_crawler-2.19.0-py3-none-any.whl |
|---|---|
| Size | 85.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b228049df475a9272f40488c96c30fe5c0b40a73e3c2a7404b239db1ecc2d5b0
|
|
BLAKE2b-256 checksum How to use checksums |
ae06ff488f77fbcbc1c4c77885743f391504699304257a102e92f9c2a0e68638
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for ds-crawler 2.19.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.