Visitar URL original
CI: Introduce functional scripts dependencies in CI test selection by C-Achard · Pull Request #3396 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Resolve functional script dependencies recursively
Add `resolve_functional_scripts` to expand selected functional scripts with transitive dependencies, return dependency-ordered execution, and detect cycles explicitly. `decide()` now uses this resolver to collect dependency provenance for auto-added scripts, replacing the previous one-level dependency provenance logic and keeping output provenance formatting clearer and consistent.
  • Loading branch information
C-Achard committed Jul 14, 2026
commit 076e6aabef3040a642bce02e47d202f70d47d198
58 changes: 48 additions & 10 deletions tools/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,49 @@
return False


def resolve_functional_scripts(
selected: set[str],
) -> tuple[list[str], dict[str, set[str]]]:
"""Expand and dependency-order functional scripts.

Returns:
ordered
Selected scripts and their transitive dependencies, with each
dependency appearing before scripts that depend on it.
dependency_sources
Provenance entries for every dependency added during expansion.
"""
ordered: list[str] = []
dependency_sources: dict[str, set[str]] = defaultdict(set)
visited: set[str] = set()
visiting: set[str] = set()

def visit(script: str) -> None:
if script in visited:
return

if script in visiting:
raise ValueError(f"Cyclic functional-script dependency involving {script!r}")

visiting.add(script)

for dependency in FUNC_SCRIPT_DEPENDENCIES.get(
script,
(),
):
dependency_sources[dependency].add(f"dependency:{script}")
visit(dependency)

visiting.remove(script)
visited.add(script)
ordered.append(script)

for script in sorted(selected):
visit(script)

return ordered, dependency_sources


def order_functional_scripts(
selected: set[str],
) -> list[str]:
Expand Down Expand Up @@ -534,22 +577,17 @@
fast_reasons.append("fallback_minimal_pytest")
lane_reasons["fast"] = fast_reasons

ordered_functional_scripts = order_functional_scripts(functional_set)

for dependent in functional_set:
for dependency in FUNC_SCRIPT_DEPENDENCIES.get(
dependent,
(),
):
script_sources[dependency].add(f"dependency:{dependent}")
ordered_functional_scripts, dependency_sources = resolve_functional_scripts(functional_set)
for scrpt, srcs in dependency_sources.items():

Check failure on line 581 in tools/test_selector.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

scrpt ==> script
script_sources[scrpt].update(srcs)

Check failure on line 582 in tools/test_selector.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

scrpt ==> script

return SelectorResult(
lanes=lanes,
pytest_paths=sorted(pytest_paths_set),
functional_scripts=ordered_functional_scripts,
provenance=SelectionProvenance(
pytest={k: sorted(v) for k, v in sorted(pytest_sources.items())},
scripts={k: sorted(v) for k, v in sorted(script_sources.items())},
pytest={path: sorted(sources) for path, sources in sorted(pytest_sources.items())},
scripts={path: sorted(sources) for path, sources in sorted(script_sources.items())},
),
reasons=reasons,
changed_files=files,
Expand Down
Loading