-
Notifications
You must be signed in to change notification settings - Fork 4
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
handle missing packages exception #174
Conversation
dbt_meshify/dbt.py
Outdated
try: | ||
return self.invoke(directory, ["--quiet", "parse"]) | ||
except UninstalledPackagesFoundError: | ||
logger.debug("Project missing packages, installing...") | ||
self.invoke(directory, ["deps"]) | ||
return self.invoke(directory, ["--quiet", "parse"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very clever! 🤔 Does this exception ever get raised for other Dbt
methods? If so, it may make sense to wrap/decorate invoke()
directly to handle this exception for all dbt calls. Thoughts, @dave-connors-3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah great point! I think it's around for any submitted command when packages aren't installed, but I put it in parse
since it's always the first method we call. I can add it up a level to invoke
to be safer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks great, @dave-connors-3 ✅ 🚀
if not result.success and result.exception: | ||
if isinstance(result.exception, UninstalledPackagesFoundError): | ||
logger.debug("Project missing packages, running dbt deps...") | ||
self.dbt_runner.invoke(["deps"]) | ||
result = self.dbt_runner.invoke(runner_args if runner_args else []) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like that we'll be covered now regardless of our command. Fantastic enhancement!
Closes #156
This catches a
UninstalledPackagesFoundError
when parsing a dbt project, and runs deps automatically before parsing!yabba dabba doo!