Multiple code locations in Dagster OSS with shared code (resources, utils) #31890
-
|
Hi all, Context:
Current repo structure (simplified): dagster_OSS/ Each code location may need libraries that would clash with others, so isolation is important. But I also want to avoid duplicating the shared utils/ and resources/ code across locations. What’s the recommended way to structure repos when you need per-location env isolation but also shared code? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Not fully sure... two options:
|
Beta Was this translation helpful? Give feedback.
-
|
I would highly recommend using uv workspaces for this, where each code location is a workspace and shared packages can be represented one or more workspaces within the same project. This makes it trivial to share common code across code locations. Just make sure all you don't have any shared code workspaces importing from code locations so as to avoid circular dependencies. My company has a monorepo with about a half dozen code locations and a half dozen internal packages all structured as workspaces within a single UV project and it works amazingly well... within the codebase it feels like it's all just one big package but we can easily build and deploy code locations individually and can also slice out reusable shared code packages that are useful outside of Dagster as well. Edit: just wanted to note that I personally try to avoid importing code from one code location into another code location, as those kinds of dependencies will cause scenarios where updating one code location requires also redeploying another code location. This can easily get you into weird situations where code location B is running with out-of-date code imported from an old version of code location A, because someone updated location A but didn't know they had to restart B as well (among other suboptimal scenarios). |
Beta Was this translation helpful? Give feedback.
-
|
Both recommendations here are great. Going to mark @zyd14's as the answer, but if you have any other questions please share. |
Beta Was this translation helpful? Give feedback.
I would highly recommend using uv workspaces for this, where each code location is a workspace and shared packages can be represented one or more workspaces within the same project. This makes it trivial to share common code across code locations. Just make sure all you don't have any shared code workspaces importing from code locations so as to avoid circular dependencies.
My company has a monorepo with about a half dozen code locations and a half dozen internal packages all structured as workspaces within a single UV project and it works amazingly well... within the codebase it feels like it's all just one big package but we can easily build and deploy code locations individually and ca…