https://dagster.io/ logo
#ask-community
Title
# ask-community
s

Son Giang

05/21/2022, 11:13 AM
Hi there, Is there any way to terminate all the runs in dagit UI of a backfill/partition job that I don’t know of? Right now I have to terminate for each page, which contains maximum 25 runs. Thank you.
1
dagster bot resolve to issue 1
l

Liezl Puzon

05/22/2022, 7:52 PM
it’s gross but here’s what I do: dagit.domain.com/graphql
Copy code
import subprocess
# Query:
# query RunsRootQuery($limit: Int, $filter: RunsFilter!) {
#       pipelineRunsOrError(limit: $limit, filter: $filter) {
#         ... on Runs {
#           results {
#             runId
#           }
#       }
#       __typename
#     }
#   }
# Query Variables:
# {
#   "limit": 2500,
#   "filter": {"statuses": ["STARTED", "STARTING", "CANCELING"]}
# }
python script:
Copy code
runs = [
 "ae3369f1-bafe-408f-aefc-4abf8fda85e2",
    "b4a9fa08-fa6d-407d-a4f8-d8cee410e87b",
    "96f54815-5a30-4c7c-bf26-da589f9de4c5",
    "01eb0cb1-3abf-46df-835f-8f5d71e86d7e", …
]
curl_cmd = """
curl '<https://dagit>.<INSERT YOUR DOMAIN.com>/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: <https://dagit>.<INSERT YOUR DOMAIN.com>' --data-binary '{"query":"# Write your query or mutation here\\nmutation TerminateRun($runId: String!) {\\n  terminateRun(runId: $runId, terminatePolicy: MARK_AS_CANCELED_IMMEDIATELY){\\n    __typename\\n    ... on TerminateRunSuccess{\\n      run {\\n        runId\\n      }\\n    }\\n    ... on TerminateRunFailure {\\n      message\\n    }\\n    ... on RunNotFoundError {\\n      runId\\n    }\\n    ... on PythonError {\\n      message\\n      stack\\n    }\\n  }\\n}\\n","variables":{"runId":"<RUN_ID>"}}' --compressed --cookie "GCP_IAP_UID=<GRAB FROM NETWORK TAB ON dagit.DOMAIN.com/graphql>" --cookie "GCP_IAAP_AUTH_TOKEN_...=<GRAB FROM NETWORK TAB ON dagit.DOMAIN.com/graphql>"
"""
for run in runs:
    cmd = curl_cmd.replace("<RUN_ID>", run)
    # print(cmd)
    return_code = subprocess.call(cmd, shell=True)
you have to replace this: 1. runs = [x,y,z] based on the result of the first graphql query
RunsRootQuery
2. 2 instances of
<INSERT YOUR <http://DOMAIN.com|DOMAIN.com>>
3. 2 cookies
<GRAB FROM NETWORK TAB ON <http://dagit.DOMAIN.com/graphql|dagit.DOMAIN.com/graphql>>
with the cookie values taken from the Network tab when issuing queries from dagit.DOMAIN.com/graphql
for dagster.cloud you have to use user API token instead of the 2 cookies
for the python script I use python3
although I’m hoping this would make a good feature request since I’ve seen multiple people ask for bulk-kill tools this process seems so complex
s

Son Giang

05/23/2022, 4:36 AM
thank you, I agree. This need to be a feature though.
👍 1
l

Liezl Puzon

05/23/2022, 2:48 PM
I shared it to the #dagster-feedback channel and josh created a task for this feature request!
👍 1
9 Views