Hooks are a simpler abstraction compared to a DAG. It allows to trigger post-done operations, like sending notifications or triggering a logic in response to the final state of an operation. You can use any component as a hook, as long as it's registered in the public component hub or in a private hub in your organization.
Using the public components
Polyaxon provides several public components where the main purpose is to be used as a hook, like notifiers. For instance you can notify a slack channel about the state of your jobs:
hooks:
- trigger: succeeded
hubRef: slack
connection: slack-notificationIf you need to send notifications for all done statuses:
hooks:
- trigger: done
hubRef: slack
connection: slack-notificationRun the complete operation from scheduling/hooks/slack-hook.yaml:
polyaxon run --url https://raw.githubusercontent.com/polyaxon/polyaxon-quick-start/master/scheduling/hooks/slack-hook.yamlRunning multiple hooks
It's also possible to have multiple hooks or the same hook based on different conditions, for instance, a user can both send a slack notification and start a tensorboard after a successful experiment:
hooks:
- trigger: succeeded
hubRef: tensorboard
disableDefaults: true
params:
uuid: { value: '{{ globals.uuid }}' }
- trigger: succeeded
hubRef: slack
connection: slack-notificationRun the complete component from scheduling/hooks/multiple-hooks.yaml:
polyaxon run --url https://raw.githubusercontent.com/polyaxon/polyaxon-quick-start/master/scheduling/hooks/multiple-hooks.yaml