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

[#3885] Skip partial parsing if project env vars change #4212

Merged
merged 2 commits into from
Nov 8, 2021

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Nov 5, 2021

resolves #3885

Description

This pull request captures the env vars when the dbt_project.yml file is rendered and saves a checksum of them in the manifest.state_check. When partial parsing is attempted it will compare the checksums and skip partial parsing if they have changed.

Profile env vars have also been handled. Note: only the specified profile is actually rendered.

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 Nov 5, 2021
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

Just spent some time playing around with these changes. Looking good so far!

Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

Working great in local testing. Good to go from my perspective.

Let's make sure someone is able to give this PR + #4162 a quick code review on Monday morning, so that we can have both in rc1.

Comment on lines +81 to +82
proj_env_vars_changed = '09_project_env_vars_changed'
prof_env_vars_changed = '10_profile_env_vars_changed'
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines +401 to +402
# There will never be any project_env_vars when it's first created
project_env_vars: Dict[str, Any] = {}
Copy link
Member

@emmyoop emmyoop Nov 8, 2021

Choose a reason for hiding this comment

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

Is this true? With the new interactive init you can technically put in env_vars. Either way they're "changing" since they're new so 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.

Yes. The project_env_vars only come from rendering, which happens after the object is created. So whether or not env vars exist before the dbt code starts up doesn't matter.

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.

LGTM but I'd be happier is someone else took a look too.

Comment on lines +560 to +567
logger.info("Unable to do partial parsing because env vars "
"used in dbt_project.yml have changed")
valid = False
reparse_reason = ReparseReason.proj_env_vars_changed
if self.manifest.state_check.profile_env_vars_hash != \
manifest.state_check.profile_env_vars_hash:
logger.info("Unable to do partial parsing because env vars "
"used in profiles.yml have changed")
Copy link
Member

Choose a reason for hiding this comment

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

Depending on what goes in first (this or #4055) , this will need to be updated to the new struct logging as well as anywhere else logging is happening. Nothing to do now - more of a reminder for later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should have a walkthrough next week since everything is all crunchy right now.

Base automatically changed from pp_schema_env_vars to main November 8, 2021 16:28
@gshank gshank merged commit 3e9da06 into main Nov 8, 2021
@gshank gshank deleted the pp_project_env_vars branch November 8, 2021 16:51
iknox-fa pushed a commit that referenced this pull request Feb 8, 2022
* [#3885] Skip partial parsing if project env vars change

* Support env_vars in the profile

automatic commit by git-black, original commits:
  3e9da06
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.

Env vars + partial parsing
3 participants