Skip to content

Make convert_v3_to_v2.py non-destructive by default#719

Open
asierarranz wants to merge 1 commit into
NVIDIA:mainfrom
asierarranz:aarranz/fix-convert-v3-to-v2-inplace
Open

Make convert_v3_to_v2.py non-destructive by default#719
asierarranz wants to merge 1 commit into
NVIDIA:mainfrom
asierarranz:aarranz/fix-convert-v3-to-v2-inplace

Conversation

@asierarranz

@asierarranz asierarranz commented Jul 8, 2026

Copy link
Copy Markdown

Description

If you run scripts/lerobot_conversion/convert_v3_to_v2.py today, it converts your dataset in place and the source v3.0 dataset is gone. Nothing in --help warns about it. It happened to us: the script ate a dataset of 40 teleop episodes and we had to regenerate it from the source HDF5 files.

Why people run this script: there is a format gap between the two worlds right now. Modern LeRobot (v0.6.0) records everything as v3.0, while the native tooling in this repo (finetune scripts, data loader) still expects v2.1. So anyone recording with LeRobot today and fine-tuning through the native path has to go through this converter, and #677 even points v3.0 users straight to it. That is a lot of first-time users about to run a script that can eat their only copy. This PR makes the default behavior safe.

What changed:

  • The converted v2.1 dataset is written to --output (default: a sibling directory with a _v2.1 suffix). The source is never touched.
  • The script now refuses to overwrite the source or any existing directory. The old code did shutil.rmtree on existing siblings without warning.
  • In-place conversion still exists behind an explicit --in-place flag: it warns first and keeps the original in a sibling _backup_v3.0 directory. Mutually exclusive with --output.
  • The SO100 example workflow passes --in-place so its downstream paths keep working. Both READMEs and --help document the new behavior.

How tested: 7 new unit tests in tests/scripts/test_convert_v3_to_v2.py (destination resolution, refusal to overwrite source or existing dirs, backup naming, flag exclusion), ruff check and ruff format --check clean with the repo config, CLI smoke-tested with both flag combinations.

Note: --force-conversion still removes an existing source snapshot; that behavior predates this PR and is left as is to keep the diff focused.

The script replaced the source v3.0 dataset in place and deleted
existing _v3.0/_v2.1 sibling dirs without warning, silently destroying
data. Write the converted dataset to --output (default: sibling _v2.1
dir) and gate in-place replacement behind an explicit --in-place flag.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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