Stéphan Taljaard
05/25/2021, 10:58 AMwhich prefect
== /home/staljaard/.local/bin/prefect
)
How would you recommend installing/configuring my prefect CLI and _pip install_ed prefect (agent) to be available for all users SSH'ing into the VM?Kevin Kho
Zanie
YD
06/28/2021, 11:40 PMprefect agent docker start
, I see INFO - agent | Waiting for flow runs...
but I do not see any agent when going to <VM IP>:8080/?agents=
• How did you run the agent in a way that it is shows in the <VM IP>:8080/?agents=
?
• How did you setup the Prefect connection in python code running on different machines (other VMs) to connect to that specific instance?
ThanksKevin Kho
prefect backend server
already? And also configured your API endpoint to that VM? Were you able to register a flow and have it appear?YD
06/29/2021, 7:47 PMprefect backend server
and prefect server start --detach
not sure where are the instruction on how to configure my API endpoint to that VM.
can you please point me to them ?
flow does not appear and neither that agentKevin Kho
apollo_url="http://<your-ip-address>:4200/graphql"
YD
06/29/2021, 9:11 PM~/.prefect/config.toml
it should not exist? I do not see it in my home directory
does it matter if I use docker and added alias docker-compose="TMPDIR=${HOME}/tmp docker-compose"
to my .bash_profile ?Kevin Kho
config.toml
will be on the agent side/registration machine side. You can create it if it doesn’t exist. Let me find a template. Are you using Docker for the agent?config.toml
YD
06/29/2021, 9:37 PMLocalAgent().start()
, this started an agent that stayed on.
On the VM, running this basic code does not appear to work.
I tried starting the agent from the python code
and from the command line, both with and without docker.
it looks like it starting an agent, but it just waits for flow run, and does not show up in the dashboard, and does not persisthello-world
code I am trying is
'''
from prefect import task, Flow, Parameter
from prefect.agent.local import LocalAgent
@task(log_stdout=True)
def say_hello(name):
print("Hello, {}!".format(name))
def main():
with Flow("hello_world") as flow:
name = Parameter('name')
say_hello(name='world')
flow.run()
LocalAgent().start()
flow.register(project_name="Test")
print('done')
if __name__ == "__main__":
main()
'''Kevin Kho
def main():
with Flow("hello_world") as flow:
name = Parameter('name')
say_hello(name='world')
flow.run()
# flow.register(project_name="Test")
flow.run()
would be for local testing. flow.register()
would be to register to Cloud/Server when ready.
Then you can start your agent with another script:
from prefect.agent.local import LocalAgent
LocalAgent().start()
This would then start your agent if you call it with python ____.py
. The reason is that the previous setup spins up an agent every time you register. You want to separate these. An agent can run multiple flows. You can also do prefect local agent start
with the command line instead of the script.
Now there are two things to test. You said that the agent is not showing in the UI. If you do python _____.py
to register the flow, does it show in the UI? If the registered flow does not show in the UI, and the agent is running but does not show in the UI, then it means the API endpoint that these are hitting is not the one you want. By default with server, it will hit localhost:4200
. You want it to hit VM IP:4200
instead.
This is why you need the config.toml
in your .prefect
folder in the home directory of the machine the agent is running on to point to the right API endpoint. You file should look like
backend = "server"
[server]
host = "<http://SERVER-VM-IP>"
port = "4200"
host_port = "4200"
This will make the agent and flow.register()
send requests to the right API.YD
06/29/2021, 10:37 PMconfig.toml
in ~/.prefect
with the following content:
[server]
host = "<http://aws31-x01-my01>"
port = "4200"
host_port = "4200"
[server.ui]
apollo_url="<http://aws31-x01-my01:4200/graphql>"
then I ran
prefect backend server
prefect server stop
prefect server start -d
but it looks like it ignores the config file<http://aws31-x01-my01:4200/graphql>
in my browser I get<http://aws31-x01-my01:8080/>
opens the server UI, but tries to connect to the <http://localhost:4200/graphql>
Getting started
page
in that page I entered the graphql
IP address
then clicked connect and this did the trick
it is now connected to the correct IP
and I was able to create a docker agent.Kevin Kho
YD
06/30/2021, 11:42 PMprefect backend server
or prefect server start
or install Docker, correct?Kevin Kho
prefect backend server
because the default is to use the Prefect Cloud API end point. You should not do prefect server start
. You would need to install docker if your flows depend on itYD
07/01/2021, 7:19 PMKevin Kho
YD
07/01/2021, 7:22 PMKevin Kho
YD
07/01/2021, 7:29 PM% prefect agent docker start
--agent-address http://<Server IP>:8080
it did not like thatKevin Kho
YD
07/01/2021, 7:37 PMKevin Kho
prefect agent ____ start log-level=DEBUG
and you can see why it’s struggling to connect to the ServerYD
07/01/2021, 7:45 PMKevin Kho
YD
07/01/2021, 7:54 PMKevin Kho
YD
07/01/2021, 8:01 PMsupervisor
?Kevin Kho
YD
07/01/2021, 9:44 PMsupervisor
I must provide label, is this expected ?Kevin Kho
YD
07/01/2021, 9:55 PMsupervisor
I did not have to provide a label, but when I use supervisor
I had to add --label <computer name>
for it to run.
and it created a new agent on the Prefect serverKevin Kho