```Need help here. Trying to do in python as below...
# ask-community
s
Copy code
Need help here. Trying to do in python as below. This is to check the flow state and cancel in the flow is in running state. How to pass the values to "$flowRunId: UUID!"                                                                                                                        import prefect
from prefect import Client
from prefect import task, Flow
@task()
def check_runs():
  c = Client()
  query = """
  query RunningFlowsName {
  flow(where: {name: {_eq: "flowstatechecktest"}}) {
    id
  } }  """
  print('======')
  print(c.graphql(query=query))

  query2 = """
  query RunningFlowsState {
  flow_run(where: {state: {_eq: "Running"}}) {
    state
  }  }  """
  print('======')
  print(c.graphql(query=query2))

  query3 = """
  mutation CancelFlowRun($flowRunId: UUID!) {
  cancel_flow_run(input: {flow_run_id: $flowRunId}) {
    state
  }  }  """
  c.graphql(query=query3)

with Flow("flowstatechecktest") as flow:
    check_runs()
flow.run()
j
Hi @S K - We have a CancelFlowRun task that should help you here. If you don't want to use the task, the code in there should still be useful to you.
upvote 1