@@ -63,28 +63,8 @@ def lookup_dims(fp: Path) -> Header:
6363 return xyz_cleaned
6464
6565
66- def collect_exception_task_hook (task : Task , task_run : TaskRun , state : State ):
67- """
68- This task hook should be used with tasks where you intend to know which step of the flow run broke.
69- Since most of our tasks are mapped by default using filepaths, it takes map index into account as well
70- So that we can notify the user, 'this step of this file broke'.
71- The message is written to a file using prefect's local storage.
72- In order to retrieve it, the flow needs to have a logic at the end,
73- to lookup for this file with exception message if the task run has failed.
74- """
75- message = f"Failure in pipeline step: { task .name } "
76- map_idx = task_run .name .split ("-" )[- 1 ]
77- flow_run_id = state .state_details .flow_run_id
78- path = f"{ flow_run_id } __{ map_idx } "
79- try :
80- Config .local_storage .read_path (path )
81- except ValueError : # ValueError path not found
82- Config .local_storage .write_path (path , message .encode ())
83-
84-
8566@task (
8667 name = "mrc to movie generation" ,
87- on_failure = [collect_exception_task_hook ],
8868)
8969def mrc_to_movie (file_path : FilePath , root : str , asset_type : str , ** kwargs ):
9070 """
@@ -357,7 +337,6 @@ def copy_template(working_dir: Path, template_name: str) -> Path:
357337 name = "Batchruntomo conversion" ,
358338 tags = ["brt" ],
359339 # timeout_seconds=600,
360- on_failure = [collect_exception_task_hook ],
361340)
362341def run_brt (
363342 file_path : FilePath ,
@@ -568,9 +547,6 @@ def notify_api_running(
568547# return ns
569548
570549
571- import asyncio
572-
573-
574550async def notify_api_completion (flow : Flow , flow_run : FlowRun , state : State ) -> None :
575551 """
576552 https://docs.prefect.io/core/concepts/states.html#overview.
@@ -722,20 +698,6 @@ def send_callback_body(
722698 )
723699
724700
725- def copy_workdirs_and_cleanup_hook (flow , flow_run , state ):
726- stored_result = Config .local_storage .read_path (f"{ flow_run .id } __gen_fps" )
727- fps : List [FilePath ] = Config .pickle_serializer .loads (
728- json .loads (stored_result )["data" ].encode ()
729- )
730- parameters = flow_run .parameters
731- x_keep_workdir = parameters .get ("x_keep_workdir" , False )
732-
733- for fp in fps :
734- copy_workdir_logs .fn (file_path = fp )
735-
736- cleanup_workdir .fn (fps , x_keep_workdir )
737-
738-
739701def callback_with_cleanup (
740702 fps : List [FilePath ],
741703 callback_result : List ,
0 commit comments