David Salgado
09/25/2023, 6:56 AMimport asyncio
import prefect.client.schemas.filters as filters
from prefect.client.orchestration import get_client
from prefect.server.schemas.states import StateType
run_ids = [ ... a list of the flow run IDs I'm interested in ... ]
client = get_client()
tasks = asyncio.run(
client.read_task_runs(
flow_run_filter=filters.FlowRunFilter(id=filters.FlowRunFilterId(any_=run_ids)), # <-- This works by itself
task_run_filter=filters.TaskRunFilterState(type=filters.TaskRunFilterStateType(any_=[StateType.FAILED])), # <-- this doesn't work
)
)
This fails with:
prefect.exceptions.PrefectHTTPStatusError: Client error '422 Unprocessable Entity' for url '<https://api.prefect.cloud/api/accounts/8d8b3f47-6199-40be-98a9-1bc1b3056ee4/workspaces/71539e7c-8525-4c61-842e-90aba3248e79/task_runs/filter>'
Response: {'exception_message': 'Invalid request received.', 'exception_detail': [{'loc': ['body', 'task_runs', 'type'], 'msg': 'extra fields not permitted', 'type': 'value_error.extra'}], 'request_body': {'flows': None, 'flow_runs': {'id': {'any_': ['7924bcd8-8dea-46a0-a6f4-f47fc84002dd', 'ad2d8cd7-8302-4bf2-b434-5f923ded1ec3', '239fc509-f4b1-4b20-a37d-4a66c4d6ef37', '4e5fa333-ecf6-4a9b-bc7c-1572b8c1c4b9', '2d995267-d507-48c1-a2f4-d1b4ef60bbec']}}, 'task_runs': {'type': {'any_': ['FAILED']}, 'name': None}, 'deployments': None, 'sort': None, 'limit': None, 'offset': 0}}
I've tried a few variants for the task_run_filter
but I always get more of less the same error.