https://prefect.io logo
Title
m

Mark McDonald

04/30/2020, 5:35 PM
I'm trying to make better use of the Cloud Hooks on my flows. Ideally, I wouldn't have to set this up through the cloud UI, but rather when I'm deploying my flows. It doesn't look like there is a way to do this from Core. Will someone confirm? Like it'd be cool if this were part of Flow.register(). I'm guessing it is possible to do this from the graphql api? I'm not seeing much about it in the docs.
👀 1
d

Dylan

04/30/2020, 5:40 PM
Hi @Mark McDonald! This is definitely interesting feedback. Would you mind opening an issue for this feature request? Are you changing the hooks that are set between versions of a flow? Cloud Hooks should persist across versions once they’re set It’s possible to set cloud hooks using the graphql api. Try exploring the Interactive API for details.
Here’s an example:
mutation {
  create_cloud_hook(input: {type: EMAIL, name: "Example", version_group_id: "abc", states: ["Running"], config: {}}) {
    id
  }
}
m

Mark McDonald

04/30/2020, 5:52 PM
thanks for the feedback, Dylan. It's good to know that these hooks persist across versions. Ideally I would have the recipient of the cloud hook notifications under some version control, as part of the flow code. We are using prefect in a self service fashion. So, while it works for me to set up my own cloud hooks through the UI, I'd like to have it programmatically set for others who might forget this (important) step. In airflow, you set this in the default_args of the dag file (see below). I would probably try to do something like this, if it were possible to do during Flow.register(). The graphql api should work fine, I'd just have to do it after flow deployment, because for new flows, I wouldn't yet have the version_group_id to work off of.
default_args = {
    'owner': 'mark',
    'start_date': datetime(2020, 4, 30),
    'email': [<mailto:'mmcdonald@clearcover.com|'mmcdonald@clearcover.com>'],
    'email_on_failure': True,
    'email_on_retry': True,
    'retry_exponential_backoff': True,
    'retry_delay' = timedelta(seconds=300)
    'retries': 3
}
I will open this feature request. In the meantime, I'll work with the graphql api. That may be sufficient. Thanks again, Dylan.
d

Dylan

04/30/2020, 5:55 PM
Thank you!