-
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
Correctly handle an empty dbt_project.yml in dbt debug
#2120
Correctly handle an empty dbt_project.yml in dbt debug
#2120
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: @nchammas |
@@ -189,6 +189,12 @@ def _raw_project_from(project_root: str) -> Dict[str, Any]: | |||
) | |||
|
|||
project_dict = _load_yaml(project_yaml_filepath) |
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.
Ideally, we should just validate the complete project schema here, perhaps using something like StrictYAML.
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 pretty cool! I'll have to look into it. Sadly it looks like they don't support anchors, but maybe we'd live without that. We do validate the parsed project using hologram
, but I would love a smaller, more close-to-the-input schema definition for your yaml files.
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.
What are anchors?
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.
foo: &my_anchor
a: 1
b: [2, 3]
c: false
bar: *my_anchor
Is equivalent to:
foo:
a: 1
b: [2, 3]
c: false
bar:
a: 1
b: [2, 3]
c: false
There's also a field-override syntax, which is very convenient.
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 yes, StrictYAML removes a lot of YAML features like that.
I'm not familiar with Hologram, but I have heard of Cerberus as an option for flexible data validation.
The cla-bot has been summoned, and re-checked this pull request! |
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.
Hey @nchammas, this looks great! Thanks for your contribution. Do you think you could add a test? You should be able to copy+paste and change one of the tests in test/integration/049_debug_tests/test_debug.py
to generate an empty profile (I'd probably start with the test_postgres_invalid_project_outside_current_dir
test).
@@ -189,6 +189,12 @@ def _raw_project_from(project_root: str) -> Dict[str, Any]: | |||
) | |||
|
|||
project_dict = _load_yaml(project_yaml_filepath) |
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 pretty cool! I'll have to look into it. Sadly it looks like they don't support anchors, but maybe we'd live without that. We do validate the parsed project using hologram
, but I would love a smaller, more close-to-the-input schema definition for your yaml files.
@beckjake - I'm trying to run that test locally, but it seems the way we've setup $ pytest -k test_postgres_invalid_project_outside_current_dir
...
> raise dbt.exceptions.FailedToConnectException(str(e))
E dbt.exceptions.FailedToConnectException: Database Error
E could not translate host name "database" to address: nodename nor servname provided, or not known
.../dbt/plugins/postgres/dbt/adapters/postgres/connections.py:111: FailedToConnectException Here's the culprit: https://github.com/fishtown-analytics/dbt/blob/4e58589afdbb5e74701753e239536e318c5d8db7/test/integration/base.py#L128-L131 Why does that method return |
@nchammas I recommend using
I think that will get your tests working properly. |
OK, I'll try that. The contributing guide isn't clear that this is a requirement for running the tests, but then again it doesn't suggest calling pytest directly either. 😄 |
I believe you meant And on the third step you provided I'm getting the same error I reported in #2128. |
Oops, yes, you're correct - As I commented on #2128, something is broken with docker image building (I obviously don't do it often!). The circleci tests use |
I'm getting the same error with |
Yeah, I am. I didn't really want to spend my day on this but I guess I'm going to have to figure out what's wrong since I can't run tests anymore. |
440b9ba
to
cf90232
Compare
Tests pass locally with:
By the way, that set of 4 tests alone takes 12 seconds to run. Is that normal? |
Not sure why some of the checks aren't running, but the ones that did run, passed. |
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.
Not sure why some of the checks aren't running, but the ones that did run, passed.
The ones that aren't running require manual intervention to run. I'll kick them off, thanks for your contribution!
@nchammas before I merge/kick off tests, could you rebase this against dev/barbara-gittings, and squash it into one commit? Those tests shouldn't fail if these passed. |
I did recently merge Is that not good enough? If not, I can manually rebase and squash as you request, but it seems like something we shouldn't need to do. |
@nchammas sorry, I haven't been attentive to github! We have squash and merge disabled so I actually can't do it at merge-time. |
dcd50a5
to
5dc9393
Compare
OK, done. |
Thanks! I've kicked off the tests. Once they pass, I'll merge this. |
It's confusing to access the dbt project from within
_load_profile()
since the project has not been validated yet. If the project is invalid, the code validating the profile fails.I've tried to handle this case gracefully using the existing patterns.
Old behavior:
New behavior:
Fixes #2116.