Skip to content

Adds test infrastructure and a few tests#33

Merged
jeffcarp merged 6 commits intomainfrom
test/foundation
Feb 20, 2026
Merged

Adds test infrastructure and a few tests#33
jeffcarp merged 6 commits intomainfrom
test/foundation

Conversation

@JyotinderSingh
Copy link
Collaborator

@JyotinderSingh JyotinderSingh commented Feb 20, 2026

  • Adds pytest, pytest-cov, pytest-mock, pytest-timeout as test dependencies
  • Adds [test] extra and updates [dev] extra to include it
  • Adds pytest configuration and ruff ignores for test files
  • Adds GitHub Actions workflow for running tests on PRs
  • Adds shared scaffolding for other test branches to build on top of.

- Adds pytest, pytest-cov, pytest-mock, pytest-timeout as test dependencies
- Adds [test] extra and updates [dev] extra to include it
- Adds pytest configuration and ruff ignores for test files
- Adds GitHub Actions workflow for running tests on PRs
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @JyotinderSingh, 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 establishes a foundational testing framework for the project by integrating pytest and related tools. It introduces a structured approach to writing unit, integration, and end-to-end tests, complete with shared fixtures and configuration. The changes also include initial test cases for accelerator parsing and constant helper functions, significantly improving code reliability and maintainability.

Highlights

  • Test Infrastructure Setup: Added pytest, pytest-cov, pytest-mock, and pytest-timeout as new test dependencies, creating a dedicated [test] extra and including it in the [dev] extra.
  • Pytest Configuration: Configured pytest to discover tests in both keras_remote and tests directories, and defined an e2e marker for end-to-end tests.
  • Ruff Linter Configuration: Added ruff linter ignores for test files (**/test_*.py and tests/*) to prevent specific warnings in test code.
  • Shared Test Fixtures: Introduced keras_remote/conftest.py and tests/conftest.py to provide shared pytest fixtures, including a sample function, GCP environment variables, and mocks for Google Cloud Storage and Kubernetes clients.
  • Accelerator Parsing Tests: Added comprehensive unit tests in keras_remote/core/test_accelerators.py to validate the parsing logic for GPU and TPU configurations, including direct parsing, multi-count scenarios, aliases, error handling, and registry integrity.
  • Constants Helper Tests: Implemented unit tests in keras_remote/test_constants.py for utility functions related to zone, region, and location helpers, ensuring correct conversion and default value retrieval.
  • E2E Test Management: Created tests/e2e/conftest.py to conditionally skip end-to-end tests unless the E2E_TESTS environment variable is set, and to provide a gcp_project fixture.

🧠 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
  • keras_remote/conftest.py
    • Added shared pytest fixtures for unit tests, including sample_function, gcp_env, mock_storage_client, mock_kube_config, and mock_batch_v1.
  • keras_remote/core/test_accelerators.py
    • Added extensive unit tests for the parse_accelerator function, covering GPU and TPU parsing, multi-count configurations, aliases, error conditions, and registry integrity checks.
  • keras_remote/test_constants.py
    • Added unit tests for zone_to_region, zone_to_ar_location, and get_default_zone functions, including parameterized tests for various inputs and environment variable handling.
  • pyproject.toml
    • Added pytest, pytest-cov, pytest-mock, and pytest-timeout to a new [test] dependency group.
    • Updated the [dev] dependency group to include keras-remote[test].
    • Configured ruff to ignore specific linter rules for test files (**/test_*.py and tests/*).
    • Added [tool.pytest.ini_options] to define test paths and register an e2e marker.
  • tests/conftest.py
    • Added shared pytest fixtures for integration and e2e tests, including sample_function and gcp_env.
  • tests/e2e/conftest.py
    • Added pytest_collection_modifyitems hook to skip e2e tests by default unless E2E_TESTS environment variable is set.
    • Added gcp_project fixture to retrieve the GCP project from an environment variable, skipping if not set.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/tests.yaml
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 lays a solid foundation for testing by adding pytest dependencies, configuration, and several new test files. My review focuses on improving the developer experience with dependency management, fixing a configuration detail, and promoting best practices for writing maintainable and robust tests. I've identified a few areas for improvement:

  • Correcting the dev dependencies in pyproject.toml to work smoothly with local editable installs.
  • Fixing a glob pattern in the ruff configuration to ensure it applies recursively.
  • Removing duplicated test fixtures by using pytest_plugins for better maintainability.
  • Improving the logic for skipping E2E tests to use pytest markers instead of file paths, which is more robust.

@JyotinderSingh JyotinderSingh changed the title Adds test infrastructure and few tests Adds test infrastructure and a few tests Feb 20, 2026
@jeffcarp
Copy link
Member

Thanks!

@jeffcarp jeffcarp merged commit 9b90efb into main Feb 20, 2026
3 checks passed
@JyotinderSingh JyotinderSingh deleted the test/foundation branch February 20, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants