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

Make deps respect --project-dir #2534

Merged
merged 4 commits into from
Jun 15, 2020
Merged

Conversation

beckjake
Copy link
Contributor

@beckjake beckjake commented Jun 10, 2020

resolves #2519
resolves #2541

Description

The problem was actually the opposite of what I thought: dbt deps does the wrong thing if you give it --project-dir, and puts files relative to the current directory. But it does look in the --project-dir to find packages.yml, so it just downloads them to the wrong directory.
Subsequent dbt commands that do respect --project-dir then can't find their dependencies, because they've moved into the project directory and away from the starting directory.

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

@cla-bot cla-bot bot added the cla:yes label Jun 10, 2020
@beckjake beckjake force-pushed the fix/dbt-modules-in-project-dir branch from 4357afe to 83a4562 Compare June 11, 2020 13:39
@beckjake beckjake marked this pull request as ready for review June 11, 2020 13:40
@beckjake
Copy link
Contributor Author

I do not understand how this change causes that test to fail in that way. This test passes locally (both in isolation and in parallel) but consistently fails the exact same way in circle. Nothing about this PR should change that test's behavior and it makes no sense to me that the schemas could already exist.

Make the unique ID a bit more collision-resistant to try to avoid collisions
@beckjake beckjake force-pushed the fix/dbt-modules-in-project-dir branch from 9114285 to e00d1ed Compare June 11, 2020 15:58
@beckjake
Copy link
Contributor Author

I made a bunch of silly test changes to drop more schemas and try to avoid collisions, which seems to have fixed the issue

@drewbanin
Copy link
Contributor

I'm going to take some more time to comb through the diff in this PR, but I did want to call something out I noticed while debugging:

I think we've sort of flip-flopped on regressions for this feature over the last couple of versions of dbt:

version command status
0.16.0 dbt deps --project-dir projectdir success
0.16.0 dbt run --project-dir projectdir success
0.16.1 dbt deps --project-dir projectdir failed
0.16.1 dbt run --project-dir projectdir success
0.17.0 dbt deps --project-dir projectdir installed packages to wrong dir
0.17.0 dbt run --project-dir projectdir failed
this branch dbt deps --project-dir projectdir failed
this branch dbt run --project-dir projectdir failed

Each of the invocations marked failed errored out immediately with:

Running with dbt=<version>
Encountered an error while reading the project:
  ERROR: Runtime Error
  no dbt_project.yml found at expected path projectdir/dbt_project.yml
Encountered an error:
Runtime Error
  Could not run dbt

So, the key takeaway is that I'm seeing --project-dir is not working correctly on this branch, but there also might be some broader issues for us to investigate here than dbt_modules simply being written to the wrong dir.

I made a loom repro'ing this error in this branch: https://www.loom.com/share/54077f3fc52344d88ccfddc0d6e5ee19

@beckjake
Copy link
Contributor Author

@drewbanin You have to give the full path to your project directory.

Copy link
Contributor

@kwigley kwigley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment, everything else looks good to me!

@@ -353,7 +353,7 @@ def load_projects(
yield project.project_name, project

def _get_project_directories(self) -> Iterator[Path]:
root = Path(self.project_root) / self.modules_path
root = Path.cwd() / self.modules_path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little concern with possible behavior this line might introduce. I think the assumption here is that load_dependencies will be called after moving to the root project dir. I think it is fine, will defer to you!

Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for hitting #2541 here also - that's a great change

@beckjake beckjake merged commit 0be8326 into dev/0.17.1 Jun 15, 2020
@beckjake beckjake deleted the fix/dbt-modules-in-project-dir branch June 15, 2020 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants