Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions tests/test_utils/python_scripts/recipe_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
}


def _resolve_scope_alias(scope_value: str) -> str:
"""Resolve a legacy scope value to its L-tier alias (or return it unchanged).

Applied both to recipe rows when flattening and to the `--scope` filter
input, so callers can pass either the legacy name (e.g. `nightly`) or the
new L-tier name (e.g. `L2`) and hit the same recipe rows.
"""
if scope_value in LEGACY_SCOPE_ALIASES:
return LEGACY_SCOPE_ALIASES[scope_value][0]
return scope_value


def _apply_scope_alias(scope_value: str, explicit_cadence: Optional[List[str]]) -> tuple:
"""Resolve a legacy scope value to (new_scope, cadence).

Expand Down Expand Up @@ -206,11 +218,18 @@ def filter_by_test_case(workload_manifests: List[dotdict], test_case: str) -> Op


def filter_by_scope(workload_manifests: List[dotdict], scope: str) -> List[dotdict]:
"""Returns all workload with matching scope."""
"""Returns all workload with matching scope.

The filter input is run through the same legacy-scope alias as recipe
rows, so callers passing the legacy name (e.g. `--scope nightly`,
`--scope mr-github`) match recipes that have already been rewritten to
the new L-tier vocabulary (e.g. `scope: [L2]`, `scope: [L1]`).
"""
resolved_scope = _resolve_scope_alias(scope)
workload_manifests = list(
workload_manifest
for workload_manifest in workload_manifests
if workload_manifest.spec["scope"] == scope
if workload_manifest.spec["scope"] == resolved_scope
)

if len(workload_manifests) == 0:
Expand Down
Loading