Repository navigation
fix(tests): isolate langfuse exporter reloads - #67
Conversation
Co-authored-by: TRAE CLI <[email protected]>
Co-authored-by: Enzo <[email protected]>
Closes #66. MockSlurmTool._load_json was annotated -> dict[str, Any], but three of the seven job_details.json corpus snapshots (env_04, env_09, env_19) are top-level lists; _job_details_method already branched on isinstance(..., list) to handle both, so the annotation was a false claim mypy accepted without checking. A single widened signature (dict[str, Any] | list[Any]) would not have worked on its own, since _query_jobs calls self._state.get("jobs", []) and list has no .get. Fixed with a @overload pair instead: a Literal["slurm/slurm_state.json"] overload keeps the state-snapshot load path typed as a mapping, and the general path returns the true dict | list union that job_details actually has. Runtime is unchanged by construction. Verified: focused SLURM suite 34 passed (including new parametrized regression tests pinning job_details shapes across env_01/04/09/19, all 25 state snapshots as mappings, and the missing-file case). Full suite: 1590 passed, 24 skipped. ruff clean. mypy: 1 pre-existing third-party stub gap, no new debt — `uv run python scripts/mypy_ratchet.py` reports OK. `aobench validate benchmark`: 88 tasks, 29 environments, corpus unchanged. Merged origin/main (PR #67) into the branch to resolve a CHANGELOG.md conflict and re-verified the full suite green on the merged tree. All CI checks green on the final head SHA (4d0f709), including CodeQL. AI assistance (Codex) was disclosed by the contributor per CONTRIBUTING.md.
|
Thanks, @motodriver — merged as ef588e8. Your diagnosis was exactly right: the module was getting imported inside the I verified it directly: reverted your change locally and confirmed You're in Appreciate the honesty in the PR description about the AI assistance — that's exactly the kind of disclosure If AOBench is useful to you, a ⭐ — or passing it to someone it would help — genuinely helps with visibility. Entirely optional, and thanks again for closing out #65. |
Summary
Closes #65.
This keeps
tests/unit/test_langfuse_exporter.pyfrom evictingaobench.exporters.langfuse_exporterout ofsys.modulesduringpatch.dict(sys.modules, ...)blocks. The tests now import the module once at module scope and only reload it inside the patched contexts, so the mockedlangfusedependency is still exercised without breaking later reloads.Substantial AI assistance (TRAE) was used to help draft and verify this change. I reviewed the final patch and validation results before opening the PR.
Type of change
Checklist
make checkpasses locally (lint + type-check + tests).aobench validate benchmarkpasses (if I touched tasks or environments).docs// CLI reference) where behavior changed.CHANGELOG.mdupdated under[Unreleased].Notes for reviewers
uv run python -m pytest tests/unit -k tool -quv run python -m pytest tests/unit/test_langfuse_exporter.py -qmake check