@@ -158,6 +158,9 @@ def file_exists(name: str) -> bool:
158158 return False
159159
160160
161+ global_variable_tarfiles_pushed = 0
162+
163+
161164# C901 'globus_transfer' is too complex (20)
162165def globus_transfer ( # noqa: C901
163166 remote_ep : str , remote_path : str , name : str , transfer_type : str , non_blocking : bool
@@ -168,8 +171,10 @@ def globus_transfer( # noqa: C901
168171 global transfer_data
169172 global task_id
170173 global archive_directory_listing
174+ global global_variable_tarfiles_pushed
171175
172176 logger .info (f"{ ts_utc ()} : Entered globus_transfer() for name = { name } " )
177+ logger .debug (f"{ ts_utc ()} : non_blocking = { non_blocking } " )
173178 if not transfer_client :
174179 globus_activate ("globus://" + remote_ep )
175180 if not transfer_client :
@@ -215,7 +220,7 @@ def globus_transfer( # noqa: C901
215220 fail_on_quota_errors = True ,
216221 )
217222 transfer_data .add_item (src_path , dst_path )
218- transfer_data ["label" ] = subdir_label + " " + filename
223+ transfer_data ["label" ] = label
219224 try :
220225 if task_id :
221226 task = transfer_client .get_task (task_id )
@@ -225,12 +230,12 @@ def globus_transfer( # noqa: C901
225230 # Presently, we do not, except inadvertantly (if status == PENDING)
226231 if prev_task_status == "ACTIVE" :
227232 logger .info (
228- f"{ ts_utc ()} : Previous task_id { task_id } Still Active. Returning."
233+ f"{ ts_utc ()} : Previous task_id { task_id } Still Active. Returning ACTIVE ."
229234 )
230235 return "ACTIVE"
231236 elif prev_task_status == "SUCCEEDED" :
232237 logger .info (
233- f"{ ts_utc ()} : Previous task_id { task_id } status = SUCCEEDED. Continuing. "
238+ f"{ ts_utc ()} : Previous task_id { task_id } status = SUCCEEDED."
234239 )
235240 src_ep = task ["source_endpoint_id" ]
236241 dst_ep = task ["destination_endpoint_id" ]
@@ -243,15 +248,19 @@ def globus_transfer( # noqa: C901
243248 )
244249 else :
245250 logger .error (
246- f"{ ts_utc ()} : Previous task_id { task_id } status = { prev_task_status } . Continuing. "
251+ f"{ ts_utc ()} : Previous task_id { task_id } status = { prev_task_status } ."
247252 )
248253
249254 # DEBUG: review accumulated items in TransferData
250255 logger .info (f"{ ts_utc ()} : TransferData: accumulated items:" )
251256 attribs = transfer_data .__dict__
252257 for item in attribs ["data" ]["DATA" ]:
253258 if item ["DATA_TYPE" ] == "transfer_item" :
254- print (f" source item: { item ['source_path' ]} " )
259+ global_variable_tarfiles_pushed += 1
260+ print (
261+ f" (routine) PUSHING (#{ global_variable_tarfiles_pushed } ) STORED source item: { item ['source_path' ]} " ,
262+ flush = True ,
263+ )
255264
256265 # SUBMIT new transfer here
257266 logger .info (f"{ ts_utc ()} : DIVING: Submit Transfer for { transfer_data ['label' ]} " )
@@ -263,6 +272,7 @@ def globus_transfer( # noqa: C901
263272 f"{ ts_utc ()} : SURFACE Submit Transfer returned new task_id = { task_id } for label { transfer_data ['label' ]} "
264273 )
265274
275+ # Nullify the submitted transfer data structure so that a new one will be created on next call.
266276 transfer_data = None
267277 except TransferAPIError as e :
268278 if e .code == "NoCredException" :
@@ -310,9 +320,13 @@ def globus_block_wait(
310320 while retry_count < max_retries :
311321 try :
312322 # Wait for the task to complete
323+ logger .info (
324+ f"{ ts_utc ()} : on task_wait try { retry_count + 1 } out of { max_retries } "
325+ )
313326 transfer_client .task_wait (
314327 task_id , timeout = wait_timeout , polling_interval = 10
315328 )
329+ logger .info (f"{ ts_utc ()} : done with wait" )
316330 except Exception as e :
317331 logger .error (f"Unexpected Exception: { e } " )
318332 else :
@@ -350,7 +364,7 @@ def globus_wait(task_id: str):
350364 with 20 second timeout limit. If the task is ACTIVE after time runs
351365 out 'task_wait' returns False, and True otherwise.
352366 """
353- while not transfer_client .task_wait (task_id , timeout = 20 , polling_interval = 20 ):
367+ while not transfer_client .task_wait (task_id , timeout = 300 , polling_interval = 20 ):
354368 pass
355369 """
356370 The Globus transfer job (task) has been finished (SUCCEEDED or FAILED).
@@ -387,10 +401,24 @@ def globus_finalize(non_blocking: bool = False):
387401 global transfer_client
388402 global transfer_data
389403 global task_id
404+ global global_variable_tarfiles_pushed
390405
391406 last_task_id = None
392407
393408 if transfer_data :
409+ # DEBUG: review accumulated items in TransferData
410+ logger .info (f"{ ts_utc ()} : FINAL TransferData: accumulated items:" )
411+ attribs = transfer_data .__dict__
412+ for item in attribs ["data" ]["DATA" ]:
413+ if item ["DATA_TYPE" ] == "transfer_item" :
414+ global_variable_tarfiles_pushed += 1
415+ print (
416+ f" (finalize) PUSHING ({ global_variable_tarfiles_pushed } ) source item: { item ['source_path' ]} " ,
417+ flush = True ,
418+ )
419+
420+ # SUBMIT new transfer here
421+ logger .info (f"{ ts_utc ()} : DIVING: Submit Transfer for { transfer_data ['label' ]} " )
394422 try :
395423 last_task = submit_transfer_with_checks (transfer_data )
396424 last_task_id = last_task .get ("task_id" )
0 commit comments