Hi everyone, looking for any tips/pointers on wher...
# prefect-community
j
Hi everyone, looking for any tips/pointers on where I'm going wrong.... I'm a couple days new to Prefect (used Airflow in the past) and I'm trying to just setup a hello world type thing. Using Prefect Core I was able to get running via CLI and also got the scheduling working. My problem comes when I'm trying to visualize and "register" a flow in the UI The UI is up and running, everything is green, I ran
prefect backend server, prefect server start and prefect agent start
in that order but no flow in the UI.
Copy code
import prefect
from prefect import task, Flow

@task
def hello_task():
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>("Hello, Cloud!")

flow = Flow("hello-flow", tasks=[hello_task])

# flow.run()
flow.register()
👀 1
d
Hi @Jason Carter, Welcome! 😄 Can you confirm that your
prefect backend
is properly set in your
config.toml
? Are you receiving an error message when trying to run the above script?
j
Hi @Dylan I've never touched the file downloaded via conda and used
prefect backend server
so I assume it's set correctly but I can reach for the config. And no, I'm not receiving any errors the script runs as expected
python first_flow.py
backend = "cloud"
line 7 of my config file (in a conda env)
@Jason Carter try creating a user configuration file as outlined here. That’s the file that the
prefect backend server
command expects to update
Once that’s done, you should expect registration to work as advertised 👍
j
Thanks @Dylan i'll test that out... Should I have to change that manually or should
prefect backend server
been expected to work? If manually then why the backend server call?
d
prefect backend server
expects to change your user configuration file, but it doesn’t create one for you if it’s not present I think
Once the
$HOME/.prefect/config.toml
exists,
prefect backend server
should update it appropriately and you’ll be all set 👍
j
so I think that's the problem. I don't have a
config.toml
in that location but I do have a
backend.toml
file
with only one line
backend = "server"
d
Interesting
Can you run
prefect config
and
prefect version
for me, please?
m
The UI is up and running, everything is green, I ran 
prefect backend server, prefect server start and prefect agent start
 in that order but no flow in the UI.
Just checking, once you did all this did you also run
python my_flow_file.py
as well? That's a step that isn't necessary in airflow but is necessary in prefect
j
Hi @Dylan @Matt Allen thanks for you questions and suggestions. It's now working and I think there were a few issues on my first install but also the last step by Matt running
python file_name.py
brought everything together. Seems like a manual step for production CI/CD process, but I'm sure I just haven't gotten to those docs yet.
If you're wondering what I did to fix things, I basically started over from scratch...
Copy code
1. Updated Conda
2. Created condo env on python3 (latest)
3. Had issues, chat on Slack, starting over
4. Remove all previous versions globally and in the env plus delete left over files
5. Env - installed prefect -c condo-forge prefect
6. Prefect config gives "cloud" as backend
7. Prefect config (~/.prefect) but no actual folder, the only config.toml on machine is in condo env
8. Prefect version (0.12.5)
9. Prefect backend server
10. Prefect config now gives "server" as backend
11. Added "flow.run()" and executed from cli - worked
12. Commented out "flow.run()" and added "flow.register()"
13. Refreshed prefect UI, nothing in "flow" shows up
14. Start "docker agent" prefect agent start docker
15. Nothing showing up in Prefect UI
16. Ran $python first_flow.py flow is now showing up in UI
d
🎉