Dagster Cloud CLI
The `dagster-cloud-cli` provides command-line tools for interacting with Dagster Cloud, enabling operations such as deploying code, managing agents, and configuring workspaces. It is the primary interface for developers to manage their Dagster deployments in a Dagster Cloud environment. The current version is 1.13.0, with releases tightly coupled to the broader Dagster ecosystem's frequent update cadence.
Warnings
- gotcha The `dagster-cloud-cli` (`dg` command) is a command-line interface. For programmatic interaction with Dagster Cloud services (e.g., fetching run metadata, launching runs from Python), you should use the `dagster-cloud` Python library (SDK) instead of attempting to import from or wrap the CLI tool.
- gotcha Authentication for `dagster-cloud-cli` typically requires setting the `DAGSTER_CLOUD_AGENT_TOKEN` environment variable or using `dg login`. Operations like `dg deploy` will fail without proper authentication.
- gotcha When deploying code using `dg plus deploy`, a `dagster_cloud.yaml` configuration file and a properly structured Dagster project are required in the current directory or specified path. Missing or misconfigured files will prevent successful deployment.
- breaking Beginning with Dagster core version 1.12.18 (which `dagster-cloud-cli` depends on), `psycopg2-binary` was removed as a transitive dependency from `dagster-postgres`. If your project relies on `dagster-postgres` and implicitly depended on this, you may encounter import errors.
Install
-
pip install dagster-cloud-cli
Quickstart
import subprocess
import os
# The dagster-cloud-cli is primarily used via the 'dg' command in the terminal.
# This quickstart demonstrates checking its version programmatically.
try:
# This runs a basic 'dg --version' command to verify installation.
# For actual Dagster Cloud operations (e.g., 'dg deploy'), you would typically
# execute commands directly in your shell or CI/CD scripts.
print("Running: dg --version")
result = subprocess.run(["dg", "--version"], capture_output=True, text=True, check=True)
print("\nDagster Cloud CLI Version Information:")
print(result.stdout)
print("Ensure 'dg' is in your system's PATH after installation.")
except FileNotFoundError:
print("Error: 'dg' command not found. Ensure dagster-cloud-cli is installed and in your PATH.")
except subprocess.CalledProcessError as e:
print(f"Error running dg command: {e}")
print(f"Stdout: {e.stdout}")
print(f"Stderr: {e.stderr}")