Refuse an unknown run input by name before reading its value
`fluksio run --param lr=0.002` died with a bare JSONDecodeError: `--param` is not a `run` flag, so it became an input named `param` whose value `lr=0.002` was json-decoded. The name check ran after the coercion, so the decode error always won. Names are now checked first, and a coercion error is a SyncError naming the input and its type, the way `_ask_params` has always done it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Hra4ndWMCLU5F3KjUuVAc
This commit is contained in:
@@ -88,6 +88,24 @@ def test_run_arguments_are_typed_by_the_flow_they_are_for() -> None:
|
||||
_params(definition, ["--nonesuch", "1"])
|
||||
|
||||
|
||||
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
|
||||
|
||||
from fluksio.sdk import SyncError
|
||||
from fluksio.sdk.cli import _params
|
||||
|
||||
definition = {"inputs": [{"spec": {"name": "lr", "dtype": "float"}}]}
|
||||
|
||||
# Not a JSONDecodeError over `lr=0.002`, which is what reading the value
|
||||
# before the name used to give.
|
||||
with pytest.raises(SyncError, match="sweep --param"):
|
||||
_params(definition, ["--param", "lr=0.002"])
|
||||
|
||||
with pytest.raises(SyncError, match="'lr' takes float"):
|
||||
_params(definition, ["--lr", "fast"])
|
||||
|
||||
|
||||
def test_serve_uses_the_installation_the_directory_belongs_to(
|
||||
tmp_path: Path, monkeypatch
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user