Hello! I’m new to Prefect tasks and flows. I’m usi...
# ask-community
d
Hello! I’m new to Prefect tasks and flows. I’m using Prefect Core in Deepnote (similar to Saturn Cloud). My flows are running great and are registered in Prefect Cloud but after the flows run in Deepnote the cloud UI doesn’t seem to log it? Our plan is to use Deepnote as our orchestrator and run the flows from there and have Prefect Cloud be the UI part of the puzzle… I felt like I saw that’s an option but may be mistaken? I feel like I’ve read every page in the documentation at this point but have no idea what the issue could be and troubleshooting suggestions? or newbie advice?
k
Hey @Dakota McCarty, I suspect you are running Flows with
flow.run()
. Is that right? The UI will only keep track of flows that the Prefect scheduler triggered.
flow.run()
is intended for local testing and that flow is not registered with Prefect Cloud. If you want to keep the notebook setup, you need to use
flow.register()
and then
create_flow_run()
d
Hey @Kevin Kho, thanks for the reply! I’ve tried create_flow_run() and it does successfully create the flow run in the Cloud UI. I guess I just don’t understand how to then run it via Deepnote? I thought just starting the agent would do it but then I get this and nothing changes.
k
The agent is intended to be a long running process that polls Prefect Cloud every 10 seconds. It is responsible for the execution of Flows. So normally for deployment you leave it as a background process on some box like EC2. Or maybe you have one running in your Kubernetes cluster. You would either need a long running service outside of deepnote, but if that would execute the flows but if you wanted to execute it in deepnote, you would need a long running process hosted there to pick and up and execute the flows. Then from the notebook when you create the flow run, it would appear in the UI.
I think it’s hard to run an agent AND run the flow in the same notebook because the agent as a process will take over the notebook. When hosted as a process on a machine, it creates new subprocesses to run your flow
d
ah, got it! Was a bit scared that’s the case haha. Unfortunately, I don’t think that’d be an option with out current set up
Found a cheat-y way to do it! but one that works!
a
@Dakota McCarty do tell! 🙂
d
@Alexander Seifert sure! I’m putting together a blog post but here’s the first draft of that https://deepnote.com/@Creative-Force/Prefect-demo-beEs0aYGQa-7oU_0UX1yyQ
👏 2
k
Nice! Thanks for sharing
Copy code
client.create_flow_run(flow_id, labels='deepnote')
your labels might need to be a list of strings because this might chop it up per letter since the string is an iterable
🙏 1