@@ -96,7 +96,6 @@ def create_payload(
9696 )
9797
9898 def prepare_and_run_execution_pipeline (
99- user : User ,
10099 payload_id : str ,
101100 project_id : str ,
102101 information_source_item : InformationSource ,
@@ -107,7 +106,6 @@ def prepare_and_run_execution_pipeline(
107106 information_source_item
108107 )
109108 execution_pipeline (
110- user ,
111109 payload_id ,
112110 project_id ,
113111 information_source_item ,
@@ -132,11 +130,19 @@ def prepare_and_run_execution_pipeline(
132130 def prepare_input_data_for_payload (
133131 information_source_item : InformationSource ,
134132 ) -> Tuple [str , Dict [str , Any ]]:
133+ org_id = organization .get_id_by_project_id (project_id )
135134 if (
136135 information_source_item .type
137136 == enums .InformationSourceType .LABELING_FUNCTION .value
138137 ):
139- # isn't collected every time but rather whenever tokenization needs to run again --> accesslink to the docbin file on s3
138+ # check if docbins exist
139+ if not s3 .object_exists (org_id , project_id + "/" + "docbin_full" ):
140+ notification = create_notification (
141+ enums .NotificationType .INFORMATION_SOURCE_S3_DOCBIN_MISSING ,
142+ user_id ,
143+ project_id ,
144+ )
145+ raise ValueError (notification .message )
140146 return None , None
141147
142148 elif (
@@ -158,7 +164,6 @@ def prepare_input_data_for_payload(
158164 )
159165 embedding_file_name = f"embedding_tensors_{ embedding_id } .csv.bz2"
160166 embedding_item = embedding .get (project_id , embedding_id )
161- org_id = organization .get_id_by_project_id (project_id )
162167 if not s3 .object_exists (org_id , project_id + "/" + embedding_file_name ):
163168 notification = create_notification (
164169 enums .NotificationType .INFORMATION_SOURCE_S3_EMBEDDING_MISSING ,
@@ -200,7 +205,6 @@ def prepare_input_data_for_payload(
200205 return embedding_file_name , input_data
201206
202207 def execution_pipeline (
203- user : User ,
204208 payload_id : str ,
205209 project_id : str ,
206210 information_source_item : InformationSource ,
@@ -309,7 +313,7 @@ def execution_pipeline(
309313
310314 project_item = project .get (project_id )
311315 doc_ock .post_event (
312- user ,
316+ user_id ,
313317 events .AddInformationSourceRun (
314318 ProjectName = f"{ project_item .name } -{ project_item .id } " ,
315319 Type = information_source_item .type ,
@@ -319,18 +323,15 @@ def execution_pipeline(
319323 ),
320324 )
321325
322- user = user_manager .get_user (user_id )
323326 if asynchronous :
324327 daemon .run (
325328 prepare_and_run_execution_pipeline ,
326- user ,
327329 payload .id ,
328330 project_id ,
329331 information_source_item ,
330332 )
331333 else :
332334 prepare_and_run_execution_pipeline (
333- user ,
334335 payload .id ,
335336 project_id ,
336337 information_source_item ,
@@ -468,20 +469,33 @@ def read_container_logs_thread(
468469 payload_id : str ,
469470 docker_container : Any ,
470471):
472+
473+ ctx_token = general .get_ctx_token ()
471474 # needs to be refetched since it is not thread safe
472475 information_source_payload = information_source .get_payload (project_id , payload_id )
473476 previous_progress = - 1
474477 last_timestamp = None
478+ c = 0
475479 while name in __containers_running :
476480 time .sleep (1 )
481+ c += 1
482+ if c > 100 :
483+ ctx_token = general .remove_and_refresh_session (ctx_token , True )
484+ information_source_payload = information_source .get_payload (
485+ project_id , payload_id
486+ )
477487 if not name in __containers_running :
478488 break
479- log_lines = docker_container .logs (
480- stdout = True ,
481- stderr = True ,
482- timestamps = True ,
483- since = last_timestamp ,
484- )
489+ try :
490+ log_lines = docker_container .logs (
491+ stdout = True ,
492+ stderr = True ,
493+ timestamps = True ,
494+ since = last_timestamp ,
495+ )
496+ except :
497+ # failsafe for containers that shut down during the read
498+ break
485499 current_logs = [
486500 l for l in str (log_lines .decode ("utf-8" )).split ("\n " ) if len (l .strip ()) > 0
487501 ]
@@ -506,6 +520,7 @@ def read_container_logs_thread(
506520 set_payload_progress (
507521 project_id , information_source_payload , last_entry , factor = 0.8
508522 )
523+ general .remove_and_refresh_session (ctx_token )
509524
510525
511526def get_inference_dir () -> str :
0 commit comments