| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import sys |
|
|
| import draccus |
| import pytest |
|
|
| |
| |
| pytest.importorskip("datasets", reason="datasets is required (install lerobot[dataset])") |
|
|
| from lerobot.configs.train import TrainPipelineConfig |
| from lerobot.policies.act.configuration_act import ( |
| ACTConfig, |
| ) |
| from lerobot.scripts.lerobot_train import _remote_target_in_argv, train |
|
|
|
|
| def _set_argv(monkeypatch, *args): |
| monkeypatch.setattr(sys, "argv", ["lerobot-train", *args]) |
|
|
|
|
| def test_remote_target_detected_space_separated(monkeypatch): |
| _set_argv(monkeypatch, "--policy.type", "act", "--job.target", "a10g-small") |
| assert _remote_target_in_argv() is True |
|
|
|
|
| def test_remote_target_detected_equals(monkeypatch): |
| _set_argv(monkeypatch, "--job.target=t4-small") |
| assert _remote_target_in_argv() is True |
|
|
|
|
| def test_local_string_is_not_remote(monkeypatch): |
| _set_argv(monkeypatch, "--job.target", "local") |
| assert _remote_target_in_argv() is False |
|
|
|
|
| def test_no_target_is_not_remote(monkeypatch): |
| _set_argv(monkeypatch, "--policy.type", "act") |
| assert _remote_target_in_argv() is False |
|
|
|
|
| def test_train_dispatches_to_submit_when_remote(monkeypatch): |
| """A remote --job.target short-circuits train() to the HF Jobs submitter.""" |
| import lerobot.scripts.lerobot_train as train_module |
|
|
| captured = [] |
| monkeypatch.setattr(train_module, "submit_to_hf", lambda cfg: captured.append(cfg) or "submitted") |
| cfg = draccus.parse( |
| TrainPipelineConfig, |
| args=["--dataset.repo_id", "u/d", "--policy.type", "act", "--job.target", "a10g-small"], |
| ) |
| |
| assert train(cfg) == "submitted" |
| assert captured == [cfg] |
|
|