gpt4 book ai didi

kubernetes - Kubeflow 管道终止通知

转载 作者:行者123 更新时间:2023-12-02 11:29:16 35 4
gpt4 key购买 nike

我尝试添加一个逻辑,当管道因某些错误而终止时,该逻辑将发送松弛通知。我试图用 ExitHandler 来实现这个.但是,似乎ExitHandler不能依赖任何操作。你有什么好主意吗?

最佳答案

我找到了一个使用 ExitHandler 的解决方案.我在下面发布我的代码,希望它可以帮助别人。


def slack_notification(slack_channel: str, status: str, name: str, is_exit_handler: bool = False):
"""
performs slack notifications
"""
send_slack_op = dsl.ContainerOp(
name=name,
image='wenmin.wu/slack-cli:latest',
is_exit_handler=is_exit_handler,
command=['sh', '-c'],
arguments=["/send-message.sh -d {} '{}'".format(slack_channel, status)]
)
send_slack_op.add_env_variable(V1EnvVar(name = 'SLACK_CLI_TOKEN', value_from=V1EnvVarSource(config_map_key_ref=V1ConfigMapKeySelector(name='workspace-config', key='SLACK_CLI_TOKEN'))))
return send_slack_op

@dsl.pipeline(
name='forecasting-supply',
description='forecasting supply ...'
)
def ml_pipeline(
param1,
param2,
param3,
):
exit_task = slack_notification(
slack_channel = slack_channel,
name = "supply-forecasting",
status = "Kubeflow pipeline: {{workflow.name}} has {{workflow.status}}!",
is_exit_handler = True
)

with dsl.ExitHandler(exit_task):
# put other tasks here

关于kubernetes - Kubeflow 管道终止通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57508382/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com