Skip to content

Commit

Permalink
Revert "Update dataproc/submit_job_to_cluster.py" (#1864)
Browse files Browse the repository at this point in the history
* Revert "Remove test configs for non-testing directories (#1855)"

This reverts commit 73a7332.

* Revert "Auto-update dependencies. (#1846)"

This reverts commit df8e623.

* Revert "Tweak slack sample (#1847)"

This reverts commit a48c010.

* Revert "Non-client library example of constructing a Signed URL (#1837)"

This reverts commit fc3284d.

* Revert "GCF samples: handle {empty JSON, GET} requests + remove commas (#1832)"

This reverts commit 6928491.

* Revert "Correct the maintenance event types (#1830)"

This reverts commit c22840f.

* Revert "Fix GCF region tags (#1827)"

This reverts commit 0fbfef2.

* Revert "Updated to Flask 1.0 (#1819)"

This reverts commit d52ccf9.

* Revert "Fix deprecation warning (#1801)"

This reverts commit 981737e.

* Revert "Update submit_job_to_cluster.py (#1708)"

This reverts commit cdab25b.
  • Loading branch information
engelke authored Nov 21, 2018
1 parent 8996b42 commit d610605
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit d610605

Please sign in to comment.