Dataset DB 默认存放在本地 .datachain/db 的 SQLite 中,需注意该目录的持久化;示例读取 S3 需加 anon=True 匿名访问;Agent 技能需额外执行 datachain skill install --target claude 等命令安装
datachain
datachain-aiApache-2.0活跃维护把 S3、GCS、Azure 上的非结构化数据整理成带类型、可版本化的数据集,方便 AI Agent 和机器学习流程直接读取和复用。
The Context Layer for unstructured data: typed, versioned datasets over S3, GCS, Azure
pip install datachainREADME 未说明显存或 GPU 要求;示例使用 open_clip + torch 做嵌入,但未给出硬件规格。
把 S3/GCS/Azure 上的文件变成带类型、可版本化的数据集,用仓库级速度查询
把 S3、GCS、Azure 上的非结构化数据整理成带类型、可版本化的数据集,方便 AI Agent 和机器学习流程直接读取和复用。
核心能力
- 用 Pydantic 定义 schema,UDF 返回类型自动成为可查询列
- 每次 save 注册带版本与血缘的数据集,记录在本地 SQLite
- delta=True 增量更新,只处理新增或变更文件
- 向量以 list[float] 存于 Dataset DB,可与元数据过滤联合检索
- 按 batch 提交检查点,崩溃后从上次未提交批次续跑
容易踩的坑
- 0.62.4最新正式版2026-11-09 · 2026-11-09 03:08 UTC
What's Changed
- fix: size automatic workers by the container CPU quota by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2135
- fix: store NaN in pandas text columns as None by @shcheklein in https://github.com/datachain-ai/datachain/pull/2164
- fix: keep the column type for all-missing pandas columns by @shcheklein in https://github.com/datachain-ai/datachain/pull/2161
- fix: read Parquet map columns as dicts by @shcheklein in https://github.com/datachain-ai/datachain/pull/2162
- fix: read_values with column= and a single signal by @shcheklein in https://github.com/datachain-ai/datachain/pull/2163
- fix(file): normalize explicit text write modes by @bosprimigenious in https://github.com/datachain-ai/datachain/pull/2166
- refactor!: drop the name argument from read_values and read_pandas by @shcheklein in https://github.com/datachain-ai/datachain/pull/2171
- perf(tabular): read Parquet/CSV schemas concurrently by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2173
- refactor!: drop the column argument from read_storage by @shcheklein in https://github.com/datachain-ai/datachain/pull/2178
- fix(func): treat strings as literals in Func comparisons by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2179
- refactor: drop the column argument from listing helpers by @shcheklein in https://github.com/datachain-ai/datachain/pull/2188
- fix(tabular): read CSV and Parquet files that have a source column by @shcheklein in https://github.com/datachain-ai/datachain/pull/2187
- fix(tabular): read Parquet exported with only a source signal by @shcheklein in https://github.com/datachain-ai/datachain/pull/2189
- fix: readers rename their own signal, not the data column by @shcheklein in https://github.com/datachain-ai/datachain/pull/2190
- feat: read LeRobot v3 datasets by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2184
- fix(tar): reject compressed tar archives by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2186
- Fast UDF: stats response once in 3 sec & PYTHONPATH for UDFs by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2080
- perf: read media metadata without filling the file cache by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2118
- feat: add read_webdataset by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2182
- Delta: keep results in sync with the current source by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2115
- fix(file): give a buffered stream from File.open() without the cache by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2180
- perf(video): read with 1 MiB blocks when decoding from mid-file by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2181
New Contributors
- @bosprimigenious made their first contribution in https://github.com/datachain-ai/datachain/pull/2166
Full Changelog: https://github.com/datachain-ai/datachain/compare/0.62.3...0.62.4
- 0.62.32026-11-04 · 2026-11-04 01:46 UTC
查看更新说明
What's Changed
- Require datasets 4.0 or newer by @dreadatour in https://github.com/datachain-ai/datachain/pull/2129
- fix: discover DataChain state within Git project boundaries by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2138
- fix: keep telemetry failures from overriding CLI and API results by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2139
- fix: isolate usearch extension discovery from native model libraries by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2140
- perf: link completed downloads into the local cache by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2141
- feat: run model inference on real batches with batch_map by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2117
- fix: accept pandas timestamps on SQLite and in read_pandas by @shcheklein in https://github.com/datachain-ai/datachain/pull/2157
Full Changelog: https://github.com/datachain-ai/datachain/compare/0.62.2...0.62.3
- 0.62.22026-10-31 · 2026-10-31 17:54 UTC
查看更新说明
What's Changed
- examples: load the LED summarizer explicitly for transformers 5.22 by @shcheklein in https://github.com/datachain-ai/datachain/pull/2130
- fix(parquet): read only the picked columns with ParquetFileFormat by @shcheklein in https://github.com/datachain-ai/datachain/pull/2123
- perf(tabular): prefetch small files in partial reads by @shcheklein in https://github.com/datachain-ai/datachain/pull/2121
- Union types by @dmpetrov in https://github.com/datachain-ai/datachain/pull/1824
- union and optional docs by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2043
- ci: run tests on free runners and split them across shards by @shcheklein in https://github.com/datachain-ai/datachain/pull/2133
Full Changelog: https://github.com/datachain-ai/datachain/compare/0.62.1...0.62.2
- 0.62.12026-10-29 · 2026-10-29 13:00 UTC
查看更新说明
What's Changed
- Tests: the stuck-child test no longer times the wall clock by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2090
- fix(client): probe GCS public bucket with single request by @PranjalGoyal06 in https://github.com/datachain-ai/datachain/pull/2089
- Fix "ambiguous column" after merge without an extra SELECT by @shcheklein in https://github.com/datachain-ai/datachain/pull/2084
- fix(tabular): pick columns by name, fail when output doesn't fit by @shcheklein in https://github.com/datachain-ai/datachain/pull/2034
- test: stop using pandas options deprecated in 3.1 by @shcheklein in https://github.com/datachain-ai/datachain/pull/2093
- ci: cache FFmpeg packages so a slow Ubuntu mirror doesn't stall jobs by @shcheklein in https://github.com/datachain-ai/datachain/pull/2098
- fix(hf): read a dataset with a single column by @shcheklein in https://github.com/datachain-ai/datachain/pull/2096
- fix(hf): convert the items of Hugging Face list features by @shcheklein in https://github.com/datachain-ai/datachain/pull/2094
- fix(arrow): decode Hugging Face features of the columns read only by @shcheklein in https://github.com/datachain-ai/datachain/pull/2092
- dc.list_storage(): list a storage without saving it by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2051
- Fix crashes for wildcard directory paths and lost file locations by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2103
- [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci[bot] in https://github.com/datachain-ai/datachain/pull/2109
- Listing: keys with double slashes by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2037
- fix: keep pytest compatible with CI plugins by @shcheklein in https://github.com/datachain-ai/datachain/pull/2112
- fix: cap default TAR member read-ahead by @edsonsims in https://github.com/datachain-ai/datachain/pull/2091
- perf(parquet): fetch only the columns read from remote files by @shcheklein in https://github.com/datachain-ai/datachain/pull/2095
- fix: align read_values rows with explicit output order by @AryanRG in https://github.com/datachain-ai/datachain/pull/2111
- Fix glob reads when an object shares a directory name by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2107
- Ignore torch's MPS warning on macOS CI runners by @dreadatour in https://github.com/datachain-ai/datachain/pull/2124
- Share listing snapshot preparation with Catalog by @dmpetrov in https://github.com/datachain-ai/datachain/pull/2104
- Make the changed-local-file parquet test independent of mtime resolution by @dreadatour in https://github.com/datachain-ai/datachain/pull/2125
- fix(sqlite): read insert_into ids into a compact array instead of fetchall by @pujitha24 in https://github.com/datachain-ai/datachain/pull/2072
- open_object: block_size=0 replaces the read_ahead flag by @shcheklein in https://github.com/datachain-ai/datachain/pull/2126
- Install the datachain checkout into the Studio worker venv by @dreadatour in https://github.com/datachain-ai/datachain/pull/2127
- fix(http): read TAR members from uncached HTTP archives by @chivector in https://github.com/datachain-ai/datachain/pull/2100
- fix(deps): raise litellm cap, bump mkdocs-material for CVEs by @yathomasi in https://github.com/datachain-ai/datachain/pull/2120
- Skip the etag check for pinned versions on version-aware clients by @dreadatour in https://github.com/datachain-ai/datachain/pull/2106
- Refresh listings when an object is deleted or changed in place by @dreadatour in https://github.com/datachain-ai/datachain/pull/2108
New Contributors
- @PranjalGoyal06 made their first contribution in https://github.com/datachain-ai/datachain/pull/2089
- @edsonsims made their first contribution in https://github.com/datachain-ai/datachain/pull/2091
- @AryanRG made their first contribution in https://github.com/datachain-ai/datachain/pull/2111
- @pujitha24 made their first contribution in https
- 0.62.02026-10-21 · 2026-10-21 17:53 UTC
查看更新说明
Speed up reading buckets - #2027
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
DataChain: The Context Layer for Unstructured Data
A Python library that turns files in S3, GCS, and Azure into versioned, typed datasets, queryable at warehouse speed.
- Compute Engine: parallel Python over files, distributed on Studio. Async I/O, checkpoint recovery, incremental updates.
- Dataset DB: Pydantic schemas, versioning, file pointers, automatic lineage. Sub-second filter, join, and group_by over millions of typed records locally, hundreds of millions on Studio. Vector search over the same rows, no separate store.
Optional, for agent workflows:
- Knowledge Base: markdown summaries derived from the Dataset DB and enriched by LLM. Readable by humans and LLMs.
- Agent Harness: a skill that plugs all three into Claude Code, Cursor, Codex, GitHub Copilot, and Pi, so they understand your data. On Studio, agents reach the same datasets over MCP.
Bytes never leave your storage. Every run deposits a typed dataset the next pipeline (or agent) reads instead of recomputing.
1. Install
pip install datachain
To add the agent skill (Knowledge Base + code generation):
datachain skill install --target claude # also: cursor, codex, copilot, pi
Works with S3, GCS, Azure, and local filesystems.
2. Quickstart: agent-driven pipeline
Task: find dogs in S3 similar to a reference image, filtered by breed, mask availability, and image dimensions.
Grab a reference image and run Claude Code (or other agent):
datachain cp --anon s3://dc-readme/fiona.jpg .
claude
Prompt:
Find dogs in s3://dc-readme/oxford-pets-micro/ similar to ./fiona.jpg:
- Pull breed metadata and mask files from annotations/
- Exclude images without mask
- Exclude Cocker Spaniels
- Only include images wider than 400px
Result:
┌──────┬───────────────────────────────────┬────────────────────────────┬──────────┐
│ Rank │ Image │ Breed │ Distance │
├──────┼───────────────────────────────────┼────────────────────────────┼──────────┤
│ 1 │ shiba_inu_52.jpg │ shiba_inu │ 0.244 │
├──────┼───────────────────────────────────┼────────────────────────────┼──────────┤
│ 2 │ shiba_inu_53.jpg │ shiba_inu │ 0.323 │
├──────┼───────────────────────────────────┼────────────────────────────┼──────────┤
│ 3 │ great_pyrenees_17.jpg │ great_pyrenees │ 0.325 │
└──────┴───────────────────────────────────┴────────────────────────────┴──────────┘
Fiona's closest matches are shiba inus (both top spots), which makes sense given her
tan coloring and pointed ears.
The agent decomposed the task into steps - embeddings, breed metadata, mask join, quality filter - and saved each as a named, versioned dataset. Next time you ask a related question, it starts from what's already built.
The datasets are registered in a Knowledge Base optimized for both agents and humans:
dc-knowledge
├── buckets
│ └── s3
│ └── dc_readme.md
├── datasets
│ ├── oxford_micro_dog_breeds.md
│ ├── oxford_micro_dog_embeddings.md
│ └── similar_to_fiona.md
└── index.md
Browse it as markdown files, navigate with wikilinks, or open in Obsidian:

3. Data Harness
Code harnesses (Claude Code, Cursor, Codex, GitHub Copilot, Pi) give agents repo context, dedicated tools, and memory across sessions. DataChain adds the same for data: typed datasets the agent reads, chain operations the agent calls (read_storage, map, save), a Dataset DB where its results persist.
A dataset is the unit of work - a named, versioned result of a pipeline step like [email protected]. Every .save() registers one.
For the data-flow architecture (Compute Engine, Dataset DB, Knowledge Base) and how the components connect, see Architecture.
4. Core concepts
4.1. Dataset
A dataset is a versioned data reasoning step - what was computed, from what input, producing what schema. DataChain indexes your storage into one: no data copied, just typed metadata and file pointers. Re-runs only process new or changed files.
Create a dataset manually create_dataset.py:
from PIL import Image
import io
from pydantic import BaseModel
import datachain as dc
class ImageInfo(BaseModel):
width: int
height: int
def get_info(file: dc.File) -> ImageInfo:
img = Image.open(io.BytesIO(file.read()))
return ImageInfo(width=img.width, height=img.height)
ds = (
dc.read_storage(
"s3://dc-readme/oxford-pets-micro/images/**/*.jpg",
anon=True,
update=True,
delta=True, # re-runs skip unchanged files
)
.settings(prefetch=64)
.map(info=get_info)
.save("pets_images")
)
ds.show(5)
[email protected] is now the shared reference to this data - schema, version, lineage, and metadata.
Every .save() registers the dataset in the Dataset DB, DataChain's persistent store for schemas, versions, lineage, and processing state, kept locally in SQLite DB .datachain/db. Pipelines reference datasets by name, not paths. When the code or input data changes, the next run bumps dataset version.
This is what makes a dataset a management unit: owned, versioned, and queryable by everyone on the team.
4.2. Schemas and types
DataChain uses Pydantic to define the shape of every column. The return type of your UDF becomes the dataset schema - each field a queryable column in the Dataset DB.
show() in the previous script renders nested fields as dotted columns:
file file info info
path size width height
0 oxford-pets-micro/images/Abyssinian_141.jpg 111270 461 500
1 oxford-pets-micro/images/Abyssinian_157.jpg 139948 500 375
2 oxford-pets-micro/images/Abyssinian_175.jpg 31265 600 234
3 oxford-pets-micro/images/Abyssinian_220.jpg 10687 300 225
4 oxford-pets-micro/images/Abyssinian_3.jpg 61533 600 869
[Limited by 5 rows]
print(ds.schema) renders its schema:
file: File@v1
source: str
path: str
size: int
version: str
etag: str
is_latest: bool
last_modified: datetime
location: Union[dict, list[dict], NoneType]
info: ImageInfo
width: int
height: int
Models can be arbitrarily nested - a BBox inside an Annotation, a List[Citation] inside an LLM Response - every leaf field stays queryable the same way. The schema lives in the Dataset DB and is enforced at dataset creation time.
The Dataset DB handles datasets of any size - 100 millions of files, hundreds of metadata rows - without loading anything into memory. Pandas is limited by RAM; DataChain is not. Export to pandas when you need it, on a filtered subset:
import datachain as dc
df = dc.read_dataset("pets_images").filter(dc.C("info.width") > 500).to_pandas()
print(df)
4.3. Fast queries
Filters, aggregations, and joins run as vectorized operations directly against the Dataset DB - metadata never leaves your machine, no files downloaded.
import datachain as dc
cnt = (
dc.read_dataset("pets_images")
.filter(
(dc.C("info.width") > 400)
& ~dc.C("file.path").ilike("%cocker_spaniel%") # case-insensitive
)
.count()
)
print(f"Large images with Cocker Spaniel: {cnt}")
Milliseconds, even at 100M-file scale.
Large images with Cocker Spaniel: 6
5. Resilient Pipelines
When computation is expensive, bugs and new data are both inevitable. DataChain tracks processing state in the Dataset DB - so crashes and new data are handled automatically, without changing how you write pipelines.
5.1. Data checkpoints
Save to embed.py:
import open_clip, torch, io
from PIL import Image
import datachain as dc
model, _, preprocess = open_clip.create_model_and_transforms(
"ViT-B-32", "laion2b_s34b_b79k"
)
model.eval()
counter = 0
def encode(file: dc.File, model, preprocess) -> list[float]:
global counter
counter += 1
if counter > 236: # ← bug: remove these two lines
raise Exception("some bug") # ←
img = Image.open(io.BytesIO(file.read())).convert("RGB")
with torch.no_grad():
return model.encode_image(preprocess(img).unsqueeze(0))[0].tolist()
(
dc.read_dataset("pets_images")
.settings(batch_size=100)
.setup(model=lambda: model, preprocess=lambda: preprocess)
.map(emb=encode)
.save("pets_embeddings")
)
It fails due to a bug in the code:
Exception: some bug
Remove the two marked lines and re-run - DataChain resumes from image 201 (two 100 size batches are completed), the start of the last uncommitted batch:
$ python embed.py
UDF 'encode': Continuing from checkpoint
5.2. Similarity search
The vectors live in the Dataset DB alongside all the metadata - list[float] type in pydentic schemas. Querying them is instant - no files re-read and can be combined with not vector filters like info.width:
Prepare data:
datachain cp s3://dc-readme/fiona.jpg .
similar.py:
import open_clip, torch, io
from PIL import Image
import datachain as dc
model, _, preprocess = open_clip.create_model_and_transforms(
"ViT-B-32", "laion2b_s34b_b79k"
)
model.eval()
ref_emb = model.encode_image(preprocess(Image.open("fiona.jpg")).unsqueeze(0))[
0
].tolist()
(
dc.read_dataset("pets_embeddings")
.filter(dc.C("info.width") > 500) # from pets_images - no re-read
.mutate(dist=dc.func.cosine_distance(dc.C("emb"), ref_emb))
.order_by("dist")
.limit(3)
.show()
)
Under a second - everything runs against the Dataset DB.
5.3. Incremental updates
The bucket in this walkthrough is static, so there's nothing new to process. In production, rerun the same scripts when files are added, changed, or deleted. With delta=True, new and changed files are processed, results for deleted files are removed, and results for unchanged files are reused:
$ python create_dataset.py # 500 new images arrived
Skipping 10,000 unchanged · indexing 500 new
Saved [email protected] (+500 records)
# Next day:
$ python create_dataset.py
Skipping 10,000 unchanged · processing 500 new
Saved [email protected] (+500 records)
6. Knowledge Base
DataChain maintains two layers. The Dataset DB is the ground truth: schemas, processing state, lineage, the vectors themselves. The Knowledge Base is derived from it: structured markdown for humans and agents to read. Because it's derived, it describes what actually ran rather than what someone wrote down. Rebuild it after a pass to bring it current. The Knowledge Base is stored in dc-knowledge/.
Ask the agent to build it (from Claude Code, Cursor, Codex, GitHub Copilot, or Pi):
claude
Prompt:
Build a Knowledge Base for my current datasets
The skill generates dc-knowledge/ directory from the Dataset DB - one file per dataset and bucket:
7. AI-Generated Pipelines
The skill gives the agent data awareness: it reads dc-knowledge/ to understand what datasets exist, their schemas, which fields can be joined - and the meaning of columns inferred from the code that produced them.
See section 2. Quickstart: agent-driven pipeline above. All the steps that were manually created could be just generated.
8. Team and cloud: Studio
Data context built locally stays local. DataChain Studio makes it shared.
datachain auth login
datachain job run --workers 20 --cluster gpu-pool caption.py
# ✓ Job submitted → studio.datachain.ai/jobs/1042
# Resuming from checkpoint (4,218 already done)...
# Saved [email protected] (3,182 processed)
Studio adds: shared dataset registry, distributed compute across attached clusters, an MCP endpoint for agents, access control, UI for video/DICOM/NIfTI/point clouds, lineage graphs, reproducible runs.
Bring Your Own Cloud - all data and compute stay in your infrastructure. AWS, GCP, Azure, on-prem Kubernetes.
9. Contributing
Contributions are very welcome. To learn more, see the Contributor Guide.
10. Community and Support
- Report an issue if you encounter any problems
- Docs