Skip to content
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

Revert "Update dataproc/submit_job_to_cluster.py" #1864

Merged
merged 12 commits into from
Nov 21, 2018
10 changes: 9 additions & 1 deletion dataproc/submit_job_to_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ def get_pyspark_file(filename):
return f, os.path.basename(filename)


def get_region_from_zone(zone):
try:
region_as_list = zone.split('-')[:-1]
return '-'.join(region_as_list)
except (AttributeError, IndexError, ValueError):
raise ValueError('Invalid zone provided, please check your input.')


def upload_pyspark_file(project_id, bucket_name, filename, file):
"""Uploads the PySpark file in this directory to the configured
input bucket."""
Expand Down Expand Up @@ -191,7 +199,7 @@ def get_client():
def main(project_id, zone, cluster_name, bucket_name,
pyspark_file=None, create_new_cluster=True):
dataproc = get_client()
region = 'global'
region = get_region_from_zone(zone)
try:
if pyspark_file:
spark_file, spark_filename = get_pyspark_file(pyspark_file)
Expand Down