{"id":3442,"library":"dagster-dg-cli","title":"Dagster dg-cli","description":"The `dagster-dg-cli` package provides the command-line interface (CLI) for interacting with Dagster, a Python-native data orchestrator. It allows users to create projects, launch the Dagit UI, deploy to Dagster Cloud, and manage assets, jobs, and runs. The library frequently updates, often on a weekly cadence, in sync with the broader Dagster ecosystem. The current version is 1.13.0.","status":"active","version":"1.13.0","language":"en","source_language":"en","source_url":"https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-dg-cli","tags":["cli","data orchestration","dagster","etl","orchestration"],"install":[{"cmd":"pip install dagster-dg-cli","lang":"bash","label":"Install dg-cli"}],"dependencies":[{"reason":"The core Dagster library, required for most functionality.","package":"dagster","optional":false},{"reason":"Required for 'dg plus deploy' and Dagster Cloud interactions.","package":"dagster-cloud","optional":true}],"imports":[{"note":"This package is primarily a command-line interface (CLI) wrapper. Direct Python imports of 'main' into user code are rare; its primary utility is via the `dg` shell command.","symbol":"main","correct":"from dagster_dg_cli.cli import main"}],"quickstart":{"code":"import subprocess\nimport os\nimport time\n\nproject_name = \"my-dagster-quickstart\"\n\n# 1. Create a new Dagster project\nprint(f\"Attempting to create a new Dagster project '{project_name}'...\")\ntry:\n    # `dg new` automatically creates the directory if it doesn't exist\n    result = subprocess.run([\"dg\", \"new\", project_name], check=True, capture_output=True, text=True, timeout=30)\n    print(f\"Project '{project_name}' created successfully:\\n{result.stdout}\")\nexcept subprocess.CalledProcessError as e:\n    # Handle case where project already exists\n    if \"already exists\" in e.stderr:\n        print(f\"Project '{project_name}' already exists. Skipping creation.\")\n    else:\n        print(f\"Error creating project: {e.stderr}\")\n        raise\nexcept subprocess.TimeoutExpired:\n    print(f\"Error: 'dg new' command timed out after 30 seconds.\")\n    raise\nexcept FileNotFoundError:\n    print(\"Error: 'dg' command not found. Ensure dagster-dg-cli is installed and in your PATH.\")\n    raise\n\n# Change into the new project directory\nif os.path.exists(project_name):\n    print(f\"Changing directory to '{project_name}'...\")\n    os.chdir(project_name)\nelse:\n    print(f\"Could not find project directory '{project_name}' to change into. Exiting.\")\n    exit(1)\n\n# 2. Launch the Dagster UI (Dagit)\nprint(\"\\nTo launch the Dagster UI (Dagit), open a new terminal in this directory and run:\")\nprint(\"    dg dev\")\nprint(\"\\nThen navigate your browser to http://localhost:3000 to see your project.\")\nprint(\"This `dg dev` command will keep running. Press Ctrl+C in that terminal to stop it.\")\nprint(\"\\nDemonstration complete. You can now explore 'my-dagster-quickstart' directory.\")","lang":"python","description":"This quickstart demonstrates how to create a new Dagster project using `dg new`. It then provides instructions to launch the local development UI (Dagit) with `dg dev` in a separate terminal to interact with the newly created project. The Python script executes the setup command but provides clear instructions for the long-running `dg dev` command."},"warnings":[{"fix":"Focus on using `dg` commands in your shell. If you need programmatic access to Dagster objects, import directly from the `dagster` package (e.g., `from dagster import asset`).","message":"The `dagster-dg-cli` package is primarily for providing the `dg` command-line executable. It is not typically imported as a Python library into user code. Most Dagster functionality is accessed via the `dagster` core package and its sub-packages.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the official Dagster documentation for your installed `dagster-dg-cli` version to ensure compatibility when scripting with `dg api` commands. Pin your `dagster-dg-cli` version in `requirements.txt`.","message":"The `dg api` commands for programmatic inspection (e.g., `dg api job list`, `dg api asset-check list`) are rapidly evolving. Scripts relying on specific output formats or command availability should be version-aware.","severity":"gotcha","affected_versions":">=1.12.22"},{"fix":"Ensure `pip install dagster-cloud` and configure your `pyproject.toml` under `[tool.dg.project]` as per Dagster Cloud documentation before attempting `dg plus deploy`.","message":"Using `dg plus deploy` requires the `dagster-cloud` package to be installed and proper configuration (e.g., `agent_queue`, `image`) within your project's `pyproject.toml` file to generate the `dagster_cloud.yaml`.","severity":"gotcha","affected_versions":">=1.12.22"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}