https://dagster.io/ logo
Title
k

Kevin Otte

02/17/2023, 10:13 PM
I have a config.py file under assets folder in my project. Im trying to import certain secrets from the config into a file but keep running into this error (see 🧵 )
:dagster-bot-responded-by-community: 1
The above exception was caused by the following exception:
ModuleNotFoundError: No module named 'config'
  File "/usr/local/lib/python3.8/site-packages/dagster/_core/code_pointer.py", line 138, in load_python_module
    return importlib.import_module(module_name)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/dagster/app/data/__init__.py", line 16, in <module>
    assets=load_assets_from_package_module(assets), schedules=[daily_refresh_schedule]
  File "/usr/local/lib/python3.8/site-packages/dagster/_core/definitions/load_assets_from_modules.py", line 237, in load_assets_from_package_module
    ) = assets_from_package_module(package_module)
  File "/usr/local/lib/python3.8/site-packages/dagster/_core/definitions/load_assets_from_modules.py", line 197, in assets_from_package_module
    return assets_from_modules(
  File "/usr/local/lib/python3.8/site-packages/dagster/_core/definitions/load_assets_from_modules.py", line 58, in assets_from_modules
    for module in modules:
  File "/usr/local/lib/python3.8/site-packages/dagster/_core/definitions/load_assets_from_modules.py", line 288, in _find_modules_in_package
    submodule = import_module(f"{package_module.__name__}.{modname}")
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/dagster/app/data/assets/base.py", line 2, in <module>
    import config
p

Pezhman Zarabadi-Poor

02/17/2023, 11:30 PM
The issue is that your are trying to
import config
in your
base.py
. This should be
from <your_package>.data.assets.config import <your_variable>
However, I suggest also moving such non-asset bits out of asset folder too.
:rainbow-daggy: 1