I got a question, can we not see the Prefect UI un...
# ask-community
m
I got a question, can we not see the Prefect UI unless we use Prefect Cloud?
โœ… 1
j
If you self host you can get a very similar (albeit missing some features) based on my experience
m
Host myself meaning Kubernetes or something like that? Not on localhost?
j
I searched for k8 hosting documentation and didn't find anything so I just spun up an instance and did it from there
for "prefect-server"
m
Can I host this prefect-server locally? Like for airflow, I could start a local server and I can see Airflow UI and everything. But when I was trying out Prefect locally, it seemed like I needed to set up Prefect Cloud in order to get access to the UI.
j
you can host locally or on a container and change the PREFECT_API_URL to something like 127.0.0.1 or whatever host:port you setup the server to
๐Ÿค” 1
m
Okay, thanks a lot. Going to take a second look.
j
Prefect Cloud does have a free tier that might be a lot easier to get started with if that is an option for you
m
Yeah, I had to do that in order to get the UI. Just wondering if I can do a POC completely locally without Prefect Cloud.
Where can I change the PREFECT_API_URL?
j
yup you can, I think you can even do it within a docker container using something like docker compose
but that is more of a POC and I doubt would scale
its just an environment variable
so if you're POC'ing in docker compose you can set it there
you can also use a prefect command I believe
to overwrite it too which might be required, just search it
m
Just POCing for now. My team might get enterprise if all goes well.
j
hey! you can get started with prefect entirely locally: to spin up a server you use
prefect server start
and you'll have the API and UI available (related docs for self hosting) It's really easy to do a POC with cloud as well, everyone gets a free account. Cloud effectively is us hosting the UI/API for you (with a bunch of other additions ๐Ÿ™‚)
๐Ÿ‘€ 1
m
Their intro video I followed

https://www.youtube.com/watch?v=FNVP-fTJMYgโ–พ

also just showed using Prefect Cloud.
Thanks, I'll check it out.
๐Ÿ‘ 1
Hmm, not working for me. I'm missing something.
@Jake Kaplan So I ran started a local server
prefect server start
in which I can view the UI. Then I ran my simple python prefect script, which completes successfully. But I do not see this in my local UI.
j
in that other screenshot you posted it look like you were already connected to Cloud? Is
PREFECT_API_URL
set in your profile (
prefect profile inspect
to check) or as an env var? If so you may need to unset it
or if you can show the me the output of
prefect version
I can see what youre connected to
m
Yep, looks like I'm connected to cloud.
How do I unset it from Cloud?
j
prefect cloud logout
๐Ÿ‘ 1
m
Is there a documentation for switching between cloud and local?
j
If you want to not have to worry about logging in/out the easiest thing to do is use profiles https://docs.prefect.io/2.10.12/concepts/settings/?h=profil#creating-and-removing-profiles
Copy code
prefect profile create local_profile
prefect profile create cloud_profile
prefect profile use cloud_profile
prefect cloud login
...
Copy code
prefect profile ls
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Available Profiles: โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚             default โ”‚
โ”‚       local_profile โ”‚
โ”‚     * cloud_profile โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
   * active profile
you'll have two profiles that you can switch between with
prefect profile use <profile name>
๐Ÿ‘ 1
m
@Jake Kaplan Follow up question. If I were to start over from scratch and want to test prefect and the UI locally, do I still need to create a deployment/start a worker and work-pool?
j
Hey there, could you give a little more context?
m
Sorry if it's confusing. So before, I was following a tutorial to use prefect cloud and created a deployment. And was able to run everything on prefect cloud. And then, I wanted to test the same flow completely locally. At that point, all I needed to do was:
Copy code
prefect cloud logout
prefect server start
And then I could run my flow and see UI all locally. Now I want to test out another flow on a separate computer. And want to do things locally as well for now. Do I still need to make a deployment (which I think automatically creates a work-pool and worker)?
j
when doing this step:
Copy code
prefect cloud logout
prefect server start
you're effectively saying stop pointing to our (PrefectCloud) backend and start pointing to a local backend on your machine. so if you change machines and want to run against a local backend on your new machine, you'll need to recreate any objects you care about, deployments or otherwise
does that help?
m
Thanks so much for your help. So, essentially, even if I only want to run it completely locally, I still need to create a deployment to be able to launch prefect UI and run
prefect server start
. Is that correct?
j
nope. sorry if I was confusing. you can run
prefect server start
out of the box without anything existing already to launch the UI
โœ… 1
m
Okay, thanks!
j
hey i'm not totally certain, I don't have of experience running on windows. Would you mind opening an issue here: https://github.com/PrefectHQ/prefect/issues?