Changeset View
Changeset View
Standalone View
Standalone View
docs/content/concepts/dagit/graphql-client.mdx
Show All 33 Lines | - <PyObject | ||||
object="DagsterGraphQLClient" | object="DagsterGraphQLClient" | ||||
method="get_run_status" | method="get_run_status" | ||||
/> | /> | ||||
- <PyObject | - <PyObject | ||||
module="dagster_graphql" | module="dagster_graphql" | ||||
object="DagsterGraphQLClient" | object="DagsterGraphQLClient" | ||||
method="reload_repository_location" | method="reload_repository_location" | ||||
/> | /> | ||||
- <PyObject | |||||
module="dagster_graphql" | |||||
object="DagsterGraphQLClient" | |||||
method="shutdown_repository_location" | |||||
/> | |||||
## Using the GraphQL Client | ## Using the GraphQL Client | ||||
The snippet below shows example instantiation of the client: | The snippet below shows example instantiation of the client: | ||||
```python file=/concepts/dagit/graphql/client_example.py startafter=start_setup_marker endbefore=end_setup_marker | ```python file=/concepts/dagit/graphql/client_example.py startafter=start_setup_marker endbefore=end_setup_marker | ||||
from dagster_graphql import DagsterGraphQLClient | from dagster_graphql import DagsterGraphQLClient | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | new_run_id: str = client.submit_pipeline_execution( | ||||
preset=PRESET_NAME, | preset=PRESET_NAME, | ||||
) | ) | ||||
do_something_on_success(new_run_id) | do_something_on_success(new_run_id) | ||||
except DagsterGraphQLClientError as exc: | except DagsterGraphQLClientError as exc: | ||||
do_something_with_exc(exc) | do_something_with_exc(exc) | ||||
raise exc | raise exc | ||||
``` | ``` | ||||
### Shutting down a Repository Location Server | |||||
If you're running your own gRPC server, 'reload_repository_location' does not restart your server your reload your repository code - instead, it just refreshes the information about your repositories that appears in dagit. In order for your server to reload changes to your code, it must be restarted. | |||||
One way to cause your server to restart and your code to be reloaded is to run your server in an environment like Kubernetes that automatically restarts services when they fail (or docker-compose with `restart: on-failure` set on the service), and then use the `shutdown_repository_location` function on the GraphQL client to shut down the server. The server will then be restarted by your environment, which will be automatically detected by Dagit. | |||||
Example usage: | |||||
```python file=/concepts/dagit/graphql/client_example.py startafter=start_shutdown_repo_location_marker endbefore=end_shutdown_repo_location_marker | |||||
from dagster_graphql import ( | |||||
ShutdownRepositoryLocationInfo, | |||||
ShutdownRepositoryLocationStatus, | |||||
) | |||||
shutdown_info: ShutdownRepositoryLocationInfo = client.shutdown_repository_location(REPO_NAME) | |||||
if shutdown_info.status == ShutdownRepositoryLocationStatus.SUCCESS: | |||||
do_something_on_success() | |||||
else: | |||||
raise Exception(f"Repository location shutdown failed: {shutdown_info.message}") | |||||
``` | |||||
#### Repository Location and Repository Inference | #### Repository Location and Repository Inference | ||||
Note that specifying the repository location name and repository name are not always necessary; the GraphQL client will infer the repository name and repository location name if the pipeline name is unique. | Note that specifying the repository location name and repository name are not always necessary; the GraphQL client will infer the repository name and repository location name if the pipeline name is unique. | ||||
```python file=/concepts/dagit/graphql/client_example.py startafter=start_submit_marker_pipeline_name_only endbefore=end_submit_marker_pipeline_name_only | ```python file=/concepts/dagit/graphql/client_example.py startafter=start_submit_marker_pipeline_name_only endbefore=end_submit_marker_pipeline_name_only | ||||
from dagster_graphql import DagsterGraphQLClientError | from dagster_graphql import DagsterGraphQLClientError | ||||
try: | try: | ||||
Show All 10 Lines |