https://dagster.io/ logo
#dagster-support
Title
# dagster-support
c

Charles

06/27/2022, 10:21 AM
Hi all, I have Dagster running on a VM and connected as Agent to Dagster Cloud. I'm trying to add a code location of a repository I cloned inside
dagster_home
called
my_project
however I get the following error:
Exception: Can not import module dagster from path ./dagster_home/my_project/dagster, unable to load spec.
Here's the location YAML I've defined via Cloud UI:
Copy code
location_name: my_project
code_source:
  python_file: ./dagster_home/my_project/dagster
What am I missing?
👋 1
Do I understand correctly that when referencing repo's they must follow same structure & content as the Cereal example? https://github.com/dagster-io/dagster-cloud/tree/main/dagster-cloud-examples/dagster_cloud_examples/cereals
d

daniel

06/27/2022, 2:35 PM
Hi Charles - a couple of ideas to try: Firstly - typically a python file would end in .py - so if dagster is a folder rather than a file you may want to use
package_name
rather than
python_file
as your key. the first thing I would try is renaming your folder to something other than dagster, as I've seen python get very confused when determining if an import was a local module with the same name as an installed module (for example, you'll often have a bad time if you try to load a file called random.py or math.py since those are built-in python packages). The next thing I'd try is seeing whether running 'python ./dagster_home/my_project/dagster' (or whatever the new filename is) - or
python -m <your folder>
if it's a folder/python module) is able to run your code without any issues, that will typically surface any import-related issues which seems to be what's happening here.
c

Charles

06/27/2022, 2:41 PM
Thank you Daniel that's very helpful! In the Dagit documentation, I read this:
Every code location must set the
code_source:
key to either
python_file:
or
package_name:
to specify where to find your code.
But it's not clear to me what kind of file Dagster is looking for? ie; should the
.py
file reference a
resopository
object such as this one? Or something else?
d

daniel

06/27/2022, 2:42 PM
Ah sorry, where I said python_module I should have said package_name, my mistake
Editted!
c

Charles

06/27/2022, 2:43 PM
No worries, I edited my follow-up question too.
@daniel just tagging you in case you missed my edit
d

daniel

06/27/2022, 3:55 PM
Ah sorry, I misunderstood your comment
Yeah, the py file needs to contain a dagster repository
In our example here, the package imports the cereal_repository Dagster repository: https://github.com/dagster-io/dagster-cloud/blob/main/dagster-cloud-examples/dagster_cloud_examples/__init__.py
6 Views