Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show friendly error when tries to record already existed dataset #592

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

helper2424
Copy link
Contributor

@helper2424 helper2424 commented Dec 22, 2024

What this does

This PR makes the process of dataset recording is more friendly. If you try to run scripts for recording dataset two times sequentially (it could happend because of some env error, or robot error or whatever) the script will show you the following error:

    obj.meta = LeRobotDatasetMetadata.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/helper2424/Documents/lerobot/lerobot/common/datasets/lerobot_dataset.py", line 291, in create
    obj.root.mkdir(parents=True, exist_ok=False)
  File "/opt/homebrew/Cellar/python@3.12/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pathlib.py", line 1311, in mkdir
    os.mkdir(self, mode)
FileExistsError: [Errno 17] File exists: '/Users/helper2424/.cache/huggingface/lerobot/helper2424/hil-serl-pusht-reward-classifier-test'

It's difficult to realize what it means. The answer is easy - we try to create dataset two times. If it exists the code will crashs.

To avoid the confusion I have added error handling and user friendly error text which asks user to launch the script one more time with --resume flag.

Examples:

Before After
Screenshot 2024-12-22 at 3 52 05 PM Screenshot 2024-12-22 at 3 52 30 PM

How it was tested

I have launched two times the following command

python lerobot/scripts/control_robot.py record \    --robot-path lerobot/configs/robot/koch_helper2424.yaml \
    --num-episodes 2 \
    --warmup-time-s 5 \
    --episode-time-s 10 \
    --fps 30 \
    --policy-overrides "device=mps" \
    --repo-id ${HF_USER}/hil12-serl-pusht-reward-classifier-test \
    --single-task "Push small T object to the correct position"

Unit tests:

pytest tests/lerobot/common/datasets/test_lerobot_dataset.py

@helper2424 helper2424 marked this pull request as ready for review December 22, 2024 09:26
…gfix/add_friendly_exception_handler_when_tries_to_create_already_exist_ds
…gfix/add_friendly_exception_handler_when_tries_to_create_already_exist_ds
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