Skip to content

Conversation

jinnthehuman
Copy link

… (#151)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jinnthehuman, 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 adds a crucial integration test to validate the end-to-end execution of Colab notebooks that leverage Spark Connect. By programmatically triggering and monitoring a notebook execution job on Google Cloud AI Platform, it ensures that the necessary services and configurations are correctly integrated and functional for this specific workflow, enhancing the reliability of Spark Connect usage within Colab Enterprise.

Highlights

  • New Integration Test: Introduces a new integration test designed to execute a Colab notebook that utilizes Spark Connect within the Google Cloud AI Platform environment.
  • Dependency Update: Adds google-cloud-aiplatform>=1.119.0 to the requirements-test.txt file, enabling interaction with the AI Platform API.
  • Colab Notebook Execution: The test programmatically creates and monitors a NotebookExecutionJob using the aiplatform_v1.NotebookServiceClient, verifying that the job completes successfully.
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 adds an integration test for executing a Colab notebook. The changes look good overall, but I have a couple of suggestions to improve the maintainability and efficiency of the new test code. Specifically, I recommend sourcing hardcoded IDs and URIs from environment variables to make the test more flexible. I also found an opportunity to simplify the logic for retrieving the executed job details, making the test more efficient and robust.

Comment on lines +25 to +26
REPOSITORY_ID = "97193e1e-c5d1-4ce8-bc6f-cf206c701624"
TEMPLATE_ID = "6409629422399258624"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better maintainability and flexibility, these hardcoded IDs should be configurable via environment variables, with the current values as defaults. This pattern is already used for project, region, and service account.

This also applies to the GCS URIs hardcoded on lines 89 and 92. I recommend extracting them to module-level constants as well, for example:

GCS_NOTEBOOK_URI = os.getenv(
    "GCS_NOTEBOOK_URI",
    "gs://e2e-testing-bucket/input/notebooks/spark_connect_e2e_notebook_test.ipynb",
)
GCS_OUTPUT_URI = os.getenv("GCS_OUTPUT_URI", "gs://e2e-testing-bucket/output")
Suggested change
REPOSITORY_ID = "97193e1e-c5d1-4ce8-bc6f-cf206c701624"
TEMPLATE_ID = "6409629422399258624"
REPOSITORY_ID = os.getenv("REPOSITORY_ID", "97193e1e-c5d1-4ce8-bc6f-cf206c701624")
TEMPLATE_ID = os.getenv("TEMPLATE_ID", "6409629422399258624")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fangyh20 I think we can ignore this comment but please LMK

"dataform_repository_resource_name": f"projects/{test_project}/locations/{test_region}/repositories/{test_repository}",
},
"gcs_notebook_source": {
"uri": "gs://e2e-testing-bucket/input/notebooks/spark_connect_e2e_notebook_test.ipynb",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we upload the test content from repo for testing? so we do have one place for managing all test dependencies. ideally, we should be able to test existing integration test code and new test cases in executor within github repo.

@@ -1,2 +1,3 @@
pytest>=8.0
pytest-xdist>=3.0
google-cloud-aiplatform>=1.119.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: sort alphabetically

Comment on lines +25 to +26
REPOSITORY_ID = "97193e1e-c5d1-4ce8-bc6f-cf206c701624"
TEMPLATE_ID = "6409629422399258624"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May we add a comment what this vars are?

notebook_execution_job={
"display_name": test_execution_display_name,
# Specify a NotebookRuntimeTemplate to source compute configuration from
"notebook_runtime_template_resource_name": f"projects/{test_project}/locations/{test_region}/notebookRuntimeTemplates/{test_template}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to preconfigure project for this to work somehow? If so, let's document it

"dataform_repository_resource_name": f"projects/{test_project}/locations/{test_region}/repositories/{test_repository}",
},
"gcs_notebook_source": {
"uri": "gs://e2e-testing-bucket/input/notebooks/spark_connect_e2e_notebook_test.ipynb",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bucket seems to be a little too generic for global namespace, maybe we can use something like dataproc-spark-connect-e2e-testing

from google.cloud import aiplatform_v1
from google.cloud.aiplatform_v1.types import JobState

import os
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May we add doc comment to this test that describes how it works?

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