Paige Gulley
07/16/2024, 8:54 PMPaige Gulley
07/16/2024, 8:56 PMdeployment_filter = DeploymentFilter(
name=DeploymentFilterName(any_=["deployment-name"])
)
#get the deployment from the name, and then create a run!
async with prefect.get_client() as client:
response = await client.read_deployments(deployment_filter=deployment_filter)
#print(response[0].id)
run = await client.create_flow_run_from_deployment(response[0].id, tags=["my-tag"])
print(run)
Paige Gulley
07/16/2024, 8:57 PMthis_run_filter = FlowRunFilter(
id=FlowRunFilterId(any_=[run.id])
)
async with prefect.get_client() as client:
run_info = await client.read_flow_runs(flow_run_filter=this_run_filter)
print(run_info[0].state_type == StateType.RUNNING or
run_info[0].state_type == StateType.SCHEDULED or
run_info[0].state_type == StateType.PENDING)
Paige Gulley
07/16/2024, 8:59 PM#Get running and tagged flow runs
running_filter = FlowRunFilter(
state=FlowRunFilterStateType(any_=[StateType.RUNNING, StateType.SCHEDULED,StateType.PENDING])
)
async with prefect.get_client() as client:
run_info = await client.read_flow_runs(flow_run_filter=running_filter)
print(len(run_info)) #I always get a value of 200 here (mostly a big backlog of completed runs)
print(run_info[0]) #a random old completed run.
Paige Gulley
07/16/2024, 9:00 PMPaige Gulley
07/16/2024, 9:05 PMPaige Gulley
07/16/2024, 9:05 PMrunning_tagged_filter = FlowRunFilter(
state=FlowRunFilterState(
type=FlowRunFilterStateType(any_=[StateType.RUNNING, StateType.SCHEDULED,StateType.PENDING])))
Paige Gulley
07/16/2024, 9:06 PM