Jeremy Yeo
04/02/2020, 7:03 AMpip install prefect
.
2. prefect backend server
.
3. In a new terminal: prefect server start
- this allows UI to be accessible locally (no flows yet).
4. In another new terminal, start an agent to run flows: prefect agent start
.
5. Create a simple new flow in `demo-flow.py`:
import prefect
from prefect import task, Flow
@task
def hello_task():
logger = prefect.context.get("logger")
<http://logger.info|logger.info>("Hello, Cloud!")
@task
def another_task():
logger = prefect.context.get("logger")
<http://logger.info|logger.info>("Our second flow!")
flow = Flow("hello-flow", tasks=[hello_task])
flow.register()
flow_2 = Flow("second-flow", tasks=[another_task])
flow_2.register()
6. Register the new flows: python demo-flow.py
.
7. Navigate to the UI (localhost:8080
) and start a manual run of the "hello-flow" flow.
8. Output is visible in the log in the UI.
---
Is this how one should "register" a flow (step 6) and why would a run of such a simple flow take 3 minutes to complete? Thanks :)Jeremiah
fow.register()
is indeed the correct way to send the flow to the server.
As for the three minutes thing - that’s definitely not expected. These flows should run instantly, subject only to a slight delay if it takes your agent a moment to grab them, but that shouldn’t take more than a couple seconds. To be precise - is it taking 3 minutes for your agent to identify and load the scheduled flow run, or is it taking three minutes for the flow to actually run (which would be very weird given how simple the flows are)?