Repository navigation
audit: drop dead utils imports from system_evaluator (nightly) - #496
haiyuan-eng-google merged 1 commit into
Conversation
Remove two unreferenced imports (_parse_json_from_text, strip_markdown_fences) flagged by ruff F401 and confirmed with a repo-wide grep: the only occurrences in system_evaluator.py are the import lines; no __all__, star-import, sys.modules alias, dotted-path, docs, notebook, entry-point, or mock.patch reference remains. The identical-looking bindings in performance_evaluator.py are intentionally kept: trace_evaluator.py aliases that module and test_trace_shim_preserves_public_and_private_exports pins the namespace. Canonical homes (utils.*) and the evaluators.py compat re-export are untouched. No behavior or public API change. Baseline: a51c39a Tests: focused 144 passed; full suite 5342 passed, 65 skipped (6 failed + 5 collection errors are pre-existing env issues, identical on baseline).
caohy1988
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Independent blind review by Astra (Codex), on caohy1988's behalf. Reviewed tip 2e2d0eeadc351470d920639f266b43aad2d5dc00 against base a51c39a2dfaa6d863a0e16597f7b1b191b86effb. This is a COMMENT review.
Findings
- P0: None.
- P1: None.
- P2: None. No fixes requested.
Evidence
- The only change deletes the two imports at src/bigquery_agent_analytics/system_evaluator.py:40–41 (base), plus a blank line. An AST comparison confirms everything else is identical. GitHub's file contents match the local file byte-for-byte.
- Independent repository-wide
rgsearches found neither helper used throughsystem_evaluator: no direct import, dotted reference, wildcard import, patch target,getattrdependency, documentation reference, or entry point. This module has no__all__, dynamic export hook, orsys.modulesalias. In the base file, each helper appears only on its removed import line. - Canonical definitions remain at utils.py:22 and :42. Compatibility imports and the public
strip_markdown_fencesexport remain at evaluators.py:27–47. The performance/trace namespace compatibility is preserved, including the identities asserted at tests/test_pr123_performance_regressions.py:350–374. - The one-file cleanup is appropriately scoped. No obvious additional dead code in the touched module needs inclusion. No behavior regression or supported API break found.
Validation
Local Python 3.13.5:
PYTHONDONTWRITEBYTECODE=1 python3 -m pytest -p no:cacheprovider \
tests/test_system_evaluator.py tests/test_evaluators.py \
tests/test_pr123_legacy_regressions.py \
tests/test_pr123_performance_regressions.py --tb=short -q
144 passed, 2 deprecation warnings in 3.95s
These tests directly exercise the touched module: tests/test_system_evaluator.py:31–51. Legacy shared-symbol identities and wildcard exports are checked at tests/test_pr123_legacy_regressions.py:72–80.
Touched-file checks passed: pyink --check (25.12.0, <26), isort --check-only (8.0.0), and ruff check --no-cache (0.11.2). git diff --check passed; worktree remains clean. The full suite was not rerun locally.
CI is green: Python 3.10–3.14, format, browser smoke, and package build passed. CLA, change detection, and scan-pr passed; four conditional zizmor jobs were skipped. No pending or failed checks at final verification.
Blindness: no vault files, shared peer artifacts, or existing PR #496 reviews/comments were read. Sources were the allowed PR descriptions/diffs/files, CI status, and this worktree. The allowed #490 diff included historical #486 review references; no PR #496 peer-review material was encountered. No branch modifications, push, or merge.
caohy1988
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Blind review (Fable / Claude, on caohy1988's behalf) of tip 2e2d0ee vs base a51c39a, done in a fresh worktree without reading other reviews. I re-verified every dead-ness claim myself with rg; the 3-line deletion is correct, scoped, and behavior-neutral. Nothing blocking. Posted as COMMENT per the dual-review protocol.
P0 — none
P1 — none
P2 — non-blocking, all outside the diff
-
src/bigquery_agent_analytics/performance_evaluator.py:59and:61are shim-only imports with no in-code marker._extract_json_from_text(:59) andstrip_markdown_fences(:61) have zero body uses (only_parse_json_from_textat :60 is actually called, at :1024/:1125/:1174), soruff check --select F401still flags both, andruff --fixwould delete exactly those two lines and breaktests/test_pr123_performance_regressions.py:350(test_trace_shim_preserves_public_and_private_exports, names pinned at :369-371 through thetrace_evaluator.py:25sys.modulesalias). This PR's description records why they are kept, but the next nightly will only see the linter output. Suggested fix (2 lines; fine to ride in this PR or the next one), mirroring the existing convention atsrc/bigquery_agent_analytics/runtime_spec.py:59:from bigquery_agent_analytics.utils import _extract_json_from_text # noqa: F401 – re-exported via trace_evaluator shim; pinned by test_trace_shim_preserves_public_and_private_exports from bigquery_agent_analytics.utils import strip_markdown_fences # noqa: F401 – same
Nit: the commit message's "identical-looking bindings in performance_evaluator.py are intentionally kept" slightly over-states; :60 is a real use, only :59/:61 are shim-only.
-
Same-class leftovers the same tool finds (candidates for the next nightly, not this PR).
ruff check --select F401 src/bigquery_agent_analytics/at HEAD, ignoring__init__.pyre-export blocks and try/except availability probes, still lists ~21 auto-fixable hits, e.g.feedback.py:34-36(dataclass,field,json),feedback.py:691(google.cloud.bigquery),insights.py:40/42/45(asyncio,dataclass,json),eval_validator.py:36(field),ai_ml_integration.py:62(timedelta),cli.py:197(ResolvedGraph),ontology_materializer.py:79(ResolvedProperty),extractor_compilation/diagnostics.py:75andontology_models.py:42(Any),extractor_compilation/measurement.py:52(CompileResult). Each needs the same namespace check this PR did. Two I checked are load-bearing and must not be auto-fixed:ontology_models.py:169-172(Extracted*re-exports consumed bytests/test_extracted_models.py:22-25) andperformance_evaluator.py:59/61(item 1).client.py:86(_AI_GENERATE_JUDGE_BATCH_QUERY_TEMPLATE as AI_GENERATE_JUDGE_BATCH_QUERY) is undecided: there is no in-repo consumer ofclient.AI_GENERATE_JUDGE_BATCH_QUERY(tests import it fromevaluators,tests/test_system_evaluator.py:24), but it is an un-underscored name on theclientnamespace, so triage it as a possible compat alias rather than a mechanical delete. -
No CI gate for unused imports.
.github/workflows/ci.yml:53-59(Format check) installs only pyink + isort and runsautoformat.sh+git diff --exit-code; no workflow runs ruff/pyflakes/vulture, which is how #490 missed these two lines in the very block it edited. Once item 2 is cleaned, consider addingruff check --select F401 src/to the Format job with[tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"]inpyproject.toml, so this is the last manual sweep. Separate PR is fine. -
Docs, pre-existing drift, FYI only.
SDK.md:2672listssystem_evaluator.pyunder "Standalone modules (no internal imports)"; this PR makes that true again (baseline had the two.utilsimports).SDK.md:2685"insights.py → system_evaluator" is stale independent of this PR (insights.py:52imports from.evaluators).
What I verified
- Dead-ness (rg, all file types, whole repo): no
system_evaluator._parse_json_from_text/.strip_markdown_fences; nofrom …system_evaluator importof either name; no__all__in the file; noimport *of the module; nosys.modulesalias forsystem_evaluator(onlytrace_evaluator.py:25→performance_evaluator); nomock.patch/getattrtargets; nothing indocs/,SDK.md,README.md,examples/,scripts/,plugins/, notebooks, or[project.scripts].docs/design.md:1429defines the helper generically without attributing it to this module. Module importers pull onlyCodeEvaluator/EvaluationReport/SessionScore/SystemEvaluator/SESSION_SUMMARY_QUERY(client.py:117-120,aggregate_grader.py:53,evaluators.py:27-31,__init__.py:109-112;tests/test_pr123_legacy_regressions.py:74-78getattr's only the three report/SQL names;test_evaluators.py:26,test_system_evaluator.py:31-32,test_sdk_client.py:1048,test_pr123_client_regressions.py:32). - In-file: no
json/re/ fence / parse code anywhere insystem_evaluator.py(every hit is docstring prose); every remaining import is used;ruff check --select Fclean at HEAD; baselinea51c39atrips exactly the two F401s at old lines 40-41.git log -Sshows both imports arrived inf5e03bd(#123) with no call site ever, so they were dead since birth; #490's hunk removedudf_kernelsfrom the same block and left them. - Canonical homes / compat intact:
utils.py:22and:42definitions;evaluators.py:32-33re-export from.utilswithstrip_markdown_fencesin__all__(:47), asserted bytest_pr123_legacy_regressions.py:80;performance_evaluator.py:59-61untouched. Public surface ofbigquery_agent_analyticsandevaluatorsis unchanged; the only observable delta ishasattr(system_evaluator, <name>)flipping to False for two never-documented helpers with zero consumers. - Tests (local, this worktree, HEAD, Python 3.13.5):
pytest tests/test_system_evaluator.py tests/test_evaluators.py tests/test_pr123_legacy_regressions.py tests/test_pr123_performance_regressions.py tests/test_pr123_client_regressions.py tests/test_categorical_evaluator.py→ 331 passed, 0 failed. Env note only: the shared.venvhas a stalebigquery_agent_analytics-0.2.3.dist-infowith no METADATA (makes_telemetry._read_version()raiseTypeError) and lackspytest_asyncio(54 async collection failures); both are pre-existing and identical on baseline, worked around with a /tmp dist-info shim + /tmp plugin target, no repo files touched. - Format / lint:
ruff check --select F401clean;isort --check-only(google profile) clean;pyink --checkclean on both 24.8.0 (pyink<26, as CI pins) and 25.12.0. - CI: run 36235576070 — Format check, Test (3.10 / 3.11 / 3.12 / 3.13 / 3.14), Build package, Configurator browser smoke, scan-pr, cla/google all pass; zizmor jobs skipped by path filter.
- Scope: one file, 3 deletions, no unrelated changes; no CHANGELOG entry needed, matching the #490 precedent for no-behavior-change audit PRs.
a2a1d90
into
GoogleCloudPlatform:main
…st (#501) * chore(release): 0.5.4 — compaction_windows view, smoke-test unpickling allowlist Bump the version to 0.5.4 and cut the CHANGELOG for the ten PRs merged since v0.5.3 (#490–#497, #499, #500). [Unreleased] is left empty; the #494 entry moves into [0.5.4]. * docs(changelog): tighten 0.5.4 compatibility notes List every incidental name #490/#496 removed and where each lives now, fix the permission repair to `chmod go-w`, scope the log-dir symlink rule to logs outside the state directory, and qualify the tracing checks' platform fallbacks. * chore(release): date 0.5.4 for 2026-09-29
Import-line deletions only; no logic, signature or public API change. Every removed name is flagged by `ruff check --select F401` and has no reference anywhere in the tracked tree: no from-import, attribute access, mock.patch / monkeypatch / getattr target, or mention in docs, notebooks, deploy/ or producers/. None of the touched modules defines __all__, is star-imported, or is aliased through sys.modules. Removed: - ai_ml_integration.py: datetime.timedelta - cli.py: function-local resolved_spec.ResolvedGraph in _load_spec_from_args - eval_validator.py: dataclasses.field - extractor_compilation/diagnostics.py: typing.Any - extractor_compilation/measurement.py: .compiler.CompileResult (the package __init__ still imports .compiler first) - feedback.py: dataclasses.dataclass, dataclasses.field, json, and a function-local google.cloud.bigquery import - insights.py: asyncio, dataclasses.dataclass, json - ontology_materializer.py: resolved_spec.ResolvedProperty - ontology_models.py: typing.Any - ttl_importer.py: rdflib.XSD (the remaining rdflib imports still gate _RDFLIB_AVAILABLE) - bigquery_ontology/graph_ddl_compiler.py: binding_models.PropertyBinding Kept on purpose although ruff flags them: - performance_evaluator.py utils imports: re-exported through the trace_evaluator shim and asserted by test_trace_shim_preserves_public_and_private_exports - ontology_models.py extracted_models imports: re-exports - client.py AI_GENERATE_JUDGE_BATCH_QUERY: compat alias from #123, named in docs/design.md - package __init__ re-exports Follow-up to #490 and #496. vulture did not report these because it counts a name as used when any other module uses it; ruff F401 checks each file.
What was removed
Two unreferenced imports from
src/bigquery_agent_analytics/system_evaluator.py(pure 3-line deletion, no logic touched):from .utils import _parse_json_from_text(was line 40)from .utils import strip_markdown_fences(was line 41)Follow-up to #490, which removed the
udf_kernelsimport from this same file but missed these two.rg evidence per symbol
Both flagged by
ruff check --select F401; confirmed dead repo-wide:grep -n "_parse_json_from_text\|strip_markdown_fences" src/bigquery_agent_analytics/system_evaluator.py→ only the two import lines (count = 2, no other use in the file).__all__insystem_evaluator.py; nosystem_evaluator import *anywhere.sys.modulesalias forsystem_evaluator(onlyperformance_evaluatorhas one, viatrace_evaluator.py).system_evaluator._parse_json_from_text/system_evaluator.strip_markdown_fences) in any.py/.md/.ipynb/.rst/.txt.mock.patch/getattrtargets on these paths intests/orsrc/; no test asserts their presence on thesystem_evaluatornamespace (the legacy-compat test only pinsSessionScore/EvaluationReport/SESSION_SUMMARY_QUERYidentity).strip_markdown_fencesis not mentioned inSDK.md/docs//README.md; no pyproject entry point touches these symbols.utils.strip_markdown_fences,utils._parse_json_from_text, plus theevaluators.pycompat re-export (strip_markdown_fencesinevaluators.__all__).Explicitly NOT removed: the identical-looking bindings in
performance_evaluator.pyare load-bearing —trace_evaluator.pydoessys.modules[__name__] = performance_evaluatorandtest_trace_shim_preserves_public_and_private_exportsassertsgetattridentity for_extract_json_from_text,_parse_json_from_text, andstrip_markdown_fenceson that namespace.Also scanned and rejected (not dead): vulture 100%-confidence hits
memory_service.py:1034 app_name(ADKBaseMemoryService.search_memoryoverride signature) andtrace.py:1057 memo(__deepcopy__protocol signature).Tests run
pytest tests/test_system_evaluator.py tests/test_evaluators.py tests/test_pr123_legacy_regressions.py tests/test_pr123_performance_regressions.py→ 144 passed both times.git stash— pre-existing environment issues, zero regressions from this change.ruff check --select F401on the touched file: clean.isort --check-onlyandpyink --check(25.12, < 26 per CI): clean.No behavior or public API change. Ready for review (Astra + Fable).