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:
2026-10-15 10:56:46 +02:00
parent e597c34823
commit b9078dd19f
4 changed files with 50 additions and 5 deletions
+12 -2
View File
@@ -453,15 +453,20 @@ def _ask_params(definition: dict[str, Any]) -> dict[str, Any]:
def _params(definition: dict[str, Any], rest: list[str]) -> dict[str, Any]:
"""Turn `--lr 0.05` into a typed parameter, using the flow's own inputs."""
"""Turn `--lr 0.05` into a typed parameter, using the flow's own inputs.
After `--` every token is `name=value`, which is how an input that shares
its name with a flag of `run` is set.
"""
types = _input_types(definition)
cut = rest.index("--") if "--" in rest else len(rest)
# Collected as written and typed afterwards, so a name this flow does not
# have is refused by name rather than by whatever its value failed to parse
# as: `--param lr=0.002` is a sweep's spelling, and said so it reads as an
# input called `param` holding unparseable json.
raw: dict[str, str | bool] = {}
pending: str | None = None
for token in rest:
for token in rest[:cut]:
if token.startswith("--"):
if pending is not None:
# A flag with no value is a flag: `--resume` means true.
@@ -480,6 +485,11 @@ def _params(definition: dict[str, Any], rest: list[str]) -> dict[str, Any]:
pending = None
if pending is not None:
raw[pending] = True
for token in rest[cut + 1 :]:
name, sep, value = token.partition("=")
if not sep or not name:
raise SyncError(f"after `--` an input is name=value, not '{token}'")
raw[name.replace("-", "_")] = value
unknown = sorted(set(raw) - set(types))
if unknown:
hint = ""