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

[#4554] Don't require a profile for dbt deps and clean commands #4610

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Jan 22, 2022

resolves #4554

Description

Changing a profile parsing exception from a CompilationException to a ParsingException caused a failure in the code that intended to trap the error.

Switch to not loading the profile when we don't need it, and remove code that incorrectly reported the nature of the error.

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

@cla-bot cla-bot bot added the cla:yes label Jan 22, 2022
@gshank gshank force-pushed the ct-25-deps_no_profile branch from 4d9f8c6 to 75bf0e0 Compare January 24, 2022 14:40
@gshank
Copy link
Contributor Author

gshank commented Jan 24, 2022

Prior to this pull request for the dbt deps and clean commands we would attempt to load the profile and if it failed would mis-report an error and then proceed with an UnsetProfile. The code would also set 'send_anonymous_usage_stats' to False for cases where the profile failed to load, which meant that for this edge case we had a different default for that attribute. Since we refactored the UserConfig/flags code, having an 'unset' user config no longer makes sense. It also doesn't make a lot of sense to go to extra work to validate profiles (and issue incorrect error messages) when the profile isn't required for the command.

This change simplifies the '_get_rendered_profile' code to use the UnsetProfile directly, and set the user_config separately.

Copy link
Member

@emmyoop emmyoop left a comment

Choose a reason for hiding this comment

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

One comment about a test location but otherwise looks good.

Comment on lines +290 to +293
@use_profile('postgres')
def test_postgres_clean_bad_profile(self):
del os.environ['PROFILE_TEST_HOST']
self.run_dbt(["clean"])
Copy link
Member

Choose a reason for hiding this comment

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

This test doesn't really make sense to have here since it's for dbt clean but since we're going to rearrange them all soon I'm not sure how much it matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I realized that. But it needs exactly the same setup, so it felt like a waste to copy the same test to a different integration test directory. Rather than being in a dbt 'deps' command, maybe we need a test for "things that run without a profile", but like you said, I'd like to defer that to later reorganization.

@gshank gshank merged commit 3032594 into main Jan 25, 2022
@gshank gshank deleted the ct-25-deps_no_profile branch January 25, 2022 17:26
@leahwicz leahwicz added the backport 1.0.latest Tag for PR to be backported to the 1.0.latest branch label Jan 27, 2022
@github-actions
Copy link
Contributor

The backport to 1.0.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.0.latest 1.0.latest
# Navigate to the new working tree
cd .worktrees/backport-1.0.latest
# Create a new branch
git switch --create backport-4610-to-1.0.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 3032594b26aaafaf1003db513645660d0e7c89dc
# Push it to GitHub
git push --set-upstream origin backport-4610-to-1.0.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.0.latest

Then, create a pull request where the base branch is 1.0.latest and the compare/head branch is backport-4610-to-1.0.latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.0.latest Tag for PR to be backported to the 1.0.latest branch cla:yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-25] [Bug] dbt deps should not require a profile
3 participants