Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadene committed Jun 13, 2024
1 parent be8a37c commit dadcbdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions lerobot/scripts/push_dataset_to_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_push_dataset_to_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit dadcbdc

Please sign in to comment.