diff --git a/lerobot/scripts/push_dataset_to_hub.py b/lerobot/scripts/push_dataset_to_hub.py index e43e5f274..18714a40a 100644 --- a/lerobot/scripts/push_dataset_to_hub.py +++ b/lerobot/scripts/push_dataset_to_hub.py @@ -142,22 +142,21 @@ def push_dataset_to_hub( cache_dir: Path = Path("/tmp"), tests_data_dir: Path | None = None, ): + # Check repo_id is well formated + if len(repo_id.split("/")) != 2: + raise ValueError( + f"`repo_id` is expected to contain a community or user id `/` the name of the dataset (e.g. 'lerobot/pusht'), but instead contains '{repo_id}'." + ) + user_id, dataset_id = repo_id.split("/") + # Robustify when `raw_dir` is str instead of Path raw_dir = Path(raw_dir) - if not raw_dir.exists(): raise NotADirectoryError( f"{raw_dir} does not exists. Check your paths or run this command to download an existing raw dataset on the hub:" f"python lerobot/common/datasets/push_dataset_to_hub/_download_raw.py --raw-dir your/raw/dir --repo-id your/repo/id_raw" ) - # Check repo_id is well formated - if len(repo_id.split("/")) != 2: - raise ValueError( - f"`repo_id` is expected to contain a community or user id `/` the name of the dataset (e.g. 'lerobot/pusht'), but instead contains '{repo_id}'." - ) - user_id, dataset_id = repo_id.split("/") - if local_dir: # Robustify when `local_dir` is str instead of Path local_dir = Path(local_dir) diff --git a/tests/test_push_dataset_to_hub.py b/tests/test_push_dataset_to_hub.py index d9e2b6ab8..7ddbe7aab 100644 --- a/tests/test_push_dataset_to_hub.py +++ b/tests/test_push_dataset_to_hub.py @@ -229,9 +229,9 @@ def _mock_download_raw(raw_dir, repo_id): raise ValueError(repo_id) -def test_push_dataset_to_hub_invalid_repo_id(): +def test_push_dataset_to_hub_invalid_repo_id(tmpdir): with pytest.raises(ValueError): - push_dataset_to_hub(Path("raw"), "raw_format", "invalid_repo_id") + push_dataset_to_hub(Path(tmpdir), "raw_format", "invalid_repo_id") def test_push_dataset_to_hub_out_dir_force_override_false(tmpdir):