Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIP-7511 user defined @exit_handler Part 2/2 #274

Merged
merged 3 commits into from
Dec 4, 2023

Conversation

talebzeghmi
Copy link
Collaborator

@talebzeghmi talebzeghmi commented Nov 30, 2023

https://argo-server.int.stage-k8s.zg-aip.net/argo-ui/workflows/aip-playground-dev/helloflow-vwdpv?tab=workflow

example use:

from metaflow import FlowSpec, step, exit_handler
from metaflow.plugins.aip import exit_handler_resources, exit_handler_retry

# advanced likely a 10% case of customizing the retry or resources
@exit_handler_retry(times=1, minutes_between_retries=0)
@exit_handler_resources(cpu="600m", memory="600Mi")
def my_exit_handler(
    status: str,
    flow_parameters: dict,
    argo_workflow_run_name: str,
    metaflow_run_id: str,
    argo_ui_url: str,
    retries: int,
) -> None:
    if retries == 0:
        raise Exception("oopsie")


@exit_handler(func=my_exit_handler, on_success=True)
class HelloFlow(FlowSpec):
    @step
    def start(self):
        raise Exception("foo")
        self.next(self.end)

    @step
    def end(self):
        print("HelloFlow is all done.")

if __name__ == "__main__":
    HelloFlow()
python metaflow/tutorials/00-helloworld/helloworld.py aip run --notify --sqs-url-on-error foo

image

note: Not able to reuse the Metaflow @resources and @retry decorator

Because:

@talebzeghmi talebzeghmi changed the title AIP-7511 user defined @exit_handler AIP-7511 user defined @exit_handler Part 2/2 Dec 1, 2023
metaflow/plugins/aip/aip.py Show resolved Hide resolved
metaflow/plugins/aip/aip.py Show resolved Hide resolved
metaflow/plugins/aip/aip.py Outdated Show resolved Hide resolved
metaflow/plugins/aip/aip.py Show resolved Hide resolved
@talebzeghmi talebzeghmi merged commit b866f3c into feature/aip Dec 4, 2023
3 checks passed
@talebzeghmi talebzeghmi deleted the tz/AIP-7511-exit-handler-decorator branch December 4, 2023 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants