Skip to main content

Overview

The Atlas SDK provides direct PostgreSQL access for training data extraction, eliminating JSONL export intermediates and preventing schema drift between SDK and ATLAS Core. Query training sessions with reward-based filtering, selective data loading, and pagination support for large datasets.

Prerequisites

  • Atlas SDK v0.1.13 or higher
  • PostgreSQL database with runtime traces (configured via storage.database_url)
  • Python 3.10+

Direct Database Access

Basic Usage

Query training sessions directly from PostgreSQL:

Async Queries

For high-throughput training pipelines:

Query Filters

Reward-Based Filtering

Filter sessions by reward score using JSONB operators:

Status Filtering

Filter by runtime completion status:

Date Range Filtering

Query sessions within a specific time window:

Selective Data Loading

Control which data is loaded to optimize performance:
Performance impact:
  • include_trajectory_events=False: 50-70% faster queries
  • include_learning_data=False: 30-40% faster queries

Pagination

Process large datasets in batches using async iterators:

Session Count Queries

Get session counts without loading full data:

Fetch Individual Sessions

Retrieve a specific session by ID:

Schema Fields

AtlasSessionTrace

Essential fields (always loaded):
  • session_reward: Aggregate reward with score and uncertainty
  • trajectory_events: Ordered list of runtime events
  • student_learning: Student persona learning notes
  • teacher_learning: Teacher persona learning notes
  • learning_history: Historical learning data
  • adaptive_summary: Mode selection and probe evidence
Property accessors (loaded on demand):
  • learning_key: Task identifier for grouping sessions
  • teacher_notes: Guidance provided during execution
  • reward_summary: Simplified reward statistics
  • drift: Detected schema or behavior drift
  • drift_alert: Critical drift warnings
  • triage_dossier: Pre-execution risk assessment
  • reward_audit: Detailed judge breakdowns

AtlasStepTrace

Essential fields:
  • runtime: Execution time in milliseconds
  • depends_on: Step dependency graph
Property accessors:
  • attempt_history: Previous attempt records

Performance Optimization

Database Indexes

The SDK automatically creates performance indexes:

Query Optimization

For training workloads with millions of sessions:

Integration with Training Pipeline

Step 1: Query Training Data

Step 2: Convert to Training Format

Step 3: Wire into Hydra configs

Prefer to skip the manual Python glue? The repo now ships a Postgres-backed dataset preset. Override the global data config with runtime_pg and supply your connection details:
The helper streams sessions via atlas.training_data, converts trajectory events into chat-format messages, and produces Hugging Face datasets on the fly—no JSONL export required.

Step 4: Train with GRPO

See GRPO Training Guide for complete training pipeline.

Migration from JSONL Export

Previous Approach (JSONL Files)

Direct Database Access

Benefits:
  • No intermediate JSONL files
  • Filters applied at database level
  • 10-100x faster queries with indexes
  • No schema drift between SDK and training

Troubleshooting

API Reference

Core Functions

Converter Functions