41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""Check that the launch command rejects a mismatched model action length."""
|
|||
|
|
|
||
|
|
import os
|
||
|
|
from pathlib import Path
|
||
|
|
import subprocess
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
|
||
|
|
ROOT = Path(__file__).parents[1]
|
||
|
|
SCRIPT = ROOT / "scripts" / "run_serving.sh"
|
||
|
|
|
||
|
|
|
||
|
|
def _launch(horizon):
|
||
|
|
if "WALLX_TEST_CHECKPOINT" not in os.environ:
|
||
|
|
pytest.skip("set WALLX_TEST_CHECKPOINT to run checkpoint-specific contract tests")
|
||
|
|
checkpoint = Path(os.environ["WALLX_TEST_CHECKPOINT"])
|
||
|
|
env = os.environ.copy()
|
||
|
|
env["PYTHON_BIN"] = os.environ.get("WALLX_TEST_PYTHON", "python")
|
||
|
|
return subprocess.run(
|
||
|
|
[
|
||
|
|
"bash", str(SCRIPT),
|
||
|
|
"--checkpoint-path", str(checkpoint),
|
||
|
|
"--train-config-path", str(checkpoint / "config.yml"),
|
||
|
|
"--action-horizon", str(horizon),
|
||
|
|
"--dry-run",
|
||
|
|
],
|
||
|
|
cwd=ROOT, env=env, text=True, capture_output=True, check=False,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def test_launch_rejects_mismatch_to_training_horizon():
|
||
|
|
result = _launch(10)
|
||
|
|
assert result.returncode != 0
|
||
|
|
assert "action horizon" in (result.stderr + result.stdout).lower()
|
||
|
|
|
||
|
|
|
||
|
|
def test_launch_accepts_training_horizon():
|
||
|
|
result = _launch(32)
|
||
|
|
assert result.returncode == 0, result.stderr
|
||
|
|
assert "--model-config.action-horizon 32" in result.stdout
|