|
| 1 | +--- |
| 2 | +title: Adding a project to Dagster+ |
| 3 | +sidebar_position: 30 |
| 4 | +tags: [dagster-plus-feature] |
| 5 | +description: You can add a single Dagster project manually to your Dagster+ deployment or add multiple Dagster projects that roll up into one global lineage graph. |
| 6 | +--- |
| 7 | + |
| 8 | +import DagsterPlus from '@site/docs/partials/\_DagsterPlus.md'; |
| 9 | + |
| 10 | +<DagsterPlus /> |
| 11 | + |
| 12 | +This guide will cover three options for adding a new Dagster project (also known as a code location) to your Dagster+ deployment: |
| 13 | + |
| 14 | +- [Adding a Dagster project manually](#adding-a-new-dagster-project-manually) |
| 15 | +- [Adding a Dagster project in a new Git repository](#adding-a-dagster-project-in-a-new-git-repository) |
| 16 | +- [Adding a new Dagster project to an existing Git monorepo](#adding-a-new-dagster-project-to-a-git-monorepo) |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +Before following the steps in this guide, you will need to: |
| 21 | + |
| 22 | +- [Create a Dagster project](/guides/build/projects/creating-projects). |
| 23 | +- Have [Editor, Admin, or Organization Admin permissions in Dagster+](/deployment/dagster-plus/authentication-and-access-control/rbac/user-roles-permissions). |
| 24 | +- Find your Dagster+ deployment type. An administrator can help find this information, or you can locate it by clicking _Deployment > Agents tab_ in the Dagster UI. Dagster+ Serverless organizations will have a _Managed by Dagster+_ label next to the agent. |
| 25 | + |
| 26 | +Adding a project follows two steps: |
| 27 | + |
| 28 | +- For Dagster+ Hybrid, ensuring the Dagster code is in a place accessible by your agent, usually by building a Docker image with your code that's pushed to a registry. For Dagster+ Serverless you can skip this step. |
| 29 | +- Notifying Dagster+ of the new or updated code location. This will be done by using the Dagster+ Python client. |
| 30 | + |
| 31 | +Often these two steps are handled by CI/CD connected to your Git repository. |
| 32 | + |
| 33 | +## Adding a new Dagster project manually |
| 34 | + |
| 35 | +### Step 1: Install the `dagster-cloud` Python client |
| 36 | + |
| 37 | +Start by installing the `dagster-cloud` Python client: |
| 38 | + |
| 39 | +<Tabs groupId="package-manager"> |
| 40 | + <TabItem value="uv" label="uv"> |
| 41 | + |
| 42 | + ```shell |
| 43 | + uv add dagster-cloud |
| 44 | + ``` |
| 45 | + |
| 46 | + </TabItem> |
| 47 | + |
| 48 | + <TabItem value="pip" label="pip"> |
| 49 | + |
| 50 | + ```shell |
| 51 | + pip install dagster-cloud |
| 52 | + ``` |
| 53 | + |
| 54 | + </TabItem> |
| 55 | +</Tabs> |
| 56 | + |
| 57 | +### Step 2: Authenticate the `dagster-cloud` Python client |
| 58 | + |
| 59 | +Next, authenticate the `dagster-cloud` Python client: |
| 60 | + |
| 61 | +1. In the Dagster+ UI, click the user icon in the upper right corner. |
| 62 | +2. Click **Organization settings**, then the **Tokens** tab. |
| 63 | +3. Click the **Create user token** button. |
| 64 | +4. Copy the token. |
| 65 | +5. Set the following environment variables: |
| 66 | + |
| 67 | + ```bash |
| 68 | + export DAGSTER_CLOUD_ORGANIZATION="organization-name" # if your URL is https://acme.dagster.plus your organization name is "acme" |
| 69 | + export DAGSTER_CLOUD_API_TOKEN="your-token" |
| 70 | + ``` |
| 71 | + |
| 72 | +### Step 3: Add your Dagster project |
| 73 | + |
| 74 | +Now add your Dagster project. The following example assumes you are running the command from the top-level working directory of your Dagster project with a project named "dagster_tutorial" structured as a Python module named "dagster_tutorial": |
| 75 | + |
| 76 | +<Tabs groupId="package-manager"> |
| 77 | + |
| 78 | + <TabItem value="uv" label="uv"> |
| 79 | + ```shell |
| 80 | + . |
| 81 | + ├── pyproject.toml |
| 82 | + ├── README.md |
| 83 | + ├── src |
| 84 | + │ └── dagster_tutorial |
| 85 | + │ ├── __init__.py |
| 86 | + │ ├── definitions.py |
| 87 | + │ └── defs |
| 88 | + │ └── __init__.py |
| 89 | + ├── tests |
| 90 | + │ └── __init__.py |
| 91 | + └── uv.lock |
| 92 | + ``` |
| 93 | + </TabItem> |
| 94 | + <TabItem value="pip" label="pip"> |
| 95 | + ```shell |
| 96 | + . |
| 97 | + ├── pyproject.toml |
| 98 | + ├── README.md |
| 99 | + ├── src |
| 100 | + │ └── dagster_tutorial |
| 101 | + │ ├── __init__.py |
| 102 | + │ ├── definitions.py |
| 103 | + │ └── defs |
| 104 | + │ └── __init__.py |
| 105 | + └── tests |
| 106 | + └── __init__.py |
| 107 | + ``` |
| 108 | + </TabItem> |
| 109 | +</Tabs> |
| 110 | + |
| 111 | +The commands below take two main arguments: |
| 112 | + |
| 113 | +- `module_name` is determined by your code structure |
| 114 | +- `location_name` is the unique label for this project used in Dagster+ |
| 115 | + |
| 116 | +<Tabs> |
| 117 | +<TabItem value="serverless" label="Dagster+ Serverless"> |
| 118 | + |
| 119 | +If you are using Dagster+ Serverless, run the following command to add your Dagster project: |
| 120 | + |
| 121 | +```bash |
| 122 | +dagster-cloud serverless deploy-python-executable --deployment prod --location-name dagster_tutorial --module-name dagster_tutorial |
| 123 | +``` |
| 124 | + |
| 125 | +Running the command multiple times with the same location name will _update_ the project. Running the command with a new location name will _add_ a project. |
| 126 | + |
| 127 | +</TabItem> |
| 128 | +<TabItem value="hybrid" label="Dagster+ Hybrid"> |
| 129 | + |
| 130 | +If you are using Dagster+ Hybrid, make sure you have deployed the code appropriately by: |
| 131 | + |
| 132 | +1. Building a Docker image and pushing it to an image registry. |
| 133 | +2. Running the `dg plus deploy configure` command from the Dagster project root to create a `dagster_cloud.yaml` file. |
| 134 | + |
| 135 | +Then run the following command, using the image URI which is available from your registry: |
| 136 | + |
| 137 | +```bash |
| 138 | +dagster-cloud deployment add-location --deployment prod --location-name dagster_tutorial --module-name dagster_tutorial --image 764506304434.dkr.ecr.us-west-2.amazonaws.com/hooli-data-science-prod:latest |
| 139 | +``` |
| 140 | + |
| 141 | +</TabItem> |
| 142 | +</Tabs> |
| 143 | + |
| 144 | +After running the command, you can verify the project was deployed by navigating to the _Deployments_ tab on Dagster+. |
| 145 | + |
| 146 | +## Adding a Dagster project in a new Git repository |
| 147 | + |
| 148 | +Adding a project to a Git repository follows the same steps as adding a project manually, but automates those steps by running them through CI/CD. For more information, see [Configuring CI/CD in Dagster+](/deployment/dagster-plus/deploying-code/configuring-ci-cd). |
| 149 | + |
| 150 | +The CI/CD process will add the project to Dagster+, which can be verified by viewing the _Deployments_ tab. |
| 151 | + |
| 152 | +## Adding a new Dagster project to a Git monorepo |
| 153 | + |
| 154 | +Many organizations use a Git monorepo to contain multiple Dagster projects. To add a new Dagster project to a monorepo: |
| 155 | + |
| 156 | +1. [Create a Dagster workspace](/guides/build/projects/workspaces/creating-workspaces) to hold your Dagster projects. |
| 157 | +2. Move your existing Dagster project(s) into the `/projects` directory of the workspace. If necessary, [convert the projects](/guides/build/projects/moving-to-components/migrating-project) to the new Dagster project structure. |
| 158 | +3. In the `/projects` directory of the workspace, [create a new Dagster project](/guides/build/projects/creating-projects) with the `dagster-create` CLI. |
| 159 | +4. Run the `dg plus deploy configure` command in the workspace root to create deployment configuration files for projects that need them. |
| 160 | + |
| 161 | +After following these steps, trigger the CI/CD process to add your project to Dagster+. Navigate to the _Deployments_ tab in Dagster+ to confirm your project was added. |
| 162 | + |
| 163 | +## Next steps |
| 164 | + |
| 165 | +- After adding a code location, you may want to set up [access controls](/deployment/dagster-plus/authentication-and-access-control) |
| 166 | +- You may want to add additional configuration to your project. This configuration will vary by agent type, but see examples for [setting default resource limits for Kubernetes](/deployment/dagster-plus/hybrid/kubernetes) or [changing the IAM role for ECS](/deployment/dagster-plus/hybrid/amazon-ecs/configuration-reference). |
0 commit comments