I created a deployment, then I added a schedule from the UI. When I then reran the “build” step, the YAML file had the same schedule as I defined from the UI, even though I didn’t specify that schedule manually from CLI or in YAML. Why is that happening?

Deployment is an API-first concept. Therefore the API is a single source of truth rather than the YAML manifest or CLI command.

This means that anytime you modify any attribute of deployment from the UI, CLI, or via an API call (incl. changing default parameters or schedules, storage, and infrastructure blocks), any of those actions trigger a change in the corresponding deployment attribute.

Relying purely on YAML for that can only serve as a single source of truth if the YAML file is the only way you define your deployments (which is a totally valid option!).

In all other cases, inspecting the state of deployment in the backend from the UI, or the CLI command shown below, will give you the information about the current state:

prefect deployment inspect flow_name/deployment_name