https://dagster.io/ logo
Title
s

Spencer Guy

10/08/2022, 3:40 PM
Is it possible to submit runs to the Run Coordinator from an external application?
a

Archie Kennedy

10/09/2022, 3:49 PM
This can be done via the GraphQL API. Here is my implementation:
import requests

query = """
mutation LaunchRunMutation(
  $repositoryLocationName: String!
  $repositoryName: String!
  $jobName: String!
  $runConfigData: RunConfigData!
) {
  launchRun(
    executionParams: {
      selector: {
        repositoryLocationName: $repositoryLocationName
        repositoryName: $repositoryName
        jobName: $jobName
      }
      runConfigData: $runConfigData
    }
  ) {
    __typename
    ... on LaunchRunSuccess {
      run {
        runId
      }
    }
    ... on RunConfigValidationInvalid {
      errors {
        message
        reason
      }
    }
    ... on PythonError {
      message
    }
  }
}
"""

variables = {
    "repositoryLocationName": "your_dagster_repo",
    "repositoryName": "your_dagster_repo",
    "jobName": "your_job",
    "runConfigData": {} # This is where op config goes
}

response = <http://requests.post|requests.post>(
    "<https://your-dagster.dagster.cloud/prod/graphql>",
    json={"query": query, "variables": variables},
    headers={"Dagster-Cloud-Api-Token": "<DAGSTER CLOUD SECRET>"},
)
s

Spencer Guy

10/13/2022, 9:39 PM
Thanks for the example code @Archie Kennedy 🙌