Repository navigation
refactor(e2e): simplify test helpers and fix redundant HF_HOME env passing - #688
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on refining and simplifying the end-to-end test suite. It streamlines test code by introducing a shared helper function, corrects an issue with redundant environment variable passing in Docker, and removes unnecessary code logic, ultimately improving maintainability and clarity of the test infrastructure. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughHF_HOME is no longer forwarded into the Docker test container and proc cleanup code is simplified in benchmark setup; realtime WebSocket tests consolidate repeated user-message payloads into a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
…ssing - Extract _make_user_message() helper in test_realtime_ws.py to replace 7 copy-pasted conversation.item.create dict structures, reducing ~70 lines of boilerplate - Remove "HF_HOME" from the env-var pass-through tuple in benchmarks/conftest.py — it was already explicitly set on line 61 when mounting the HF cache directory, causing the variable to be passed twice to Docker - Simplify redundant hasattr+getattr guard in _cleanup_procs() to plain getattr with default, since getattr(p, "proc", p) already handles the missing attribute case Refs: #686 Signed-off-by: Simo Lin <linsimo.mark@gmail.com>
b373337 to
7ba8106
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces several good refactorings that simplify the e2e test code and fix a minor correctness issue. Extracting the _make_user_message helper in test_realtime_ws.py significantly reduces code duplication. The fixes in conftest.py for the redundant HF_HOME environment variable and the unnecessary hasattr check are also clean and correct. I have one suggestion to further improve the new helper function by using constants for protocol strings to enhance maintainability.
Summary
Follow-up cleanup to #686. Simplifies e2e test code by extracting a shared helper, fixing a redundant Docker env-var pass, and removing a dead code guard.
What changed
e2e_test/realtime/test_realtime_ws.py: Extracted_make_user_message(text)helper to replace 7 identical copy-pastedconversation.item.createdict structures (~70 lines removed).e2e_test/benchmarks/conftest.py:64: Removed"HF_HOME"from the env-var pass-through tuple. The HF cache mount block on line 61 already explicitly passes-e HF_HOME={hf_home}when the directory exists, so the loop entry was redundant and could theoretically set a conflicting value.e2e_test/benchmarks/conftest.py:154: Simplifiedgetattr(p, "proc", p) if hasattr(p, "proc") else ptogetattr(p, "proc", p)— thehasattrguard was redundant sincegetattrwith a default already handles the missing attribute case.Why
Reduces copy-paste boilerplate in the realtime WebSocket tests and fixes a minor correctness issue where
HF_HOMEcould be passed twice to Docker with potentially different values.How
_make_user_message(text)helper that wraps theconversation.item.createevent structure, then replaced all 7 inline usages.("HF_TOKEN", "HF_HOME")to("HF_TOKEN",).hasattrcheck beforegetattrwith a default value.Test plan
python3 -c "import ast; ast.parse(open('e2e_test/realtime/test_realtime_ws.py').read())"— syntax OKpython3 -c "import ast; ast.parse(open('e2e_test/benchmarks/conftest.py').read())"— syntax OKHF_TOKEN;HF_HOMEstill passed via the explicit mount blockRefs: #686
Summary by CodeRabbit
Release Notes