Dagster Cloud
Dagster Cloud is a fully-managed cloud platform for Dagster, providing hosted orchestration, development tools, and operations dashboards. The `dagster-cloud` Python library offers a client to interact with the Dagster Cloud API programmatically, manage deployments, and configure agents. It is currently at version 1.13.0 and follows the Dagster core library's release cadence, typically releasing new versions monthly.
Warnings
- gotcha Authentication to Dagster Cloud requires setting `DAGSTER_CLOUD_ORGANIZATION_ID` and `DAGSTER_CLOUD_API_TOKEN` environment variables. Without these, client initialization will fail or lead to unauthorized access errors.
- breaking The `dagster-cloud` library must be compatible with the core `dagster` library. Significant version mismatches (e.g., pre-1.0 `dagster` with 1.x `dagster-cloud`) can lead to import errors, runtime exceptions, or unexpected behavior due to API changes and data model evolution.
- gotcha Changes to deployment models (e.g., agent-based, hybrid, serverless) often require updates to `dagster-cloud` configuration or even CLI commands. Relying on outdated deployment patterns with newer `dagster-cloud` versions can lead to deployment failures or inefficiencies.
Install
-
pip install dagster-cloud
Imports
- DagsterCloudClient
from dagster_cloud.client import DagsterCloudClient
- DagsterCloudCodeLocation
from dagster_cloud.dagster_cloud_definitions import DagsterCloudCodeLocation
Quickstart
import os
from dagster_cloud.client import DagsterCloudClient
# Ensure these environment variables are set:
# DAGSTER_CLOUD_ORGANIZATION_ID
# DAGSTER_CLOUD_API_TOKEN
organization_id = os.environ.get('DAGSTER_CLOUD_ORGANIZATION_ID', 'your_org_id_here')
api_token = os.environ.get('DAGSTER_CLOUD_API_TOKEN', 'your_api_token_here')
if not organization_id or not api_token:
print("Error: DAGSTER_CLOUD_ORGANIZATION_ID and DAGSTER_CLOUD_API_TOKEN must be set.")
exit(1)
try:
client = DagsterCloudClient(
organization_id=organization_id,
api_token=api_token
)
# Example: List available workspaces
workspaces = client.get_workspaces()
print(f"Found {len(workspaces)} workspaces in Dagster Cloud:")
for ws in workspaces:
print(f"- {ws.name} (ID: {ws.id})")
except Exception as e:
print(f"An error occurred: {e}")