Spaces:
Sleeping
Sleeping
Commit ·
a83d5d2
1
Parent(s): d4776d0
Preliminary findings propagation @57dca65
Browse files- tools/hf_space/runner.py +25 -5
tools/hf_space/runner.py
CHANGED
|
@@ -456,6 +456,7 @@ def _validate_zip_streaming(*, api: HfApi, dataset: str, token: str | None,
|
|
| 456 |
|
| 457 |
merged_results: list[dict] = []
|
| 458 |
merged_layout: list[dict] = []
|
|
|
|
| 459 |
# Set when ANY processed unit's results.json carries
|
| 460 |
# preliminary_check_failed=true (the validator's strict pre-check fired).
|
| 461 |
# Propagated into the final dict so the dashboard sees the flag
|
|
@@ -786,8 +787,10 @@ def _validate_zip_streaming(*, api: HfApi, dataset: str, token: str | None,
|
|
| 786 |
asset["rel_path"] = asset_rel
|
| 787 |
zip_results = rj.get("results", [])
|
| 788 |
zip_layout = rj.get("layout_findings") or []
|
|
|
|
| 789 |
merged_results.extend(zip_results)
|
| 790 |
merged_layout.extend(zip_layout)
|
|
|
|
| 791 |
if rj.get("preliminary_check_failed"):
|
| 792 |
any_preliminary_check_failed = True
|
| 793 |
out(f" {len(zip_results)} asset(s); rc={rc}")
|
|
@@ -900,6 +903,7 @@ def _validate_zip_streaming(*, api: HfApi, dataset: str, token: str | None,
|
|
| 900 |
"schema_version": 1,
|
| 901 |
"results": merged_results,
|
| 902 |
"layout_findings": merged_layout,
|
|
|
|
| 903 |
"preliminary_check_failed": any_preliminary_check_failed,
|
| 904 |
"profile_coverage": {},
|
| 905 |
"streaming_zips": len(zip_entries),
|
|
@@ -918,12 +922,28 @@ def _summarize(results_json: dict) -> tuple[str, str]:
|
|
| 918 |
# knows what to do (forward the report to the partner; address
|
| 919 |
# these before re-validating to surface deeper USD findings).
|
| 920 |
if results_json.get("preliminary_check_failed"):
|
| 921 |
-
|
| 922 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 923 |
files_affected = len(results_json.get("results") or [])
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 927 |
counts = {"error": 0, "failure": 0, "warning": 0}
|
| 928 |
total = len(results_json.get("results", []))
|
| 929 |
failed = 0
|
|
|
|
| 456 |
|
| 457 |
merged_results: list[dict] = []
|
| 458 |
merged_layout: list[dict] = []
|
| 459 |
+
merged_preliminary: list[dict] = []
|
| 460 |
# Set when ANY processed unit's results.json carries
|
| 461 |
# preliminary_check_failed=true (the validator's strict pre-check fired).
|
| 462 |
# Propagated into the final dict so the dashboard sees the flag
|
|
|
|
| 787 |
asset["rel_path"] = asset_rel
|
| 788 |
zip_results = rj.get("results", [])
|
| 789 |
zip_layout = rj.get("layout_findings") or []
|
| 790 |
+
zip_preliminary = rj.get("preliminary_findings") or []
|
| 791 |
merged_results.extend(zip_results)
|
| 792 |
merged_layout.extend(zip_layout)
|
| 793 |
+
merged_preliminary.extend(zip_preliminary)
|
| 794 |
if rj.get("preliminary_check_failed"):
|
| 795 |
any_preliminary_check_failed = True
|
| 796 |
out(f" {len(zip_results)} asset(s); rc={rc}")
|
|
|
|
| 903 |
"schema_version": 1,
|
| 904 |
"results": merged_results,
|
| 905 |
"layout_findings": merged_layout,
|
| 906 |
+
"preliminary_findings": merged_preliminary,
|
| 907 |
"preliminary_check_failed": any_preliminary_check_failed,
|
| 908 |
"profile_coverage": {},
|
| 909 |
"streaming_zips": len(zip_entries),
|
|
|
|
| 922 |
# knows what to do (forward the report to the partner; address
|
| 923 |
# these before re-validating to surface deeper USD findings).
|
| 924 |
if results_json.get("preliminary_check_failed"):
|
| 925 |
+
# Count actual issues by summing across results — robust to
|
| 926 |
+
# whichever sidecar field the validator populated.
|
| 927 |
+
violations = sum(len(r.get("issues") or [])
|
| 928 |
+
for r in (results_json.get("results") or []))
|
| 929 |
+
if violations == 0:
|
| 930 |
+
# Fall back to the sidecar list when results is empty
|
| 931 |
+
# (shouldn't happen, defensive).
|
| 932 |
+
violations = len(results_json.get("preliminary_findings")
|
| 933 |
+
or results_json.get("layout_findings") or [])
|
| 934 |
files_affected = len(results_json.get("results") or [])
|
| 935 |
+
# Per-code breakdown for the chip text — the partner-facing
|
| 936 |
+
# summary is more useful when it names the failing rules.
|
| 937 |
+
code_counts: dict[str, int] = {}
|
| 938 |
+
for r in (results_json.get("results") or []):
|
| 939 |
+
for iss in (r.get("issues") or []):
|
| 940 |
+
c = iss.get("code") or "UNKNOWN"
|
| 941 |
+
code_counts[c] = code_counts.get(c, 0) + 1
|
| 942 |
+
top_codes = sorted(code_counts.items(), key=lambda kv: -kv[1])[:3]
|
| 943 |
+
codes_text = ", ".join(f"{c} ×{n}" for c, n in top_codes) if top_codes else "0 issues"
|
| 944 |
+
return "fail", (f"PRELIMINARY CHECK FAILED — {codes_text} "
|
| 945 |
+
f"({files_affected} file(s) affected). Address these "
|
| 946 |
+
f"before deeper validation runs.")
|
| 947 |
counts = {"error": 0, "failure": 0, "warning": 0}
|
| 948 |
total = len(results_json.get("results", []))
|
| 949 |
failed = 0
|