Adds automated login + credential setup for @run()#50
Conversation
Summary of ChangesHello @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 user experience for 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 significantly improves the user experience by automating credential setup for remote execution. The introduction of the keras_remote/credentials.py module centralizes and streamlines the verification and auto-configuration of gcloud CLI, gke-gcloud-auth-plugin, GCP Application Default Credentials, and Kubeconfig. This change effectively removes the need for manual keras-remote up execution for credential setup, addressing a key pain point. The refactoring of prerequisites_check.py to delegate common checks to the new module, along with the removal of the Docker prerequisite and auth steps, simplifies the CLI logic. The documentation (AGENTS.md) has been appropriately updated to reflect these architectural changes. Overall, this is a well-implemented and valuable enhancement.
Integrate credential auto-setup into
remote.run()Problem
Users with GCP IAM access to an existing cluster cannot use
@keras_remote.run()directly without first runningkeras-remote up. Theupcommand is the only path that configures the three credential types needed by the execution pipeline:~/.kube/config): job submission, status polling, log streamingWithout these,
remote.run()fails with opaque errors.Solution
Add a shared
credentials.pymodule that verifies and auto-configures all required credentials at the start ofexecute_remote(), before any work begins. Each check is idempotent, if credentials are already valid, it's a no-op.shutil.which("gcloud")shutil.which(...)gcloud components install --quietgcloud auth application-default print-access-tokengcloud auth application-default loginconfig.list_kube_config_contexts()— validates active context matchesgke_{project}_{zone}_{cluster}gcloud container clusters get-credentialsThe kubeconfig check validates the active context points to the correct cluster, not just that some kubeconfig exists.
Changes
keras_remote/credentials.pyis the shared credential verification module withensure_credentials()entry point and individualensure_*functions. UsesRuntimeError(no click dependency) so it works from both the programmatic API and CLI.keras_remote/backend/execution.pycallsensure_credentials()at the top ofexecute_remote(). Also removes the unusedBackendClientProtocol in favor ofBaseK8sBackendbase class withNotImplementedErrorstubs.keras_remote/cli/prerequisites_check.pyrefactored to delegate common checks (gcloud, auth plugin, ADC) to the shared module, wrappingRuntimeErrorintoclick.ClickException. CLI-only checks (Pulumi, kubectl) unchanged. Removed Docker prerequisite check (not needed — container builds use Cloud Build).AGENTS.mdto reflect new module, execution pipeline step, andBaseK8sBackendreplacingBackendClient.