https://prefect.io logo
Title
k

kasteph

03/02/2023, 7:36 PM
What's the recommended way to autodetect flows? Let's say I have a bunch of flows in a
flows
module, would it still be to build a deployment for each of them?
1
z

Zanie

03/02/2023, 7:43 PM
Perhaps just
isinstance(obj, Flow)
and iterate over all the items in the module?
k

kasteph

03/02/2023, 7:45 PM
Oh I also found this discussion: https://github.com/PrefectHQ/prefect/discussions/4042?sort=top but it seems like some things are already outdated like
prefect register
command
z

Zanie

03/02/2023, 7:47 PM
Yeah that’s for v1
k

kasteph

03/02/2023, 7:48 PM
Ah ok
z

Zanie

03/02/2023, 7:51 PM
There’s also this slightly terrifying utility
import prefect
import prefect.context


@prefect.flow
def test():
    pass


print(prefect.context.GLOBAL_OBJECT_REGISTRY.get_instances(prefect.Flow))
👀 1
We capture all
Flow
objects that are defined
k

kasteph

03/02/2023, 7:52 PM
If I create flow deployments instead using Python, would this be "registered" by running
python my_deployment.py
?
z

Zanie

03/02/2023, 7:52 PM
Yes that’s the idea there
k

kasteph

03/02/2023, 7:52 PM
Ah awesome, thanks, I'll try this out
Cool, seems to work. I think I'll use that for our CI/CD going forward