https://dagster.io/ logo
#ask-community
Title
# ask-community
c

Clayton Casey

05/23/2023, 9:57 PM
Hello again, I have a question that I can't seem to find much documentation on. I have my practice-code-locations directory organized so that each code location is held within the businessFunction/projectName folder. This helps segment everything and keep it organized. (EXAMPLE BELOW) Here is the contents of my root directory: practice-code-locations ├───collections │ └───dag-collection-recommender │ ├───collection_rec_dag │ │ ├───assets │ │ │ └───core │ │ └───resources │ └───output ├───consumer-lending ├───data ├───marketing │ └───dag-hubspot ├───mortgage └───universal ├───resources ├───sensors └───utils I am trying to find out how to import my universal resources/utils/etc into my collection_rec_dag code location so that I can run dagster dev from the practice-code-locations and all imports will resolve accodingly. My workspace.yaml looks like this 'load_from: - python_module: module_name: collection_rec_dag working_directory: dag-collection-recommender' I am unable to import in my code locations via relative or explicit imports. e.g. from universal.resources import dbconnection / from ..universal.resources import dbconnection. I know it has something to do with my workspace.yaml but I can't figure it out. Any help? I can provide errors on the thread.
o

owen

05/23/2023, 11:02 PM
hi @Clayton Casey! the simplest option is probably just to make
universal
a package and install it into your environment with
pip install -e universal
. Then, you can import from this package with
from universal.resources import dbconnection
. This blog post talks a bit more about how to do that.
c

Clayton Casey

05/24/2023, 8:26 PM
Thanks, let me research doing this!
code-locations ├───dag-another-marketing-project ├───dag-collection-recommender └───dag-hubspot I can get my project working exactly as expected when it is organized this way (above). My workspace.yaml sits in the code-locations directory and looks like this.
load_from:
- python_package: dag-collection-recommender
- python_package: dag-hubspot
- python_package: dag-another-marketing-project
When I try to introduce another layer of organization (i.e. business function directories for my dag projects to sit in) I start running into errors. Example tree: code-locations ├───collections │ └───dag-collection-recommender └───marketing ├───dag-another-marketing-project └───dag-hubspot New workspace.yaml
load_from:
- python_package: collections.dag-collection-recommender
I've tried using code-locations.collections.dag-collection-recommender code-lcoations\collections\dag-collection-recommender collections.dag-collection-recommender. Example errors. The above exception was caused by the following exception: ModuleNotFoundError: No module named 'collections.dag-collection-recommender' Any recommendations on how to reference my package as a code location correctly?
a

Ahmed Elsagheer

08/07/2023, 10:53 AM
I had the same issue @Clayton Casey cam you share your workaround with me if you find one?
4 Views