Skip to content

Commit 7d1e97c

Browse files
quality follow-ups (preflight git rev-parse, schema_version on graders, shellcheck pass, fix latent SC2259 in submodule pipeline)
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
1 parent e3a6c18 commit 7d1e97c

7 files changed

Lines changed: 84 additions & 10 deletions

File tree

.claude/evals/aggregate.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,31 @@ def _cohen_kappa(a: list[bool | None], b: list[bool | None]) -> dict[str, Any]:
8686
}
8787

8888

89+
# Bump GRADING_SCHEMA_VERSION whenever the on-disk grading.*.json shape
90+
# changes incompatibly. Readers below only warn on mismatch (older
91+
# workspaces remain partially readable); add migration logic here when
92+
# you bump.
93+
GRADING_SCHEMA_VERSION = "1"
94+
95+
96+
def _check_schema(path: Path, payload: dict) -> None:
97+
"""Warn (don't fail) if a grading file was produced by a different schema.
98+
99+
Keeps the loop resilient: an old workspace with no version field still
100+
aggregates, just with a one-line note pointing at the producer.
101+
"""
102+
found = payload.get("schema_version")
103+
if found is None:
104+
sys.stderr.write(
105+
f"warning: {path} has no schema_version field "
106+
f"(expected {GRADING_SCHEMA_VERSION!r}); produced by an older "
107+
f"grader. Some fields may be missing.\n")
108+
elif found != GRADING_SCHEMA_VERSION:
109+
sys.stderr.write(
110+
f"warning: {path} schema_version={found!r}, expected "
111+
f"{GRADING_SCHEMA_VERSION!r}. Aggregation may misread fields.\n")
112+
113+
89114
def _load_iteration(iter_dir: Path) -> dict[str, dict[str, dict]]:
90115
"""Return {config_name: {grader_name: grading_dict}}."""
91116
out: dict[str, dict[str, dict]] = {}
@@ -95,7 +120,9 @@ def _load_iteration(iter_dir: Path) -> dict[str, dict[str, dict]]:
95120
cfg_record: dict[str, dict] = {}
96121
for path in sorted(cfg.glob("grading.*.json")):
97122
grader = path.stem.split(".", 1)[1]
98-
cfg_record[grader] = json.loads(path.read_text())
123+
payload = json.loads(path.read_text())
124+
_check_schema(path, payload)
125+
cfg_record[grader] = payload
99126
if cfg_record:
100127
out[cfg.name] = cfg_record
101128
return out

.claude/evals/graders/executable.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def grade(skill: str, responses: dict, assertions_path: Path) -> dict:
213213
skipped = sum(1 for s in scenarios if s["status"] == "skipped")
214214

