Joey Allison
03/05/2025, 6:56 PMMarvin
03/05/2025, 6:57 PMPATCH
call for updating deployment schedules might not be well-documented or a known issue. However, the documentation does mention that when updating a deployment schedule, typically only basic information such as a cron string or interval is required. This implies that the API might not handle more complex parameter updates for schedules as expected, potentially leading to them being reset or set to empty objects.
If you are encountering this issue consistently, it might be worth reaching out to Prefect support or checking if there are any updates or patches that address this behavior. You can refer to the Prefect documentation on deployments and schedules for more details: Prefect Deployment Documentation.
If this is a critical issue, consider filing a bug report on the Prefect GitHub repository with details of your API call and the unexpected behavior.Joey Allison
03/05/2025, 10:17 PMimport json
import httpx
# Setup the Client
prefect_client = httpx.Client(
base_url=api_url,
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
},
)
# Get the Existing Flow ID
flow_name = "Test Flow 480a35"
deployment_name = "Test Deployment 480a35"
deployment_resp = prefect_client.get(url=f"deployments/name/{flow_name}/{deployment_name}")
# Update the Flow's schedules (only one in this case) via PATCH
patch_resp = prefect_client.patch(
url=f"deployments/{deployment_resp.json()['id']}",
json={
"schedules": [
{
"parameters": {"foo": "bar"},
"schedule": {
"cron": "*/5 * * * *",
"day_or": True,
"timezone": "America/New_York",
},
},
],
}
)
# Get the updated Flow resp and assert the parameters are present
updated_deployment_resp = prefect_client.get(url=f"deployments/name/{flow_name}/{deployment_name}")
updated_deployment_json = updated_deployment_resp.json()
assert len(updated_deployment_json["schedules"]) == 1
assert updated_deployment_json["schedules"][0]["parameters"] == {"foo": "bar"}
This results in a schedule in the response that does not have any parameters
populated. Everything else for the schedule is present, though. Patching new values for cron
, day_or
, or timezone
updates the schedule as one would expect. When passing parameters
with slug
, the parameters
do update.
Lastly, when passing in an empty array for schedules
, the schedules are not deleted (but this might be intended).Joey Allison
03/06/2025, 8:40 PMNate
03/06/2025, 8:59 PMJoey Allison
03/06/2025, 9:01 PMparameters
is a bug. I'll open an issue for that. Not sure about the rest, though.