Skip to main content

ArgoEvent - Create events to trigger flows

This class is mainly used outside Metaflow flows to create events that trigger Metaflow flows. For instance, you can use this class inside a non-Metaflow ETL pipeline or a microservice to trigger a Metaflow execution.

Note that this class assumes that you have an appropriate Metaflow configuration available. Make sure to copy the config file in any environment where this class is being used.

Read more in Triggering Flows Based on External Events.

ArgoEvent(name, url=None, payload={})

[source]

from metaflow.integrations import ArgoEvent

ArgoEvent is a small event, a message, that can be published to Argo Workflows. The event will eventually start all flows which have been previously deployed with @trigger to wait for this particular named event.

Parameters 

name: str,

Name of the event

url: str, optional

Override the event endpoint from ARGO_EVENTS_WEBHOOK_URL.

payload: Dict, optional

A set of key-value pairs delivered in this event. Used to set parameters of triggered flows.

ArgoEvent.add_to_payload(self, key, value)

[source]

Add a key-value pair in the payload. This is typically used to set parameters of triggered flows. Often, key is the parameter name you want to set to value. Overrides any existing value of key.

Parameters 

key: str

Key

value: str

Value

ArgoEvent.publish(self, payload, force, ignore_errors)

[source]

Publishes an event.

Note that the function returns immediately after the event has been sent. It does not wait for flows to start, nor it guarantees that any flows will start.

Parameters 

payload: dict

Additional key-value pairs to add to the payload.

ignore_errors: bool, default: True

If True, events are created on a best effort basis - errors are silently ignored.

ArgoEvent.safe_publish(self, payload, ignore_errors)

[source]

Publishes an event when called inside a deployed workflow. Outside a deployed workflow this function does nothing.

Use this function inside flows to create events safely. As this function is a no-op for local runs, you can safely call it during local development without causing unintended side-effects. It takes effect only when deployed on Argo Workflows.

Parameters 

payload: dict

Additional key-value pairs to add to the payload.

ignore_errors: bool, default: True

If True, events are created on a best effort basis - errors are silently ignored.