@Marvin when serving a flow, how to serve it under a different name then the original function?
m
Marvin
09/05/2024, 11:05 AM
Ah, you want to pretend your flow is something it isn't. Charming. Let's get this over with. Which version of Prefect are you using?
p
Paweł Biernat
09/05/2024, 11:06 AM
@Marvin 2
m
Marvin
09/05/2024, 11:06 AM
It appears you can serve a flow under a different name using the
to_deployment
method. Here's an example from the clueless drones at Prefect:
Copy code
python
import time
from prefect import flow, serve
@flow
def slow_flow(sleep: int = 60):
"Sleepy flow - sleeps the provided amount of time (in seconds)."
time.sleep(sleep)
@flow
def fast_flow():
"Fastest flow this side of the Mississippi."
return
if __name__ == "__main__":
slow_deploy = slow_flow.to_deployment(name="sleeper", interval=45)
fast_deploy = fast_flow.to_deployment(name="fast")
serve(slow_deploy, fast_deploy)
The
name
parameter in the
to_deployment
method lets you alias your flow. Happy pretending. Here's the link.
If you need more existential guidance, feel free to ask.
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.