Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve errors on importing plugins (#2006) #2022

Merged
merged 1 commit into from
Jan 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions core/dbt/adapters/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ def load_plugin(self, name: str) -> Type[Credentials]:
# singletons
try:
mod = import_module('.' + name, 'dbt.adapters')
except ImportError as e:
logger.info("Error importing adapter: {}".format(e))
raise RuntimeException(
"Could not find adapter type {}!".format(name)
)
if not hasattr(mod, 'Plugin'):
raise RuntimeException(
f'Could not find plugin in {name} plugin module'
)
plugin: AdapterPlugin = mod.Plugin # type: ignore
except ModuleNotFoundError as exc:
# if we failed to import the target module in particular, inform
# the user about it via a runtiem error
logger.info(f'Error importing adapter: {exc}')
if exc.name == 'dbt.adapters.' + name:
raise RuntimeException(f'Could not find adapter type {name}!')
# otherwise, the error had to have come from some underlying
# library. Log the stack trace.
logger.debug('', exc_info=True)
raise
plugin = mod.Plugin # type: AdapterPlugin
plugin_type = plugin.adapter.type()

if plugin_type != name:
Expand Down