stocky-fountain-57774
08/14/2024, 6:37 AMvictorious-lawyer-58417
08/14/2024, 6:40 AMrun --with my_decorator
or something else?stocky-fountain-57774
08/14/2024, 6:57 AMstocky-fountain-57774
08/14/2024, 7:00 AM"""This module contains the custom step decorators for Metaflow."""
from metaflow.decorators import StepDecorator
class JobStepDecorator(StepDecorator):
"""Step decorator that does something before and after the step, and also if the step fails."""
name = "jobstepdecorator"
def task_pre_step(
self,
step_name,
task_datastore,
metadata,
run_id,
task_id,
flow,
graph,
retry_count,
max_user_code_retries,
ubf_context,
inputs,
):
"""Do something before the step."""
# Do something before the step
def task_post_step(self, step_name, flow, graph, retry_count, max_user_code_retries):
"""Do something after the step."""
# Do something after the step
def task_exception(self, exception, step_name, flow, graph, retry_count, max_user_code_retries):
"""Do something if the step fails."""
I would like to test the different functionsstocky-fountain-57774
08/14/2024, 7:01 AMdry-beach-38304
08/14/2024, 9:25 AMstocky-fountain-57774
08/14/2024, 11:07 AMfrom metaflow import customstepdecorator
But inside the repo itself, I'm not sure if it's possible.
I tried workarounds by importing the class itself, in the context of a flow, but it didn't work. Is it possible to do that ?
Again, maybe I don't really understand the underlying logic, and maybe using Python decorators could work.
I use the decorator to log what has happened in the step and handle errors, connected to an external logging API.dry-beach-38304
08/14/2024, 3:54 PM