https://prefect.io logo
#prefect-community
Title
# prefect-community
i

Iuliia Volkova

07/01/2022, 12:47 PM
@Anna Geller hi Anna, I have a couple of questions relative to Prefect 2.0 - in thread.
1
1) We are building an interface with Prefect 2.0 REST API under the hood and I need to get the last deployments for each flow. I don't see how I can do this with existed REST API. I thought to use https://orion-docs.prefect.io/api-ref/rest-api/#/Deployments/read_deployments_deployments_filter_post but it doesn't have way to get latest deployments or maybe I missed something. It will be useful to have some filtering by 'latest per flow' to get the last versions of the deployments that was done. Thanks for any help. Also if it is not done & will be useful for community - I can prepare PR for this. 2) if there any updates about this issue - https://github.com/PrefectHQ/prefect/issues/5524 (
manual_only)
? Is it planned or already in work by someone or help needed?
a

Anna Geller

07/01/2022, 12:52 PM
1. what do you mean by last deployment? each flow can have multiple deployments associated with that flow 2. this one is out of scope for GA, if we would do it, most likely in Q4 or next year - if this is important to you, feel free to give it a try and contribute a PR
i

Iuliia Volkova

07/01/2022, 12:53 PM
@Anna Geller I mean last in time, so latest by created date
a

Anna Geller

07/01/2022, 12:54 PM
what are you trying to do that way?
i

Iuliia Volkova

07/01/2022, 12:54 PM
like we have a flow & we want to create the new flow runs only for the latest deployment with last actual code
maybe there is a different way in Prefect to do this 🙂
a

Anna Geller

07/01/2022, 12:56 PM
it's hard to understand why you would need that/why you would need to do it that way... can you explain your business use case for that? Could you solve that by assigning a schedule? Do you plan to have more than one deployment per flow?
you can definitely list deployments and then filter by date in your Python code, sth like this:
Copy code
import asyncio
from prefect.client import get_client
from prefect.orion.schemas.filters import DeploymentFilter, DeploymentFilterTags


async def main():
    tag_filter = DeploymentFilterTags(all_=["local"])
    filter_ = DeploymentFilter(tags=tag_filter)
    async with get_client() as client:
        response = await client.read_deployments(deployment_filter=filter_)
        print(response)


if __name__ == "__main__":
    asyncio.run(main())
i

Iuliia Volkova

07/01/2022, 12:59 PM
we don't want to call prefect as dependency, this is why we use Prefect 2.0 & REST API
so we have layer that manage to work not only with Prefect as flow runner, it communicate with prefect only by REST API this is why I'm asking about it )
but, you give me the idea how make the workaround with tags 🙂 thank you
a

Anna Geller

07/01/2022, 1:02 PM
awesome, good luck! 🤞
6 Views