fix(cicd): defer pytest import so oaeval works on a clean install - #253
Merged
himanshu231204 merged 2 commits intoJul 29, 2026
Merged
Conversation
Move the pytest import out of module scope so the oaeval CLI can start on a clean install that does not include pytest. Co-Authored-By: Kimi K2.7 Code <noreply@kimi.com>
|
🎉 Congratulations @Nitjsefnie! Your pull request has been successfully merged into main. 🚀 Thank you for contributing to OpenAgentHQ and helping improve the project. We truly appreciate your contribution and hope to see you back with more amazing PRs! Happy Open Sourcing! ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
oaevaldies on any clean install because the CLI import chain reaches a module-levelimport pytest, and pytest is a dev dependency rather than a runtime one.The chain, traced on current
main:In a virtualenv carrying the runtime dependencies but not pytest,
oaeval --helpraisesModuleNotFoundError: No module named 'pytest'before printing anything. The import is now deferred into the plugin entrypoints that actually run under pytest, so the module imports cleanly without it.This still reproduces at 0.4.8, not only at the 0.4.6 the issue was reported against — the post-fix run below reports
openagent-eval 0.4.8.Type of Change
Related Issues
Closes #227
How Has This Been Tested?
Reproduced first, then fixed. In a virtualenv with the runtime dependencies and no pytest:
After the change, same virtualenv:
Added
tests/unit/test_cicd/test_no_pytest_import.py— two subprocess-based tests that blockpytestinsys.modulesand assert thatopenagent_eval.cicd.OAEvalPluginandopenagent_eval.cli.main.appimport cleanly and thatoaeval --helpsucceeds. Subprocess rather than in-process, because the import has already happened by the time an in-process test runs.uv run pytest) — 975 passed, 4 skipped ontests/unit; 54 passed ontests/integration; full run with coverage 1029 passed, 79.61% against the 75% floor. The plugin behaves identically with pytest present.uv run ruff check .) — exits 1 on 229 pre-existing findings repo-wide.plugin.pycarries the same two findings on this branch as onmain(UP035,B904, shifted one line by the added import); the new test file has none. Zero new findings.uv run mypy openagent_eval/) — see Additional Notes.uvx --from build python -m buildanduvx --from twine twine check dist/*both pass.Checklist
Additional Notes
Why lazy rather than declaring pytest a runtime dependency. #227 offers both. Making a test framework a hard runtime requirement of an evaluation library, to satisfy an optional CI-integration module, seemed the wrong trade — it lands in every user's install to serve a path most never touch. Happy to switch if you'd prefer the dependency.
Adjacent, not fixed:
openagent_eval/cicd/__init__.py:14still eagerly importsOAEvalPlugin, so importing anything fromopenagent_eval.cicdpulls the plugin module in. That is harmless now the pytest import is deferred, but it means any future optional CI-only dependency added toplugin.pyreintroduces exactly this class of failure. Left alone as out of scope.Bug discovered while running your CI commands: #250 — CI type-check step targets a non-existent src/ directory, so mypy has never run on the package. It is why the type-checker box above is unticked; this PR template's own checklist already names the correct path.
Generated by Claude Opus 5 (brief, review), Kimi K2.7 Code (implementation)