fluksio run takes inputs after -- as name=value
So an input named like a flag of run, timeout or sync, can still be set. Flags before -- keep naming inputs as they did.
This commit is contained in:
@@ -90,6 +90,31 @@ def test_run_arguments_are_typed_by_the_flow_they_are_for() -> None:
|
||||
_params(definition, ["--nonesuch", "1"])
|
||||
|
||||
|
||||
def test_inputs_after_a_double_dash_may_share_a_name_with_a_run_flag(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""`run --timeout` is the wait; `-- timeout=5` is the flow's input."""
|
||||
from fluksio import cli
|
||||
from fluksio.sdk import cli as sdk_cli
|
||||
|
||||
seen = []
|
||||
monkeypatch.setattr(
|
||||
sdk_cli, "cmd_run", lambda args, rest: seen.append((args.timeout, rest)) or 0
|
||||
)
|
||||
cli.main(["run", "train", "--timeout", "3", "--lr", "0.1", "--", "timeout=5"])
|
||||
assert seen == [(3.0, ["--lr", "0.1", "--", "timeout=5"])]
|
||||
|
||||
definition = {
|
||||
"inputs": [
|
||||
{"spec": {"name": "lr", "dtype": "float"}},
|
||||
{"spec": {"name": "timeout", "dtype": "int"}},
|
||||
]
|
||||
}
|
||||
assert sdk_cli._params(definition, seen[0][1]) == {"lr": 0.1, "timeout": 5}
|
||||
with pytest.raises(sdk_cli.SyncError, match="name=value"):
|
||||
sdk_cli._params(definition, ["--", "timeout"])
|
||||
|
||||
|
||||
def test_a_sweeps_param_spelling_is_refused_by_name() -> None:
|
||||
"""`run --param lr=0.002` is a name this flow has not got, and says so."""
|
||||
import pytest
|
||||
|
||||
Reference in New Issue
Block a user