-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix project dir argument when running debug (#1733) #1989
Fix project dir argument when running debug (#1733) #1989
Conversation
Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA. In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, don't hesitate to ping @drewbanin. CLA has not been signed by users: @franloza |
Thanks for making this PR @franloza! I gave this a quick spin locally and I noticed that the code change here doesn't have the effected specified in the PR description. Specifically, I saw that when running I think the relevant method codepath might be around here: https://github.com/fishtown-analytics/dbt/blob/cc491904bc7ed5c27a395e3a1936e57e4221354a/core/dbt/config/project.py#L391-L393 This method is called via I think we'll want to update the (also: @cla-bot check) |
The cla-bot has been summoned, and re-checked this pull request! |
Yes, you were completely right @drewbanin. As you mentioned, the added test only checked that we were looking outside current directory and returned the error in the first if statement:
However, we were not covering the case of specifing an existent |
core/dbt/task/debug.py
Outdated
@@ -125,7 +126,7 @@ def _load_project(self): | |||
return red('ERROR not found') | |||
|
|||
try: | |||
self.project = Project.from_current_directory(self.cli_vars) | |||
self.project = Project.from_project_root(self.project_dir, self.cli_vars) |
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.
Looks like this line is too long per our styleguide:
core/dbt/task/debug.py:129:80: E501 line too long (85 > 79 characters)
Can you split this onto two lines?
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.
Looks good to me. Two tiny comments + the flake8 fix that drew noted and this will be great. Thanks for writing great tests!
|
||
@use_profile('postgres') | ||
def test_postgres_not_found_project_dir(self): | ||
self.use_default_project() |
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.
You shouldn't need to call use_default_project
unless you do things with the project/profile as part of the test - setUp
will call it (some old tests still have it, so I understand where this came from!)
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.
Yes, you're right @beckjake . I did not realize that it is called in setUp
method. I will take it into account for the next time, thanks!
splitout = self.capsys.readouterr().out.split('\n') | ||
for line in splitout: | ||
if line.strip().startswith('dbt_project.yml file'): | ||
self.assertIn('ERROR invalid', line) |
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.
Can you please add a newline at the end of this file? looking at stuff in the terminal can get annoying without trailing newlines.
I have fixed style code style violations and removed |
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.
Looks great, I've kicked off the tests for a final run. Thanks for your contribution @franloza!
Fixes #1733
I did not make the class
DebugTask
inherited fromRequiresProjectTask
because it raised adbt.exceptions.RuntimeException
inget_nearest_project_dir()
function ifdbt_project.yml
was not found. Instead, I just used the argumentproject_dir
from arguments as first choice and set current directory as fall-back value.The included test checks that, even if a
dbt_project.yml
is in the current directory, the--project-dir
argument is used, leading to a "not found" error.