Skip to content

Add bt datasets snapshots for dataset version control#176

Draft
max-braintrust wants to merge 10 commits into
mainfrom
max/add-dataset-snapshots
Draft

Add bt datasets snapshots for dataset version control#176
max-braintrust wants to merge 10 commits into
mainfrom
max/add-dataset-snapshots

Conversation

@max-braintrust
Copy link
Copy Markdown

@max-braintrust max-braintrust commented May 6, 2026

TL;DR

Follow up to: #104

Adds bt datasets snapshots for managing saved dataset snapshots from the CLI: list, create, and restore dataset states from saved snapshots.

What changed?

Added dataset snapshot management functionality:

  • New bt datasets snapshots command with subcommands: list, create, and restore
  • Uses snapshot/dataset snapshot terminology to match the UI
  • Snapshot listing displays saved snapshots for a dataset
  • Snapshot creation can infer the current dataset head xact when --xact-id is omitted
  • Snapshot restore supports restore by snapshot name or by xact ID with --snapshot
  • Restore includes preview support and requires confirmation unless --force is passed
  • JSON output includes snapshot list/create/restore modes and found_existing for create responses
  • Moved snapshot-specific CLI args into the snapshot module to match existing subcommand patterns
  • Added shared profile utilities for resolving profile info and generating default snapshot name slugs

Added test coverage:

  • Unit tests for snapshot arg parsing, read/write auth routing, response deserialization, default snapshot names, and restore target selection
  • Fixture coverage for snapshot creation, duplicate xact handling via x-bt-found-existing, and snapshot listing
  • Mock server support for dataset snapshot create and list endpoints

How to test?

# Create a dataset
bt datasets create my-dataset --rows '[{"id":"case-1","input":{"text":"hi"},"expected":"hello"}]'

# List snapshots
bt datasets snapshots list my-dataset

# Create a snapshot
bt datasets snapshots create my-dataset baseline

# Re-run create for the same xact to verify found_existing handling
bt datasets snapshots create my-dataset baseline-again --xact-id 1000192656880881099 --json

# Restore by snapshot name
bt datasets snapshots restore my-dataset --name baseline

# Restore by xact ID
bt datasets snapshots restore my-dataset --snapshot 1000192656880881099 --force

@max-braintrust max-braintrust changed the title Add bt datasets snapshots for better dataset version control Add bt datasets snapshots for dataset version control May 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Latest downloadable build artifacts for this PR commit 56d5516009d7:

Available artifact names
  • ``artifacts-build-global
  • ``artifacts-build-local-x86_64-pc-windows-msvc
  • ``artifacts-build-local-x86_64-apple-darwin
  • ``artifacts-build-local-aarch64-pc-windows-msvc
  • ``artifacts-build-local-x86_64-unknown-linux-musl
  • ``artifacts-build-local-x86_64-unknown-linux-gnu
  • ``artifacts-build-local-aarch64-apple-darwin
  • ``artifacts-build-local-aarch64-unknown-linux-gnu
  • ``artifacts-plan-dist-manifest
  • ``cargo-dist-cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant