Track API
The Track API provides efficient time-series data tracking for robotics, reinforcement learning, and any sequential experiments.
Overview
Tracks are perfect for:
- Robotics: Robot positions, joint angles, sensor readings
- Reinforcement Learning: Agent trajectories, rewards, states
- Simulations: Physics parameters over time
- Sequential Data: Any data that changes over time
Basic Usage
Timestamp-Based Tracking
Tracks support three timestamp modes:
1. Auto-Generated Timestamps (Recommended)
When _ts is not provided, timestamps are automatically generated:
2. Explicit Timestamps
Provide explicit timestamps when you need precise control:
3. Timestamp Inheritance with _ts=-1
Use _ts=-1 to inherit the last timestamp from the previous tracks.append() or metrics.log() call in the same thread. This is perfect for synchronizing multi-modal data:
_ts=-1 also inherits across metrics and tracks — they share the same last timestamp per thread:
Benefits of _ts=-1:
- Cleaner code - no need to manually pass timestamps around
- Less error-prone - can't accidentally use wrong timestamp
- Perfect for robotics/ML multi-modal data (poses, images, sensors at same instant)
- Works across ALL tracks and metrics globally (per thread)
Multiple Tracks
Track different aspects of your experiment:
Numpy Array Serialization
Tracks automatically serialize numpy arrays:
MuJoCo Example
Perfect for tracking robot simulations:
Aligning Frames with Tracks
Use consistent step indices to align frames with track data:
Reinforcement Learning Example
Buffering and Performance
Tracks use the background buffering system:
Configure track buffering:
Timestamp Merging
Entries with the same timestamp are automatically merged:
You can also use _ts=-1 for merging:
Best Practices
1. Use Consistent Indexing
2. Include Step/Episode in Data
3. Organize by Topic
4. Zero-Pad Filenames for Alignment
5. Store Frame References in Tracks
Track Slicing and Iteration
The slice() method returns an iterable view of track data with timestamp-based indexing using floor matching.
Basic Iteration
Timestamp Range Filtering
Floor-Match Timestamp Queries
The slice object supports findByTime() with floor matching: returns the entry with the largest timestamp ≤ queried timestamp.
Practical Example: Robot Trajectory Analysis
Synchronizing Multi-Modal Data
Combine slicing with timestamp inheritance for synchronized queries:
Slice Features
Iterator Protocol:
for entry in slice: ...- Iterate through entriesiter(slice)- Get iterator- Can iterate multiple times (data is cached)
Timestamp Queries:
slice.findByTime(timestamp)- Get entry by timestamp (floor match)- Optimized for sequential queries using internal index
- Raises
StorageError(fromml_dash) if query timestamp is before first entry
Length:
len(slice)- Get number of entries in slice
Representation:
repr(slice)- Shows topic, start, and end timestamps
API Reference
experiment.tracks(topic: str) -> TrackBuilder
Returns a TrackBuilder for the specified topic.
Parameters:
topic(str): Topic name (e.g., "robot/position")
Returns:
- TrackBuilder instance
TrackBuilder.append(**fields, _ts=None) -> TrackBuilder
Append a data entry to the track. Keyword-only: each keyword becomes a field.
Parameters:
**fields: Data fields to track_ts(float, optional): Timestamp. Omitted: generated from the current time.-1: reuse the previous timestamp. A number: use it as given.
Examples:
TrackBuilder.slice(start_timestamp: float = None, end_timestamp: float = None) -> TrackSlice
Create an iterable slice of track data with timestamp-based indexing.
Parameters:
start_timestamp(float, optional): Start timestamp (inclusive)end_timestamp(float, optional): End timestamp (inclusive)
Returns:
TrackSliceobject supporting iteration and timestamp indexing
Examples:
Comparison with Metrics
| Feature | Tracks | Metrics |
|---|---|---|
| Use Case | Time-series data, trajectories | Training metrics, losses |
| Structure | Flexible dict per entry | Flat key-value pairs |
| Timestamp | _ts field, explicit or auto | _ts field, explicit or auto |
_ts=-1 inheritance | Yes, shared with metrics | Yes, shared with tracks |
| Merging | Timestamp-based merging | No merging |
| Best For | Robotics, RL, sensors | Training loss, accuracy |
Example: Complete Robot Tracking
This creates a complete tracking dataset with aligned frames, positions, and control signals!