https://prefect.io logo
Title
d

Dave Wei

05/15/2023, 9:21 PM
hi everyone, anyone know how to schedule cron jobs on UI now? I’m not seeing deployments in my prefect cloud as well.
1
w

Will Raphaelson

05/15/2023, 9:32 PM
Hi Ofir - the flow and deployment pages are now combined. You can navigate to your deployment from the flows page where you can add a cron string.
d

Dave Wei

05/15/2023, 9:34 PM
hi @Will Raphaelson thanks for helping, i tried to click that burger icon, only see copy id and automate, should i choose automate?
image.png
hmmm, but there is no way to create a deployment..
w

Will Raphaelson

05/15/2023, 9:41 PM
Deployments are created via the API using either the CLI or the python class. After its created, you can add a cron string as a schedule via the UI. https://docs.prefect.io/latest/concepts/deployments/
d

Dave Wei

05/15/2023, 9:59 PM
is it still possible to directly add schedule on ui?
image.png
e

Emil Ordoñez

05/15/2023, 10:00 PM
You still have to create the deployment, and as I understand, that's not posible from the UI, you have to deploy your Flow first
w

Will Raphaelson

05/15/2023, 10:01 PM
Emil is correct, thanks Emil. You’ll need to create the deployment (i like using the CLI) first, and then once the deployment is created you’ll see an option in the ui like this
👍 1
e

Emil Ordoñez

05/15/2023, 10:04 PM
in the new UI, you go to the Flows section and there you'll find a Deployments dropdown for the Deployed Flows and there you can go to edit your deployment:
🙏 1
and yes, you are still able to create Schedules using the UI, but based on your screenshots, your Flow is still not Deployed
d

Dave Wei

05/15/2023, 10:42 PM
image.png
image.png
i tried to apply the super simple deployment yaml file, but keep getting error like this…
e

Emil Ordoñez

05/15/2023, 10:52 PM
I'm not sure if I can help you with that error. I prefer deploying using Python, maybe this example can help you:
from prefect.deployments import Deployment

@flow
def your_flow_function():
    return 0

def deploy_flows():
    depl_flow = Deployment.build_from_flow(flow=your_flow_function, name="deploymentname", 
                                                  work_queue_name='yourqueue')
    depl_flow.apply()

if __name__ == "__main__":
    deploy_flows()
d

Dave Wei

05/15/2023, 10:53 PM
😂 i kinda know what’s going on, I need to build the yaml file first by
prefect deployment build
e

Emil Ordoñez

05/15/2023, 10:54 PM
yeap
the build command first and then the apply
I think you can do that also in a single step by sending
--apply
on the `build`command
🙌 1
prefect deployment build your_python_file.py:your_flow_function --name deploymentname --work-queue workqueuename --apply
at least back in the days that's what I did
now I'm not sure if that should work with the new concepts of work pools
d

Dave Wei

05/15/2023, 11:05 PM
--apply
cmd is super useful sir
im wondering do i have to build such deployment file every time when i create new flow?
e

Emil Ordoñez

05/15/2023, 11:07 PM
that's why I use python instead of CLI for deployments, I can just have a python deployment file sitting in the same folder where my new flow is also sitting
d

Dave Wei

05/15/2023, 11:23 PM
after putting the deployment file in the folder, how to “trigger” it?
e

Emil Ordoñez

05/15/2023, 11:24 PM
just run it, but you can also do the same that I did in the Python example code that I shared here
d

Dave Wei

05/15/2023, 11:29 PM
image.png
yeah, i created a deployment python script by referring to the document
@Emil Ordoñez sir do you know why my flows always show “late” after deployed, did it happen to you as well?
e

Emil Ordoñez

05/16/2023, 2:16 PM
If you don't have an agent running, you won't be able to run your deployments. Go read the agents section on the Concepts page: https://docs.prefect.io/latest/concepts/work-pools/
d

Dave Wei

05/16/2023, 6:14 PM
i created a work pool and attached all deployments to it, its working well now!
thanks Emil!