Ryan Morshead
07/17/2023, 10:57 PMDeployment.apply
with changes attributes they are not reflected on the Prefect server. Given that Deployment.apply
does not have an override
parameter. How can I update an existing deployment. [SOLVED]Emil Christensen
07/18/2023, 4:15 PM.apply
on a deployment should replace it (or create it if it doesn’t exist).Ryan Morshead
07/18/2023, 4:16 PMinfra_overrides
async def apply_deployment(deployment: Deployment) -> UUID:
"""Apply a deployment or update it if it already exists"""
client = get_client()
try:
existing_deployment = await get_client().read_deployment_by_name(f"{deployment.flow_name}/{deployment.name}")
except ObjectNotFound:
return await deployment.apply()
else:
# copy attributes from my new deployment to the current deployment
for name in deployment.__fields__:
if hasattr(existing_deployment, name):
setattr(existing_deployment, name, getattr(deployment, name))
await client.update_deployment(existing_deployment)
return existing_deployment.id
Emil Christensen
07/18/2023, 4:27 PMDeployment
is what? Is it an instance of prefect.deployments.Deployment
?Ryan Morshead
07/18/2023, 4:29 PMupdate_deployment
seems to expect a DeploymentReponse
or an ORM Deployment
Emil Christensen
07/18/2023, 4:31 PMreturn await deployment.apply()
? Does it give you back the UUID of the deployment?Ryan Morshead
07/18/2023, 4:31 PMapply
unless there’s something special that the backend does with a CreateDeployment
request, it doesn’t seem like apply
should actually update an existing deployment.Deployment.apply
is looking for _block_document_id
here. However, Deployment.load
never seems to set it._block_document_id
is not declared as a Field
of Deployment
(which further suggests this is likely the isssue).Emil Christensen
07/18/2023, 4:59 PMDeployment.build_from_flow
to construct `Deployment`s. Is there a reason you’re constructing it directly?Ryan Morshead
07/18/2023, 5:01 PMDeployment.build_from_flow
load_existing=True