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

handle missing packages exception #174

Merged
merged 2 commits into from
Sep 19, 2023
Merged

handle missing packages exception #174

merged 2 commits into from
Sep 19, 2023

Conversation

dave-connors-3
Copy link
Collaborator

Closes #156

This catches a UninstalledPackagesFoundError when parsing a dbt project, and runs deps automatically before parsing!

yabba dabba doo!

Comment on lines 31 to 36
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"])
Copy link
Collaborator

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?

Copy link
Collaborator Author

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!

Copy link
Collaborator

@nicholasyager nicholasyager left a 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 ✅ 🚀

Comment on lines +23 to +28
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 [])

Copy link
Collaborator

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!

@dave-connors-3 dave-connors-3 merged commit a699463 into main Sep 19, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants