Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 2898cdf

Browse files
authored
Revert "Update dataproc/submit_job_to_cluster.py" [(#1864)](GoogleCloudPlatform/python-docs-samples#1864)
* Revert "Remove test configs for non-testing directories [(#1855)](GoogleCloudPlatform/python-docs-samples#1855)" This reverts commit 73a73321579337312e8ba85c34fe9c37b42b7f6e. * Revert "Auto-update dependencies. [(#1846)](GoogleCloudPlatform/python-docs-samples#1846)" This reverts commit 3adc94f. * Revert "Tweak slack sample [(#1847)](GoogleCloudPlatform/python-docs-samples#1847)" This reverts commit a48c010481c166968d9f1bd58106054c5d1c58f9. * Revert "Non-client library example of constructing a Signed URL [(#1837)](GoogleCloudPlatform/python-docs-samples#1837)" This reverts commit fc3284d995a8a35c473a207e80490fad265782af. * Revert "GCF samples: handle {empty JSON, GET} requests + remove commas [(#1832)](GoogleCloudPlatform/python-docs-samples#1832)" This reverts commit 6928491ed3d52b0bec694e6b30257f08caac5f2b. * Revert "Correct the maintenance event types [(#1830)](GoogleCloudPlatform/python-docs-samples#1830)" This reverts commit c22840fd23586349b7b665d851dea046a94ba7c7. * Revert "Fix GCF region tags [(#1827)](GoogleCloudPlatform/python-docs-samples#1827)" This reverts commit 0fbfef27d35cea23ad0e20fd2c9df3e8a4a046cb. * Revert "Updated to Flask 1.0 [(#1819)](GoogleCloudPlatform/python-docs-samples#1819)" This reverts commit d52ccf99503311bba2cec2881e8cb0f9b5a6f2bf. * Revert "Fix deprecation warning [(#1801)](GoogleCloudPlatform/python-docs-samples#1801)" This reverts commit 981737e85f60eca5cc337f172249deddca9b291b. * Revert "Update submit_job_to_cluster.py [(#1708)](GoogleCloudPlatform/python-docs-samples#1708)" This reverts commit df1f2b2.
1 parent ebcdc3e commit 2898cdf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

samples/snippets/submit_job_to_cluster.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ def get_pyspark_file(filename):
3434
return f, os.path.basename(filename)
3535

3636

37+
def get_region_from_zone(zone):
38+
try:
39+
region_as_list = zone.split('-')[:-1]
40+
return '-'.join(region_as_list)
41+
except (AttributeError, IndexError, ValueError):
42+
raise ValueError('Invalid zone provided, please check your input.')
43+
44+
3745
def upload_pyspark_file(project_id, bucket_name, filename, file):
3846
"""Uploads the PySpark file in this directory to the configured
3947
input bucket."""
@@ -191,7 +199,7 @@ def get_client():
191199
def main(project_id, zone, cluster_name, bucket_name,
192200
pyspark_file=None, create_new_cluster=True):
193201
dataproc = get_client()
194-
region = 'global'
202+
region = get_region_from_zone(zone)
195203
try:
196204
if pyspark_file:
197205
spark_file, spark_filename = get_pyspark_file(pyspark_file)

0 commit comments

Comments
 (0)