-
Notifications
You must be signed in to change notification settings - Fork 11
test: Add test that executes a colab notebook that uses spark connect… #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @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
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.
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.
REPOSITORY_ID = "97193e1e-c5d1-4ce8-bc6f-cf206c701624" | ||
TEMPLATE_ID = "6409629422399258624" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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")
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") |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: sort alphabetically
REPOSITORY_ID = "97193e1e-c5d1-4ce8-bc6f-cf206c701624" | ||
TEMPLATE_ID = "6409629422399258624" |
There was a problem hiding this comment.
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}", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
… (#151)