-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat(dataproc): create pyspark nodegroup cluster sample #13513
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
Sample code to submit a PySpark job to a Dataproc driver node group cluster.
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
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.
Summary of Changes
Hello @Supriya-Koppa, 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 new, self-contained Python sample to the repository. Its primary purpose is to provide a clear and executable example for users looking to programmatically submit PySpark jobs to Dataproc clusters, specifically those configured with driver node groups, and to illustrate how to manage the job's resource allocation and retrieve its output.
Highlights
- New Sample Code: Introduced a new Python sample,
submit_pyspark_job_to_driver_node_group_cluster.py
, demonstrating how to submit a PySpark job to a Google Cloud Dataproc cluster that utilizes a driver node group. - Dataproc Job Submission: The sample showcases the use of the
google.cloud.dataproc_v1
client library to configure and submit a PySpark job, including specifyingDriverSchedulingConfig
for memory and vcores. - Output Retrieval: The code includes logic to retrieve and print the job's output from the Google Cloud Storage bucket where Dataproc stores job results.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 or fill out our survey to provide feedback.
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
-
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. ↩
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 a new Python sample for submitting a PySpark job to a Dataproc driver node group cluster. The code is a good starting point. My review includes suggestions for improving the script's usability by implementing command-line argument parsing, enhancing robustness with proper error handling, and increasing clarity and consistency through documentation and style adjustments. Addressing these points will make the sample more robust and user-friendly.
Added a END region tag
Improving readability
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.
Thank you for your first submission to the python-docs-samples repo! 🎉
There are some changes required to this file, including:
- moving it to the correct sample location for this product:
dataproc/snippets/
- including testing (you should be able to reference tests from similar samples in the dataproc folder as a starting point)
- moved the file to dataproc/snippets/ - updated the description for main_python_file_uri
@@ -0,0 +1,91 @@ | |||
#!/usr/bin/env python |
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.
You have not provided a test to go with this file. Given the similarity, you might be able to borrow from https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/dataproc/snippets/submit_spark_job_to_driver_node_group_cluster_test.py
job = { | ||
"placement": {"cluster_name": cluster_name}, | ||
"pyspark_job": { | ||
"main_python_file_uri": "gs://dataproc-examples/pyspark/hello-world/hello-world.py" |
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.
Outstanding issue from previous review: "Where does this object come from? Is there open source code for this object?"
|
||
my_project_id = "your_project_id" # <-- REPLACE THIS | ||
my_region = "your_region" # <-- REPLACE THIS | ||
my_cluster_name = "your_node_group_cluster" # <-- REPLACE THIS | ||
|
||
submit_job(my_project_id, my_region, my_cluster_name) |
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.
Outstanding comment from previous review: Please change this main method to copy the functionality from the spark job, which will remove the "REPLACE THIS" values. This can also help if you use command-line testing
python-docs-samples/dataproc/snippets/submit_spark_job_to_driver_node_group_cluster.py
Line 93 in e06d3cf
parser = argparse.ArgumentParser( |
Sample code to submit a PySpark job to a Dataproc driver node group cluster.
Description
Fixes #
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
nox -s py-3.9
(see Test Environment Setup)nox -s lint
(see Test Environment Setup)