215215
return {
216+
"schema_version": "1",
216217
"grader": "executable",
217218
"skill": skill,
218219
"assertions_path": str(assertions_path),

.claude/evals/graders/judge.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def grade(skill: str, prompts: list[dict], assertions: dict,
247247
(len(have_scores) * 8) if have_scores else 0.0)
248248

249249
return {
250+
"schema_version": "1",
250251
"grader": "judge",
251252
"skill": skill,
252253
"model": model,

.claude/evals/graders/programmatic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def grade(skill: str, responses: dict[str, str], assertions_path: Path) -> dict:
150150
max(len(scenarios), 1))
151151

152152
return {
153+
"schema_version": "1",
153154
"grader": "programmatic",
154155
"skill": skill,
155156
"assertions_path": str(assertions_path),

.claude/evals/viewer/generate_review.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@
2525
EVALS_ROOT = Path(__file__).resolve().parents[1]
2626
PROMPTS_DIR = EVALS_ROOT / "prompts"
2727

28+
# Keep in sync with aggregate.py::GRADING_SCHEMA_VERSION. Duplicated rather
29+
# than imported so the viewer stays standalone.
30+
GRADING_SCHEMA_VERSION = "1"
31+
32+
33+
def _check_schema(path: Path, payload: dict) -> None:
34+
"""Warn (don't fail) when a grading file was produced under a different
35+
schema. The viewer is best-effort: it'll still render what it can."""
36+
found = payload.get("schema_version")
37+
if found is None:
38+
sys.stderr.write(
39+
f"warning: {path} has no schema_version field "
40+
f"(expected {GRADING_SCHEMA_VERSION!r}). Some columns may be blank.\n"
41+
)
42+
elif found != GRADING_SCHEMA_VERSION:
43+
sys.stderr.write(f"warning: {path} schema_version={found!r}, "
44+
f"expected {GRADING_SCHEMA_VERSION!r}.\n")
45+
46+
2847
# Skill discovery: each iteration directory carries a `skill.txt` or, failing
2948
# that, we try to pull it from the first grading file.
3049

@@ -58,7 +77,9 @@ def _load_iteration(iter_dir: Path) -> dict[str, dict]:
5877
gradings: dict[str, dict] = {}
5978
for path in sorted(cfg.glob("grading.*.json")):
6079
grader = path.stem.split(".", 1)[1]
61-
gradings[grader] = json.loads(path.read_text())
80+
payload = json.loads(path.read_text())
81+
_check_schema(path, payload)
82+
gradings[grader] = payload
6283
if responses or gradings:
6384
out[cfg.name] = {
6485
"responses": responses,

.claude/skills/_shared/scripts/preflight.sh

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ set -u
1919
JSON=0
2020
[[ "${1:-}" == "--json" ]] && JSON=1
2121

22-
# Locate repo root (the dir that contains scripts/doctor.sh).
22+
# Locate repo root. Prefer `git rev-parse` so moving this script up or down
23+
# a directory level does not silently break path arithmetic. Fall back to the
24+
# legacy 4-levels-up relative path when not in a git checkout (e.g. extracted
25+
# tarball, or running outside the repo).
2326
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24-
# .claude/skills/_shared/scripts/ -> repo root is 4 levels up.
25-
REPO_ROOT="$(cd "$HERE/../../../.." && pwd)"
27+
if command -v git >/dev/null 2>&1 \
28+
&& REPO_ROOT="$(git -C "$HERE" rev-parse --show-toplevel 2>/dev/null)" \
29+
&& [[ -n "$REPO_ROOT" ]]; then
30+
:
31+
else
32+
REPO_ROOT="$(cd "$HERE/../../../.." && pwd)"
33+
fi
2634

2735
# ---------------------------------------------------------------------------
2836
# Helpers
@@ -46,7 +54,9 @@ OS_KERNEL="$(uname -srm 2>/dev/null || echo unknown)"
4654
OS_ID=""
4755
OS_VERSION=""
4856
if [[ -f /etc/os-release ]]; then
57+
# shellcheck source=/dev/null
4958
OS_ID="$(. /etc/os-release && echo "${ID:-}")"
59+
# shellcheck source=/dev/null
5060
OS_VERSION="$(. /etc/os-release && echo "${VERSION_ID:-}")"
5161
fi
5262
CPU_COUNT="$(nproc 2>/dev/null || echo 0)"
@@ -194,8 +204,13 @@ BUILD_DIR_EXISTS=false
194204

195205
SUBMODULES_JSON='[]'
196206
if [[ -f "$REPO_ROOT/.gitmodules" ]] && command -v git >/dev/null 2>&1; then
207+
# Note: must use `python3 -c` rather than `python3 - <<HEREDOC` here,
208+
# because the heredoc redirect would override the piped stdin from
209+
# git submodule status and the script would never see any submodule
210+
# lines (silently emits '[]' regardless). Currently no submodules in
211+
# this repo, so the bug was latent until a future submodule lands.
197212
SUBMODULES_JSON=$(cd "$REPO_ROOT" && git submodule status 2>/dev/null \
198-
| python3 - <<'PY'
213+
| python3 -c '
199214
import json, sys
200215
out = []
201216
for line in sys.stdin:
@@ -211,8 +226,7 @@ for line in sys.stdin:
211226
"initialized": initialized,
212227
})
213228
print(json.dumps(out))
214-
PY
215-
)
229+
')
216230
fi
217231

218232
# ---------------------------------------------------------------------------

scripts/build_one_lib.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,21 @@ fi
8181
# Configure (only on first run, unless --reconfigure)
8282
if [[ ! -d "$BUILD" || $RECONFIGURE -eq 1 ]]; then
8383
echo "Configuring $LIB ($BUILD_TYPE) ..."
84+
if [[ $DO_TESTS -eq 1 ]]; then
85+
TESTS_FLAG="-DCUDAQX_INCLUDE_TESTS=ON"
86+
else
87+
TESTS_FLAG="-DCUDAQX_INCLUDE_TESTS=OFF"
88+
fi
89+
if [[ $NO_PYTHON -eq 1 ]]; then
90+
PYTHON_FLAG="-DCUDAQX_BINDINGS_PYTHON=OFF"
91+
else
92+
PYTHON_FLAG="-DCUDAQX_BINDINGS_PYTHON=ON"
93+
fi
8494
cmake -G Ninja -S "$SRC" -B "$BUILD" \
8595
-DCUDAQ_DIR="$CUDAQ_DIR_VAL" \
8696
-DCMAKE_INSTALL_PREFIX="$CUDAQX_INSTALL_PREFIX_VAL" \
8797
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
88-
$( [[ $DO_TESTS -eq 1 ]] && echo "-DCUDAQX_INCLUDE_TESTS=ON" || echo "-DCUDAQX_INCLUDE_TESTS=OFF" ) \
89-
$( [[ $NO_PYTHON -eq 1 ]] && echo "-DCUDAQX_BINDINGS_PYTHON=OFF" || echo "-DCUDAQX_BINDINGS_PYTHON=ON" )
98+
"$TESTS_FLAG" "$PYTHON_FLAG"
9099
fi
91100

92101
echo "Building $LIB ..."

0 commit comments

Comments
 (0)