def submit_pyspark_job(dataproc, project, cluster_name, bucket_name, filename):
 job_details = {'projectId': project, 'job': {'placement': {'clusterName': cluster_name}, 'pysparkJob': {'mainPythonFileUri': 'gs://{}/{}'.format(bucket_name, filename)}}}
 result = dataproc.projects().regions().jobs().submit(projectId=project, region=REGION, body=job_details).execute()
 job_id = result['reference']['jobId']
 print 'Submitted job ID {}'.format(job_id)
 return job_id

def submit_pyspark_job ( dataproc , project , cluster_name , bucket_name , filename ) : job_details = { 'projectId' : project , 'job' : { 'placement' : { 'clusterName' : cluster_name } , 'pysparkJob' : { 'mainPythonFileUri' : 'gs://{}/{}' . format ( bucket_name , filename ) } } } result = dataproc . projects ( ) . regions ( ) . jobs ( ) . submit ( projectId = project , region = REGION , body = job_details ) . execute ( ) job_id = result [ 'reference' ] [ 'jobId' ] print 'Submitted job ID {}' . format ( job_id ) return job_id
submits the pyspark job to the cluster .