Skip to content

Adds unit tests for @run, remote runner, and prereq checks#35

Merged
jeffcarp merged 6 commits intomainfrom
test/decorator-runner-cli
Feb 23, 2026
Merged

Adds unit tests for @run, remote runner, and prereq checks#35
jeffcarp merged 6 commits intomainfrom
test/decorator-runner-cli

Conversation

@JyotinderSingh
Copy link
Collaborator

No description provided.

@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 significantly enhances the test coverage and reliability of the keras_remote project by introducing a suite of new unit tests. These tests validate critical components such as CLI prerequisite checks, accelerator configuration parsing, the @run decorator's behavior, and the remote runner's GCS-based execution flow. Additionally, it sets up the testing infrastructure with necessary dependencies and configurations, ensuring a more robust development and deployment process.

Highlights

  • Prerequisite Checks Unit Tests: Added comprehensive unit tests for the prerequisites_check module, ensuring robust validation of required CLI tools like gcloud, Pulumi, Docker, and kubectl, and proper gcloud authentication flow.
  • Accelerator Configuration Unit Tests: Introduced new unit tests for the accelerators module, verifying the correct parsing and configuration of various GPU and TPU types, including multi-count, aliases, and topology handling.
  • @run Decorator and Environment Variable Capture Unit Tests: Implemented unit tests for the @run decorator and environment variable capture logic within the core module, confirming proper function wrapping, metadata preservation, and environment propagation (exact, wildcard, and mixed patterns).
  • Remote Runner Unit Tests: Developed unit tests for the remote runner's GCS integration, covering file download/upload, successful function execution, handling of function exceptions, and correct application of environment variables in a remote context.
  • Constants and Location Helpers Unit Tests: Added unit tests for the constants module, validating zone-to-region and zone-to-AR location conversions, and ensuring correct retrieval of default zone settings from environment variables or fallbacks.
  • Testing Infrastructure Setup: Updated pyproject.toml to include new test dependencies (pytest, pytest-cov, pytest-mock, pytest-timeout) and configured pytest to recognize test paths and define an e2e marker. New conftest.py files were created to provide shared pytest fixtures and implement logic for conditionally skipping end-to-end tests based on environment variables.

🧠 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
  • conftest.py
    • Added a new conftest.py file to the root directory.
    • Defined sample_function and gcp_env pytest fixtures for general testing.
  • keras_remote/cli/test_prerequisites_check.py
    • Added a new test file for prerequisites_check.
    • Included tests for checking the presence and absence of gcloud, Pulumi, kubectl, and Docker CLIs.
    • Added tests for check_gcloud_auth, verifying token success and login triggering.
  • keras_remote/conftest.py
    • Added a new conftest.py file within the keras_remote package.
    • Defined mock_storage_client, mock_kube_config, and mock_batch_v1 pytest fixtures for mocking cloud and Kubernetes interactions.
  • keras_remote/core/test_accelerators.py
    • Added a new test file for accelerators.
    • Included tests for parsing various GPU configurations (direct, multi-count, aliases) and handling invalid GPU counts.
    • Added tests for parsing various TPU configurations (bare, chip count, topology) and handling invalid TPU chips or topologies.
    • Included tests for CPU parsing, normalization, error handling, and category retrieval.
    • Added tests to ensure the integrity of the GPU and TPU registries.
  • keras_remote/core/test_core.py
    • Added a new test file for core.
    • Included tests for the @run decorator, verifying it preserves wrapped function metadata.
    • Added tests for environment variable capture, including exact matches, wildcard patterns, missing variables, and mixed patterns.
    • Included tests for _execute_on_gke defaults, verifying cluster and namespace retrieval from environment variables.
  • keras_remote/runner/test_remote_runner.py
    • Added a new test file for remote_runner.
    • Included tests for GCS download and upload helper functions.
    • Added tests for the run_gcs_mode function, covering successful execution, function exceptions, and environment variable application.
    • Included tests for the main function, verifying argument parsing and calls to run_gcs_mode.
  • keras_remote/test_constants.py
    • Added a new test file for constants.
    • Included tests for zone_to_region and zone_to_ar_location conversions.
    • Added tests for get_default_zone, verifying environment variable override and default fallback.
    • Included tests for DEFAULT_ZONE and DEFAULT_REGION constants.
  • pyproject.toml
    • Updated the [project.optional-dependencies] section to add a new test dependency group.
    • Added pytest, pytest-cov, pytest-mock, and pytest-timeout to the test dependency group.
    • Updated the dev dependency group to include keras-remote[test].
    • Updated [tool.ruff.lint.per-file-ignores] to add T201 ignore for test files.
    • Added [tool.pytest.ini_options] to specify testpaths and define an e2e marker.
  • tests/e2e/conftest.py
    • Added a new conftest.py file for end-to-end tests.
    • Implemented pytest_collection_modifyitems to skip e2e tests unless E2E_TESTS environment variable is set.
    • Defined gcp_project fixture to retrieve the GCP project from environment variables or skip if not set.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/tests.yaml
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
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

The pull request introduces a comprehensive suite of unit tests for the keras-remote package, covering accelerator parsing, the @run decorator, and the remote runner script. The tests are well-structured and leverage pytest and pytest-mock effectively to isolate components. I have provided some feedback regarding serialization consistency in the remote runner tests and a note on test isolation for sys.path modifications.

@JyotinderSingh JyotinderSingh force-pushed the test/decorator-runner-cli branch 2 times, most recently from df258fe to fdd538f Compare February 20, 2026 19:43
Tests cover:
- run() decorator behavior, env var capture (exact, wildcard, mixed)
- Remote runner GCS helpers, execution flow, and error handling
- CLI prerequisite checks for gcloud, pulumi, kubectl, docker, and auth
@JyotinderSingh JyotinderSingh force-pushed the test/decorator-runner-cli branch from fdd538f to 40d06f3 Compare February 21, 2026 02:26
@JyotinderSingh JyotinderSingh marked this pull request as ready for review February 21, 2026 02:27
@JyotinderSingh
Copy link
Collaborator Author

/gemini review

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

The pull request introduces comprehensive unit tests for the @run decorator, remote runner, and prerequisite checks. The tests are well-structured, cover various scenarios including environment variable capture, GCS interactions, and error handling, and demonstrate good use of mocking. The new test files significantly improve the test coverage and reliability of the keras_remote library.

@jeffcarp jeffcarp merged commit bf7094e into main Feb 23, 2026
4 checks passed
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.

2 participants