Tiny Python SDK for the Drift dataset API
Project description
Drift
Drift is an open-source Python SDK for working with real-world driving data and training end-to-end driving models.
The goal is to make embodied driving research easier to start. Instead of spending days wiring up dataset parsers, route metadata, and segment downloads, you can install one package, load a dataset, and begin building a training pipeline from real driving data.
Today, Drift includes a complete real-world driving dataset with:
- 15.08 hours of human driving
- 933 synchronized driving segments
- 68 routes
- 74.9 GiB of synchronized camera, vehicle telemetry, and navigation data
Drift exposes datasets, routes, and segments as simple Python objects while hiding the storage details underneath. It is best understood as a clean access layer over driving data and artifacts, rather than a fully prepared ML dataset.
Quickstart
For a one-click start, open the example notebook in Google Colab:
It is a simple end-to-end quickstart for loading the dataset, downloading segments, training a driving policy, and exporting a model. The notebook is set up to work well on an NVIDIA A100.
Drift aims to do for end-to-end driving data what Hugging Face Datasets did for NLP datasets: provide a simple, reproducible interface that makes experimentation more accessible.
The intended SDK flow is:
- Load dataset metadata.
- List routes.
- Inspect route segment references.
- Resolve each segment.
- Download the specific files your pipeline needs.
Installation
pip install drift-sdk
import drift
API endpoint
The hosted API used by the examples below is:
https://drift-api-production-1d47.up.railway.app
You do not need to run the backend locally to try the examples.
Core objects
The SDK exposes three data objects plus one client:
drift.client.DriftClientdrift.dataset.Datasetdrift.route.Routedrift.segment.Segment
The top-level convenience helpers are:
drift.load(dataset_id, base_url=None) -> Datasetdrift.route(route_id, base_url=None) -> Routedrift.segment(segment_id, base_url=None) -> Segment
Client methods
DriftClient is the full method-level API:
from drift.client import DriftClient
client = DriftClient(base_url="https://drift-api-production-1d47.up.railway.app")
dataset = client.load_dataset("jordy-v0")
routes = client.list_routes("jordy-v0")
route = client.get_route(routes[0].route_id)
segment = client.get_segment(route.segments[0]["segment_id"])
client.close()
Available methods:
load_dataset(dataset_id)returns aDatasetlist_routes(dataset_id)returnslist[Route]get_route(route_id)returns aRouteget_segment(segment_id)returns aSegmentclose()closes the underlying HTTP client
Dataset methods
Use drift.load(...) or DriftClient.load_dataset(...) when you need dataset
summary metadata.
import drift
dataset = drift.load("jordy-v0")
print(dataset.id)
print(dataset.routes_count)
print(dataset.segments_count)
Dataset fields:
idroutes_countsegments_count
Route methods
Use drift.route(...) or DriftClient.get_route(...) when you need the segment
references for a route.
import drift
client = drift.client.DriftClient()
routes = client.list_routes("jordy-v0")
route = client.get_route(routes[0].route_id)
print(route.route_id)
print(route.num_segments)
print(route.dataset)
print(route.segments[:3])
client.close()
Route fields:
route_idnum_segmentscreated_atdatasetsegments
Each route.segments item is currently a small reference dictionary such as:
{"segment_id": "...", "segment_index": 0}
Segment methods
Use drift.segment(...) or DriftClient.get_segment(...) when you need the
downloadable files for one segment.
import drift
segment = drift.segment("<segment-id>")
print(segment.segment_id)
print(segment.route_id)
print(segment.segment_index)
print(segment.files)
print(segment.download_url)
Segment fields:
segment_idroute_idsegment_indexfilesdownload_url
segment.files is a dictionary of alias to presigned URL. Current aliases may
include:
qcameraqlogrlogecamerafcameranavigation
Downloading files
Segment.download(destination=None, chunk_size=8192) downloads the segment's
primary file. Today that is download_url if present, otherwise files["fcamera"].
import os
import drift
os.makedirs("downloads", exist_ok=True)
segment = drift.segment("<segment-id>")
path = segment.download("downloads/segment.bin")
print(path)
Important limitation:
Segment.download(...)downloads one file per call.- It does not download every file listed in
segment.files. - If your pipeline needs
navigation,qlog, or another alias specifically, fetch the URL fromsegment.filesand download it yourself.
End-to-end metadata workflow
This is the real SDK usage pattern that a training pipeline should start from.
from pathlib import Path
import drift
BASE_URL = "https://drift-api-production-1d47.up.railway.app"
DATASET_ID = "jordy-v0"
CACHE_DIR = Path("training-cache")
CACHE_DIR.mkdir(parents=True, exist_ok=True)
client = drift.client.DriftClient(base_url=BASE_URL)
dataset = client.load_dataset(DATASET_ID)
print(f"dataset={dataset.id} routes={dataset.routes_count} segments={dataset.segments_count}")
routes = client.list_routes(DATASET_ID)
segment_ids = [
segment_ref["segment_id"]
for route in routes
for segment_ref in route.segments
]
print(f"resolved {len(segment_ids)} segment references")
for segment_id in segment_ids[:8]:
segment = client.get_segment(segment_id)
target = CACHE_DIR / f"{segment.segment_id}.bin"
segment.download(str(target))
print(f"downloaded {target}")
client.close()
Training-pipeline pattern
The SDK does not expose download_dataset(...), and it does not materialize a
ready-made parquet or CSV training table. A trainer should explicitly:
- Query dataset and route metadata.
- Expand route segment references into segment IDs.
- Download the needed segment files.
- Parse those raw artifacts into model-ready tensors or tables.
This is a simplified version of the same control flow used by train_driving.py:
from pathlib import Path
import drift
BASE_URL = "https://drift-api-production-1d47.up.railway.app"
DATASET_ID = "jordy-v0"
CACHE_DIR = Path(".cache/drift-data")
CACHE_DIR.mkdir(parents=True, exist_ok=True)
client = drift.client.DriftClient(base_url=BASE_URL)
routes = client.list_routes(DATASET_ID)
segment_ids = []
for route in routes:
for segment_ref in route.segments:
segment_ids.append(segment_ref["segment_id"])
for segment_id in segment_ids[:32]:
segment = client.get_segment(segment_id)
if "navigation" in segment.files:
print("navigation url:", segment.files["navigation"])
target = CACHE_DIR / f"{segment.segment_id}.bin"
segment.download(str(target))
client.close()
If your trainer expects .parquet, .csv, .jsonl, or image tensors, you
still need a conversion step after download.
PyTorch example
drift.torch.DriftDataset is a metadata dataset. It does not decode frames or
controls for you. It resolves segment metadata lazily and can optionally
download one primary file per sample.
from torch.utils.data import DataLoader
from drift.torch import DriftDataset
dataset = DriftDataset(
dataset_id="jordy-v0",
base_url="https://drift-api-production-1d47.up.railway.app",
download_dir=".cache/drift-torch",
)
print("segments:", len(dataset))
sample = dataset[0]
print(sample["segment_id"])
print(sample["files"])
print(sample.get("download_path"))
loader = DataLoader(dataset, batch_size=4, shuffle=False)
batch = next(iter(loader))
print(batch["segment_id"])
The payload returned by each item is shaped for a downstream parser:
segment_idroute_idsegment_indexfilesdownload_urldownload_pathwhendownload_diris set
TensorFlow / Keras example
drift.tensorflow.DriftDataset is also metadata-first. Iterate over it directly
or convert it into a tf.data.Dataset if you want a Keras-compatible input
stream.
import tensorflow as tf
from drift.tensorflow import DriftDataset
segments = DriftDataset(
dataset_id="jordy-v0",
base_url="https://drift-api-production-1d47.up.railway.app",
)
for item in segments:
print(item["segment_id"], item["files"])
break
keras_dataset = segments.to_keras_dataset()
keras_dataset = keras_dataset.take(4)
for item in keras_dataset:
tf.print(item["segment_id"], item["download_url"])
This is useful when your actual model input pipeline lives in a later mapping stage that downloads or decodes the referenced artifacts.
Common mistake
This is wrong:
client.load_dataset("jordy-v0")
That only returns summary metadata. It does not download data.
This is the correct conceptual flow:
dataset = client.load_dataset("jordy-v0")
routes = client.list_routes(dataset.id)
route = client.get_route(routes[0].route_id)
segment = client.get_segment(route.segments[0]["segment_id"])
segment.download("downloads/example.bin")
Release notes
0.1.1
- polished package metadata and documentation
- added release workflow and repository scaffolding
- improved SDK examples for downloads and framework integrations
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drift_sdk-0.1.5.tar.gz.
File metadata
- Download URL: drift_sdk-0.1.5.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cbaf6f97cc0b676f2b3d7ef5f457d3daa68fe52136277f453f363712a68cda7
|
|
| MD5 |
8b936b004efa8139ccc590be96486c53
|
|
| BLAKE2b-256 |
0b43f5ed245eb9a24a0c972caac69f16f26edb7ed52263abf13fdae425c34a99
|
File details
Details for the file drift_sdk-0.1.5-py3-none-any.whl.
File metadata
- Download URL: drift_sdk-0.1.5-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9fa56589558316ced8315ffb90844445cd7be0e517788dbd6f85f7569132d93
|
|
| MD5 |
780bf91058830277fe16bfcb42111624
|
|
| BLAKE2b-256 |
5b7778e61128e5582b5cb7b6e158cab96ab255171546fb8c47de3d5c97c725b0
|