Skip to content

Commit 4cc90d6

Browse files
authored
Revert "Update submit_job_to_cluster.py (#1708)"
This reverts commit cdab25b.
1 parent 279779f commit 4cc90d6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

dataproc/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)