https://prefect.io logo
#prefect-server
Title
# prefect-server
e

elbaro

02/19/2021, 1:45 AM
Hi, just wrote the first flow, the script runs the flow on its own with 0 agent and does not show up in the local UI dashboard. How to make it run on the local agent and display the runs in the dashboard? The UI only shows the flow name with 0 run.
Copy code
...
with Flow('flow') as flow:
    ..

flow.register(project_name='project1')
flow.run(parameters=dict(, ..))
flow.run(parameters=dict(, ..))
Copy code
[2021-02-19 ...] INFO - prefect.TaskRunner | Task '..': Starting task run..
[2021-02-19 ...] INFO - prefect.TaskRunner | Task '..': Finished task run for task with final state: 'Success'
...
Clikcing Flow URL shows 404.
a

Amanda Wee

02/19/2021, 2:05 AM
It sounds like you already have the prefect server and ui running, so maybe one option would be to run:
Copy code
prefect agent local start
then go to the ui and start a flow run?
e

elbaro

02/19/2021, 2:08 AM
I have a local agent as well with
Waiting for flow runs...
and UI shows this agent.
a

Amanda Wee

02/19/2021, 2:11 AM
Ah. A possible problem is that your flow has no labels, whereas the local agent has a label. For an agent to handle a flow, the flow has to have a subset of the labels of the agent, but a flow with no labels will only be handled by agents that also don't have any labels. One possible solution is to simply assign another label -- of the same name -- to both the flow and the local agent.
e

elbaro

02/19/2021, 2:14 AM
Both agent and flow has my hostname as its label. The flow skeleton (and list of tasks) shows up in the dashboard but number of runs is 0.
c

Chris White

02/19/2021, 2:14 AM
Hi elbaro — @Amanda Wee’s first suggestion is key.
flow.run
is only intended to be used for local testing / “interactive mode”. To have a run show up in the UI requires that your run was created and managed by the backend. So if you first remove the two calls to
flow.run
from your script, and then start up your agent + go to the UI to kick off a flow run as Amanda suggested, you should be good to go
e

elbaro

02/19/2021, 2:15 AM
Is
flow.register()
enough to run the flow? I have been searching how to provide parameters to
register()
but could't find one.
c

Chris White

02/19/2021, 2:16 AM
No,
flow.register
registers the existence of the Flow with the backend; to run the flow you need to either use a Prefect Client to call
create_flow_run
or navigate to the flow in the UI and click the “Run” button, which will allow you to provide whatever parameters you want
e

elbaro

02/19/2021, 2:24 AM
I see. Is there a Python way to automatically get
flow_id
?
Copy code
flow.register(project_name='project-name')
client = prefect.client.client.Client()
client.create_flow_run(??, parameters=dict(..))
client.create_flow_run(??, parameters=dict(..))
c

Chris White

02/19/2021, 2:25 AM
yup! it should be returned from `flow.register`:
Copy code
flow_id = flow.register(...)
e

elbaro

02/19/2021, 2:26 AM
It's working! Thanks you all for the help.
🎉 2
c

Chris White

02/19/2021, 2:27 AM
success kid excellent — anytime!! And thanks @Amanda Wee!!
2 Views