From 7af47abe2a16f0a402f49b018314399e67f540fc Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 14 Jul 2026 20:11:49 +0200 Subject: [PATCH] fix: accept regional layer CLI lists --- .../test_sprint191_regional_grb_context.py | 13 +++++++++++++ docs/CODEX_EXECUTION_LOG.md | 2 +- scripts/provision_regional_grb_context.py | 17 ++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/backend/tests/test_sprint191_regional_grb_context.py b/backend/tests/test_sprint191_regional_grb_context.py index 8cc3a098..58088804 100644 --- a/backend/tests/test_sprint191_regional_grb_context.py +++ b/backend/tests/test_sprint191_regional_grb_context.py @@ -59,6 +59,19 @@ def test_layer_registry_matches_verified_official_grb_collections() -> None: operator.selected_definitions("buildings") +def test_layer_selection_accepts_space_and_comma_cli_forms() -> None: + operator = load_operator() + + assert [item.key for item in operator.selected_definitions(["roads", "water", "parcels"])] == [ + "roads", + "water", + "parcels", + ] + assert [item.key for item in operator.selected_definitions("roads,parcels")] == ["roads", "parcels"] + with pytest.raises(ValueError, match="Unsupported layers"): + operator.selected_definitions(["roads", "imaginary"]) + + def test_line_owner_uses_intersection_length_and_deterministic_tie_break() -> None: operator = load_operator() scopes = __import__("geographic_scopes") diff --git a/docs/CODEX_EXECUTION_LOG.md b/docs/CODEX_EXECUTION_LOG.md index e860cc8a..0a98b413 100644 --- a/docs/CODEX_EXECUTION_LOG.md +++ b/docs/CODEX_EXECUTION_LOG.md @@ -9,7 +9,7 @@ Changed: Tested before deployment: - `python -m py_compile scripts/provision_regional_grb_context.py`. - `python -m pytest backend/tests/test_sprint191_regional_grb_context.py backend/tests/test_sprint190_regional_grb_buildings.py backend/tests/test_sprint106_map_bbox_extract.py -q` (`19 passed`). -- `bash scripts/run_readiness_check.sh` (`552 passed`; one Alembic head; frontend typecheck/build and script syntax gates passed). +- `bash scripts/run_readiness_check.sh` (`553 passed`; one Alembic head; frontend typecheck/build and script syntax gates passed). Next: - Pass the complete release gate, deploy the operator and provision all three live regional snapshots before claiming runtime readiness. diff --git a/scripts/provision_regional_grb_context.py b/scripts/provision_regional_grb_context.py index 04ff9e82..6b9c605e 100644 --- a/scripts/provision_regional_grb_context.py +++ b/scripts/provision_regional_grb_context.py @@ -112,7 +112,12 @@ LAYER_BY_KEY = {definition.key: definition for definition in LAYERS} def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser(description="Provision municipality-partitioned regional GRB context layers.") parser.add_argument("--scope", choices=sorted(GEOGRAPHIC_SCOPES), default=DEFAULT_SCOPE_KEY) - parser.add_argument("--layers", default=",".join(LAYER_BY_KEY), help="Comma-separated subset: roads,water,parcels") + parser.add_argument( + "--layers", + nargs="+", + default=list(LAYER_BY_KEY), + help="Space- or comma-separated subset: roads water parcels", + ) parser.add_argument("--observed-date", type=date.fromisoformat, default=date.today()) parser.add_argument("--base-url", default=os.environ.get("GEOINTEL_INTERNAL_API_URL", DEFAULT_API_URL)) parser.add_argument( @@ -131,8 +136,14 @@ def parse_args() -> argparse.Namespace: return parser.parse_args() -def selected_definitions(raw_layers: str) -> list[LayerDefinition]: - requested = {item.strip().lower() for item in raw_layers.split(",") if item.strip()} +def selected_definitions(raw_layers: str | list[str]) -> list[LayerDefinition]: + values = [raw_layers] if isinstance(raw_layers, str) else raw_layers + requested = { + item.strip().lower() + for value in values + for item in value.split(",") + if item.strip() + } unknown = requested - set(LAYER_BY_KEY) if unknown or not requested: raise ValueError(f"Unsupported layers: {sorted(unknown)}")