Skip to content

Commit 2b1e533

Browse files
authored
Merge pull request #365 from QuantStrategyLab/codex/qpk-pin-sync-diagnostics
fix: isolate downstream QPK dependency failures
2 parents 1354f43 + 68aea15 commit 2b1e533

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

scripts/open_downstream_qpk_pin_prs.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ def run(cmd: list[str], *, cwd: Path | None = None, env: dict[str, str] | None =
6666
return subprocess.run(cmd, cwd=cwd, env=env, text=True, capture_output=True, check=True)
6767

6868

69+
def command_failure_summary(exc: subprocess.CalledProcessError) -> str:
70+
"""Return an actionable failure marker without copying command output to logs."""
71+
command = exc.cmd
72+
if isinstance(command, (list, tuple)) and command:
73+
executable = Path(str(command[0])).name
74+
elif isinstance(command, str):
75+
executable = command.split(maxsplit=1)[0]
76+
else:
77+
executable = "unknown"
78+
return f"command={executable}:exit={exc.returncode}"
79+
80+
6981
def has_changes(repo_dir: Path) -> bool:
7082
result = run(["git", "status", "--porcelain"], cwd=repo_dir)
7183
return bool(result.stdout.strip())
@@ -496,11 +508,19 @@ def main() -> int:
496508
target_root.mkdir()
497509
for repo in repo_specs:
498510
repo_dir = clone_repo(repo, target_root, token, dry_run=args.dry_run)
499-
if not update_repo(
500-
repo_dir,
501-
qpk_pin,
502-
strategy_heads=strategy_heads if phase == "consumers" else None,
503-
):
511+
try:
512+
changed = update_repo(
513+
repo_dir,
514+
qpk_pin,
515+
strategy_heads=strategy_heads if phase == "consumers" else None,
516+
)
517+
except subprocess.CalledProcessError as exc:
518+
results.append(
519+
f"{repo.name}: dependency_update_failed:{command_failure_summary(exc)}"
520+
)
521+
failures += 1
522+
continue
523+
if not changed:
504524
results.append(f"{repo.name}: no changes needed")
505525
continue
506526
try:

tests/test_qpk_pin_consistency.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import tempfile
44
import unittest
55
from pathlib import Path
6+
from subprocess import CalledProcessError
67

78
from scripts.check_qpk_pin_consistency import (
89
check_repo,
@@ -12,6 +13,7 @@
1213
from scripts.open_downstream_qpk_pin_prs import (
1314
CONSUMER_REPOS,
1415
STRATEGY_REPOS,
16+
command_failure_summary,
1517
qpk_refs,
1618
update_aggregate_bundle,
1719
update_qsl_metadata_test_contract,
@@ -27,6 +29,16 @@
2729

2830

2931
class QpkPinConsistencyTests(unittest.TestCase):
32+
def test_command_failure_summary_omits_command_output(self) -> None:
33+
exc = CalledProcessError(
34+
2,
35+
["uv", "pip", "install", "--python", "/tmp/resolver/bin/python", "."],
36+
output="do not log resolver output",
37+
stderr="do not log resolver stderr",
38+
)
39+
40+
self.assertEqual("command=uv:exit=2", command_failure_summary(exc))
41+
3042
def test_rollout_tiers_keep_qmt_after_strategies(self) -> None:
3143
self.assertEqual(
3244
{

0 commit comments

Comments
 (0)