Skip to main content

GraphQL (dagster-graphql)

Python Client

class dagster_graphql.DagsterGraphQLClient

Official Dagster Python Client for GraphQL.

Utilizes the gql library to dispatch queries over HTTP to a remote Dagster GraphQL Server

As of now, all operations on this client are synchronous.

Intended usage:

client = DagsterGraphQLClient("localhost", port_number=3000)
status = client.get_run_status(**SOME_RUN_ID**)

Parameters:

  • hostname (str) – Hostname for the Dagster GraphQL API, like localhost or
  • port_number (Optional[int]) – Port number to connect to on the host.
  • transport (Optional[Transport], optional) – A custom transport to use to connect to the
  • use_https (bool, optional) – Whether to use https in the URL connection string for the
  • timeout (int) – Number of seconds before requests should time out. Defaults to 60.
  • headers (Optional[Dict[str, str]]) – Additional headers to include in the request. To use

Raises: ConnectionError – if the client cannot connect to the host.

get_run_status

Get the status of a given Pipeline Run.

Parameters: run_id (str) – run id of the requested pipeline run.Raises:

Returns: returns a status Enum describing the state of the requested pipeline runReturn type: DagsterRunStatus

reload_repository_location

Reloads a Dagster Repository Location, which reloads all repositories in that repository location.

This is useful in a variety of contexts, including refreshing the Dagster UI without restarting the server.

Parameters: repository_location_name (str) – The name of the repository locationReturns: Object with information about the result of the reload requestReturn type: ReloadRepositoryLocationInfo

shutdown_repository_location
deprecated

This API will be removed in version 2.0.

Shuts down the server that is serving metadata for the provided repository location.

This is primarily useful when you want the server to be restarted by the compute environment in which it is running (for example, in Kubernetes, the pod in which the server is running will automatically restart when the server is shut down, and the repository metadata will be reloaded)

Parameters: repository_location_name (str) – The name of the repository locationReturns: Object with information about the result of the reload requestReturn type: ShutdownRepositoryLocationInfo

submit_job_execution

Submits a job with attached configuration for execution.

Parameters:

  • job_name (str) – The job’s name
  • repository_location_name (Optional[str]) – The name of the repository location where
  • repository_name (Optional[str]) – The name of the repository where the job is located.
  • run_config (Optional[Union[RunConfigRunConfig, Mapping[str, Any]]]) – This is the run config to execute the job with.
  • tags (Optional[Dict[str, Any]]) – A set of tags to add to the job execution.

Raises:

  • DagsterGraphQLClientErrorDagsterGraphQLClientError("InvalidStepError", invalid_step_key) – the job has an invalid step
  • DagsterGraphQLClientErrorDagsterGraphQLClientError("InvalidOutputError", body=error_object) – some solid has an invalid output within the job.
  • DagsterGraphQLClientErrorDagsterGraphQLClientError("RunConflict", message) – a DagsterRunConflict occured during execution.
  • DagsterGraphQLClientErrorDagsterGraphQLClientError("PipelineConfigurationInvalid", invalid_step_key) – the run_config is not in the expected format
  • DagsterGraphQLClientErrorDagsterGraphQLClientError("JobNotFoundError", message) – the requested job does not exist
  • DagsterGraphQLClientErrorDagsterGraphQLClientError("PythonError", message) – an internal framework error occurred

Returns: run id of the submitted pipeline runReturn type: str

exception dagster_graphql.DagsterGraphQLClientError
class dagster_graphql.InvalidOutputErrorInfo

This class gives information about an InvalidOutputError from submitting a pipeline for execution from GraphQL.

Parameters:

  • step_key (str) – key of the step that failed
  • invalid_output_name (str) – the name of the invalid output from the given step
class dagster_graphql.ReloadRepositoryLocationInfo

This class gives information about the result of reloading a Dagster repository location with a GraphQL mutation.

Parameters:

  • status (ReloadRepositoryLocationStatusReloadRepositoryLocationStatus) – The status of the reload repository location mutation
  • failure_type – (Optional[str], optional): the failure type if status == ReloadRepositoryLocationStatus.FAILURE.
  • message (Optional[str], optional) – the failure message/reason if
class dagster_graphql.ReloadRepositoryLocationStatus

This enum describes the status of a GraphQL mutation to reload a Dagster repository location.

Parameters: Enum (str) – can be either ReloadRepositoryLocationStatus.SUCCESS or ReloadRepositoryLocationStatus.FAILURE.