Repository navigation
Conversation
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR cleanly resolves a test flake in InteractiveBeamComputeTest caused by test_async_computation_result_cancel leaking a 100s background execution thread into subsequent tests. By synchronizing on _execute_pipeline_fragment with threading.Event and ensuring isolated_env.setUp initializes return_value atomically when patching ie.current_env, cross-test state contamination is prevented.
🔍 General Feedback
- The synchronization pattern using
started_eventandrelease_eventwith cleanup in afinallyblock makes the cancellation test deterministic and eliminates the arbitrarytime.sleepdelays. - Guarding
self._cancel_buttonagainstNoneinAsyncComputationResult.cancel()properly handles non-IPython environments whenIS_IPYTHONisFalse.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR resolves a flaky test failure in InteractiveBeamComputeTest caused by test_async_computation_result_cancel leaking a 100-second background thread into subsequent tests. The fix cleanly replaces the time.sleep(100) pipeline execution with a synchronized mock of _execute_pipeline_fragment that is properly joined in a finally block, while also closing a brief mock initialization window in isolated_env.setUp and guarding _cancel_button access when IS_IPYTHON is false.
🔍 General Feedback
- Using
threading.Eventprimitives (started_eventandrelease_event) paired withwait_for_completioninfinallymakestest_async_computation_result_canceldeterministic and eliminates cross-test interference. - Passing
return_value=self.current_envdirectly topatch(...)inmock_env.pypreventsie.current_env()from briefly returning an unconfiguredMagicMockduringsetUp.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41207 +/- ##
============================================
- Coverage 59.25% 59.15% -0.11%
Complexity 4894 4894
============================================
Files 1461 1461
Lines 186046 186051 +5
Branches 3648 3648
============================================
- Hits 110244 110059 -185
- Misses 72445 72635 +190
Partials 3357 3357
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…for_completion
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR resolves a test flake in InteractiveBeamComputeTest where test_async_computation_result_cancel leaked a background pipeline execution thread running time.sleep(100) into subsequent tests. By mocking RecordingManager._execute_pipeline_fragment with a short sleep and awaiting completion before the test exits, the change cleanly eliminates cross-test pollution of the global InteractiveEnvironment.
🔍 General Feedback
- The root cause analysis and fix are spot-on. Mocking
_execute_pipeline_fragmentand explicitly callingwait_for_completionensures deterministic cleanup of the background worker thread beforeisolated_envtears down the test environment.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Fixes a flaky failure in
InteractiveBeamComputeTest.test_compute_blocking(ValueError: All PCollections must belong to the same pipeline.) inPostCommit Python Versions(run 42902232829).Root Cause
In
InteractiveBeamComputeTest.test_async_computation_result_cancel,ib.compute(pcoll, blocking=False)launched a real background thread inRecordingManager._executorrunningtime.sleep(100)onDirectRunner, while the test exited after ~1.1s without waiting for the background thread to finish. Then, the leaked background thread fromtest_async_computation_result_cancelcontinued executing during the subsequenttest_compute_blockingtest and mutatedtest_compute_blocking'sInteractiveEnvironment/ pipeline tracker.Changes
InteractiveBeamComputeTest.test_async_computation_result_cancel, mockRecordingManager._execute_pipeline_fragmentwithside_effect=lambda *args: time.sleep(2)(matchingtest_compute_multiple_asyncbelow it) and callasync_result.wait_for_completion(timeout=5)at the end of the test so no background thread or 100s pipeline execution leaks into subsequent tests.Verification
beam_PostCommit_Python_Versions.ymlworkflow run on branch:43090965770