6767_LEGACY_ENVIRONMENT_MAJOR_VERSION = '7'
6868_FNAPI_ENVIRONMENT_MAJOR_VERSION = '7'
6969
70+ _LOGGER = logging .getLogger (__name__ )
71+
7072
7173class Step (object ):
7274 """Wrapper for a dataflow Step protobuf."""
@@ -378,7 +380,7 @@ def __init__(self, options, proto_pipeline):
378380 'Missing required configuration parameters: %s' % missing )
379381
380382 if not self .google_cloud_options .staging_location :
381- logging .info ('Defaulting to the temp_location as staging_location: %s' ,
383+ _LOGGER .info ('Defaulting to the temp_location as staging_location: %s' ,
382384 self .google_cloud_options .temp_location )
383385 (self .google_cloud_options
384386 .staging_location ) = self .google_cloud_options .temp_location
@@ -495,7 +497,7 @@ def stage_file(self, gcs_or_local_path, file_name, stream,
495497 """Stages a file at a GCS or local path with stream-supplied contents."""
496498 if not gcs_or_local_path .startswith ('gs://' ):
497499 local_path = FileSystems .join (gcs_or_local_path , file_name )
498- logging .info ('Staging file locally to %s' , local_path )
500+ _LOGGER .info ('Staging file locally to %s' , local_path )
499501 with open (local_path , 'wb' ) as f :
500502 f .write (stream .read ())
501503 return
@@ -505,7 +507,7 @@ def stage_file(self, gcs_or_local_path, file_name, stream,
505507 request = storage .StorageObjectsInsertRequest (
506508 bucket = bucket , name = name )
507509 start_time = time .time ()
508- logging .info ('Starting GCS upload to %s...' , gcs_location )
510+ _LOGGER .info ('Starting GCS upload to %s...' , gcs_location )
509511 upload = storage .Upload (stream , mime_type )
510512 try :
511513 response = self ._storage_client .objects .Insert (request , upload = upload )
@@ -520,7 +522,7 @@ def stage_file(self, gcs_or_local_path, file_name, stream,
520522 'access to the specified path.' ) %
521523 (gcs_or_local_path , reportable_errors [e .status_code ]))
522524 raise
523- logging .info ('Completed GCS upload to %s in %s seconds.' , gcs_location ,
525+ _LOGGER .info ('Completed GCS upload to %s in %s seconds.' , gcs_location ,
524526 int (time .time () - start_time ))
525527 return response
526528
@@ -544,7 +546,7 @@ def create_job(self, job):
544546 if not template_location :
545547 return self .submit_job_description (job )
546548
547- logging .info ('A template was just created at location %s' ,
549+ _LOGGER .info ('A template was just created at location %s' ,
548550 template_location )
549551 return None
550552
@@ -564,7 +566,7 @@ def create_job_description(self, job):
564566 shared_names .STAGED_PIPELINE_FILENAME ),
565567 packages = resources , options = job .options ,
566568 environment_version = self .environment_version ).proto
567- logging .debug ('JOB: %s' , job )
569+ _LOGGER .debug ('JOB: %s' , job )
568570
569571 @retry .with_exponential_backoff (num_retries = 3 , initial_delay_secs = 3 )
570572 def get_job_metrics (self , job_id ):
@@ -575,7 +577,7 @@ def get_job_metrics(self, job_id):
575577 try :
576578 response = self ._client .projects_locations_jobs .GetMetrics (request )
577579 except exceptions .BadStatusCodeError as e :
578- logging .error ('HTTP status %d. Unable to query metrics' ,
580+ _LOGGER .error ('HTTP status %d. Unable to query metrics' ,
579581 e .response .status )
580582 raise
581583 return response
@@ -591,16 +593,16 @@ def submit_job_description(self, job):
591593 try :
592594 response = self ._client .projects_locations_jobs .Create (request )
593595 except exceptions .BadStatusCodeError as e :
594- logging .error ('HTTP status %d trying to create job'
596+ _LOGGER .error ('HTTP status %d trying to create job'
595597 ' at dataflow service endpoint %s' ,
596598 e .response .status ,
597599 self .google_cloud_options .dataflow_endpoint )
598- logging .fatal ('details of server error: %s' , e )
600+ _LOGGER .fatal ('details of server error: %s' , e )
599601 raise
600- logging .info ('Create job: %s' , response )
602+ _LOGGER .info ('Create job: %s' , response )
601603 # The response is a Job proto with the id for the new job.
602- logging .info ('Created job with id: [%s]' , response .id )
603- logging .info (
604+ _LOGGER .info ('Created job with id: [%s]' , response .id )
605+ _LOGGER .info (
604606 'To access the Dataflow monitoring console, please navigate to '
605607 'https://console.cloud.google.com/dataflow/jobsDetail'
606608 '/locations/%s/jobs/%s?project=%s' ,
0 commit comments