Ofir
03/02/2023, 11:47 PMPOST /model
REST API call to the Node.js server which then in turn calls Prefect 2.0 using the REST API to start a new run (of an existing deployment).
The workflow will train the model, run inference on some data and then persist the output to a database.
This is obviously an asynchronous operation that may take a few minutes (or more) to complete.
Assuming the workflow succeeded, I would like to notify the users (those who have Chrome opened to my web app) that something has happened, i.e. training completed.
How should the Node.js be notified when the flow has finished (either successfully / failed)?
Is there like a middleware / RabbitMQ / other message queue that the Node.js app can subscribe to, onto which Prefect publishes event?
If not, does Prefect expose other broadcast events? And if not, should I poll periodically from my app and maintain state diff?
Thanks!Austin Weisgrau
03/03/2023, 1:10 AMOfir
03/03/2023, 2:23 PMAustin Weisgrau
03/03/2023, 5:50 PMimport requests
def notify_on_completion(flow, flow_run, state):
<http://requests.post|requests.post>(webhook_url, json={'flow_name': flow.name, 'result': state.result()})
@flow(on_completion=[notify_on_completion])
def my_flow():
...
Ofir
03/03/2023, 5:52 PMAustin Weisgrau
03/03/2023, 5:53 PMOfir
03/03/2023, 5:54 PM