I think there is a miss-documentation on <https://...
# flyte-support
p
I think there is a miss-documentation on https://www.union.ai/docs/flyte/deployment/flyte-configuration/configuring-notifications/#webhook-connector where
try/except
block is used inside
workflow
, which should not be possible as it is straight up python in workflow, no? It should only work when executed locally but on remote should not work. At least I don't get it to work.
Copy code
notification_task = WebhookTask(
   name="failure-notification",
   url="<https://hooks.slack.com/services/xyz>", #your Slack webhook
   method=http.HTTPMethod.POST,
   headers={"Content-Type": "application/json"},
   data={"text": "Workflow failed: {inputs.error_message}"},
   dynamic_inputs={"error_message": str},
   show_data=True,
   show_url=True,
   description="Send notification on workflow failure"
)
...

@fl.workflow
def ml_workflow_with_failure_handling() -> float:
   try:
       X, y = load_and_preprocess_data()
       model = train_model(X=X, y=y)
       accuracy = evaluate_model(model=model, X=X, y=y)
       return accuracy
   except Exception as e:
       # Trigger the notification task on failure
       notification_task(error_message=str(e))
       raise
f
This is indeed wrong
cc @powerful-gold-59386 / @glamorous-carpet-83516?
@powerful-australia-73346 but if you are interested in the
try - catch
let me know - i have something cooking
p
@freezing-airport-6809 Yes I am. Currently I am doing the un-orthodox thing and using
try/except
inside a
task
with the
WebhookTask