hi everyone, anyone know how to schedule cron jobs...
# ask-community
d
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
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
hi @Will Raphaelson thanks for helping, i tried to click that burger icon, only see copy id and automate, should i choose automate?
hmmm, but there is no way to create a deployment..
w
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
is it still possible to directly add schedule on ui?
e
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
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
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
i tried to apply the super simple deployment yaml file, but keep getting error like this…
e
I'm not sure if I can help you with that error. I prefer deploying using Python, maybe this example can help you:
Copy code
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
😂 i kinda know what’s going on, I need to build the yaml file first by
Copy code
prefect deployment build
e
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
Copy code
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
--apply
cmd is super useful sir
im wondering do i have to build such deployment file every time when i create new flow?
e
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
after putting the deployment file in the folder, how to “trigger” it?
e
just run it, but you can also do the same that I did in the Python example code that I shared here
d
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
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
i created a work pool and attached all deployments to it, its working well now!
thanks Emil!