Hi, is there a way from Prefect client to know whe...
# ask-community
g
Hi, is there a way from Prefect client to know when a deployment has been updated? I mean when was last time prefect deployment has been execute on a specific deployment. If it is not possible through Prefect client, is this info stored in Orion backend database?
n
hi @Giacomo Chiarella - yes all prefect objects have
created
and
updated
fields like this
Copy code
In [1]: from prefect import get_client

In [2]: async with get_client() as client:
   ...:     deployment = await client.read_deployment("<some UUID>")
   ...:

In [3]: deployment
Out[3]: DeploymentResponse(...)

In [4]: deployment.updated
Out[4]: DateTime(2024, 3, 7, 2, 5, 49, 730749, tzinfo=Timezone('UTC'))
g
I’ve noticed actually the updated field is updated also in other situations not only when a deployment is created/updated. I was looking for something to tell me when Flow.deploy has been invoked last time
I can see the updated field is updated also in other moments (probably related to the scheduler)
n
you could probably just create a prefect variable and update that after you call flow.deploy?
g
that is a solution. I was looking for something cleaner because I will need to create a variable for each deployment
n
if you're looking for something more specific to your needs than what currently exists as
updated
then a variable seems simplest to me
g
yes, I think so
👍 1
n
or perhaps a single variable like
dict[str, datetime]
g
in that case I should be careful about concurrency, better a variable per deployment
👍 1