-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(ai): Add retry mechanism to flakey interrupt test #15421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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. |
FirebaseAI/Tests/TestApp/Tests/Utilities/IntegrationTestUtils.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a retry mechanism to handle a flaky interrupt test, which is a good approach to improve test stability. The implementation of the retry
utility function is solid, though I have a couple of minor suggestions to enhance its robustness. The main feedback is on the usage of this new retry
function in LiveSessionTests.swift
, where the current implementation doesn't correctly trigger retries on failure and could be more efficient by moving pre-test checks outside the retry loop. The suggested changes aim to make the retry logic work as intended.
FirebaseAI/Tests/TestApp/Tests/Integration/LiveSessionTests.swift
Outdated
Show resolved
Hide resolved
FirebaseAI/Tests/TestApp/Tests/Utilities/IntegrationTestUtils.swift
Outdated
Show resolved
Hide resolved
FirebaseAI/Tests/TestApp/Tests/Utilities/IntegrationTestUtils.swift
Outdated
Show resolved
Hide resolved
…swift Co-authored-by: Andrew Heard <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a retry
utility function to handle a flaky interrupt test, which is a good approach to improve test stability. The implementation of the retry
function is solid, and its application in realtime_interruption
is correct. I've added a couple of minor suggestions for code improvements, one related to using a more idiomatic Swift precondition check and another to improve the structure of the test code by moving a local type definition out of a loop. Overall, these are good changes that should help with the test flakiness.
FirebaseAI/Tests/TestApp/Tests/Integration/LiveSessionTests.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please address the Gemini NoInterruptionError
recommendation. I think the precondition
one is super low priority.
Thanks for adding this! Eventually I'd like to refactor this as a a Swift Testing Trait
but I've never had time to fully investigate and this approach should work just as well for our needs right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
The interrupt test is flakey, as it relies on a bit of timing. If the network is having issues, the model may finish generating and processing data before the client has time to interrupt. To help circumvent this, I've implemented a retry function for retrying the test
3
times, with a2
second delay between each attempt.There may be a better solution though, such as a longer audio clip (to give us more time), or some form of system instructions. If this test continues to be flakey, even under the retry infrastructure, then we may want to explore said alternatives.
#no-changelog