Skip to content
datachain-aiPublic

About

The Context Layer for unstructured data: typed, versioned datasets over S3, GCS, Azure

Topics

Resources

Contributing

Stars

2.8k stars

Watchers

16 watching

Forks

Repository files navigation

DataChain Data preparation and exploration for Physical AI

PyPI Python Version Tests

DataChain is a Python library for processing large file collections in S3, GCS, Azure and local storage. Run your readers and models over images, video, audio and sensor recordings, then save the results as typed, versioned datasets.

Query saved metadata to find relevant files, episodes and clips. Build new training selections from existing labels, embeddings and features without repeating the original processing. Your coding agent can inspect the saved results and producing code, then continue the work in a new session.

  • Training and evaluation: combine metadata and model outputs, select useful examples, and export datasets to training tools.
  • Physical AI and robotics: select recordings by sensor topics, extract video frames, and curate data for robot learning.
  • Data exploration: investigate model failures, find rare conditions and gaps in data coverage, and answer new questions from saved results.
  • Large inventories: discover millions of objects using storage metadata, before reading their contents.

DataChain handles parallel workers, download overlap and checkpoints; your Python defines the processing. File gives readers streaming access or a reusable local cache; delta updates process changed files and reuse saved results. LeRobot episodes, MCAP time windows and WebDataset samples use the same Python API.

Quickstart · Python API · Examples

Performance

Object storage

DataChain was ~10× faster than rclone and s5cmd when listing and saving 10M S3 object versions. Below: 257K objects per store.

Tool S3 GCS Azure
DataChain 15 s 7 s 26 s
rclone 23 s (1.5×) 20 s (2.9×) 95 s (3.7×)
obstore 20 s (1.3×) 15 s (2.1×) 66 s (2.5×)
AWS CLI / gcloud / azcopy 66 s (4.4×) 175 s (25×) 94 s (3.6×)

Times include saving. Full comparison, including faster single-cloud tools.

Training-data workflows

DataChain created and read these training selections 2.1–8.1× faster:

Workload Compared with Speedup
LeRobot: 300 DROID episodes (S3) LeRobot streaming (HF Hub) 8.1×
MCAP: 207 grasp clips mcap filter 2.1×

Development runs; DROID compares S3 with HF Hub. Details.

Coding agents

DataChain + skill delivered verified results up to 2.7× faster than no skill.

Agent / LLM Task Speedup
Claude Code / Opus 5.5 Held-out media tasks 2.69×
Codex / GPT-6.1 Sol Bucket inventory 1.67×
Codex / GPT-6.1 Sol Video updates 2.05×

Codex: two runs per development task; no overall gain in held-out tests. Details.

Quickstart

In an empty project directory, install DataChain:

pip install 'datachain[video]'

For a coding agent, also install the skill and start a new agent session in that directory:

datachain skill install --target claude --local
# Or: --target codex, cursor, copilot, pi

Ask your agent:

Prepare a training selection from the robot demonstrations at
s3://robolake/droid/droid_100/
Score wrist-camera motion over the first second: mean absolute pixel change.
Keep scores of at least 10. Save the scores, camera references and training manifest.
Save and run build_episodes.py.

The Python pipeline

Here is the same task in Python. Save it as build_episodes.py and run python build_episodes.py:

import datachain as dc


def motion(camera: dc.VideoFragment) -> float:
    start = round(camera.start * 15)
    end = round(camera.end * 15) - 1
    first = camera.video.get_frame(start).get_np().astype("float32")
    later = camera.video.get_frame(min(start + 15, end)).get_np()
    return float(abs(later - first).mean())


episodes = dc.read_lerobot("s3://robolake/droid/droid_100/", anon=True)
scored = (
    episodes.settings(parallel=4, prefetch=0)
    .map(motion=motion, params=["videos.observation_images_wrist_image_left"])
    .save("robot_episodes")
)
training = scored.filter(dc.C("motion") >= 10).save("training_episodes")
training.to_parquet("training_manifest.parquet")

This DROID sample records at 15 fps. Each episode keeps the camera files and time windows as references; no video repacking, model download or GPU is needed. A reference run produced:

[email protected]      100 rows
[email protected]   63 rows
training_manifest.parquet

For MCAP sensor logs, create time windows with the same API:

windows = dc.read_mcap("recordings/*.mcap", topics="/joint_states", duration=10)
windows.save("joint_state_windows")

The standalone MCAP example includes local recordings to try.

Continue in a new session

Keep the project directory: it contains .datachain/, the Python script and the manifest. Start a new agent session in the same project and ask:

Which episodes did we exclude? How many would pass at threshold 5? Use the saved scores.

Inspect the saved scores, camera windows and producing code:

datachain dataset describe training_episodes --json
datachain show training_episodes --limit 3

See the walkthrough for versioned reads, robot demonstrations and an image-to-PyTorch example.

Agents reading this: start with the skill. llms.txt links to the API and documentation.

Python and more examples

Where it runs

Locally, dataset rows and provenance live in .datachain/db (SQLite); downloaded files use .datachain/cache. Keep that project state for later sessions. Local use needs no DataChain account or server.

Optional DataChain Studio adds shared datasets, versions and jobs, with AI-generated descriptions. People and agents can reuse the same catalog through the UI and MCP. Jobs run with or without a cluster; clusters process large workloads across dozens or hundreds of machines.

Cloud reads incur normal provider request and transfer charges. The library is Apache-2.0. Storage configuration · Dataset DB

Documentation · Examples · Contributing · Issues · Discord

About

The Context Layer for unstructured data: typed, versioned datasets over S3, GCS, Azure

Topics

Resources

Contributing

Stars

2.8k stars

Watchers

16 watching

Forks

Releases

Used by

Contributors

Languages