Skip tests not for sparsecore in setUp instead of the decorator.#184
Skip tests not for sparsecore in setUp instead of the decorator.#184hertschuh merged 1 commit intokeras-team:mainfrom
setUp instead of the decorator.#184Conversation
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 refactors the test skipping mechanism for JAX-related tests, specifically those dependent on SparseCores. The change addresses an issue where Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors how tests are skipped when SparseCores are not available by moving the check from a decorator to the setUp method. This is a good change to avoid issues with decorator evaluation time. However, the change is applied inconsistently. StackedTableInitializerTest also requires SparseCores but is missing the setUp method, which will cause test failures on environments without them. I've added a comment with a fix.
| reason="Requires SparseCores", | ||
| ) | ||
| @pytest.mark.skipif(keras.backend.backend() != "jax", "JAX backend required.") | ||
| class StackedTableInitializerTest(parameterized.TestCase): |
There was a problem hiding this comment.
This test class requires SparseCores because its tests call jte_utils.num_sparsecores_per_device(), which will raise an error if SparseCores are not available. To align with the goal of this PR, you should add a setUp method to skip these tests, similar to the implementation in DistributedEmbeddingLayerTest.
class StackedTableInitializerTest(parameterized.TestCase):
def setUp(self):
super().setUp()
if not jax_distributed_embedding.DistributedEmbedding.has_sparsecores():
self.skipTest("Requires SparseCores")Decorators are evaluated before the unit tests are run and JAX may not be available.
Decorators are evaluated before the unit tests are run and JAX may not be available.