Skip to content

Commit

Permalink
[#3885] Skip partial parsing if project env vars change (#4212)
Browse files Browse the repository at this point in the history
* [#3885] Skip partial parsing if project env vars change

* Support env_vars in the profile

automatic commit by git-black, original commits:
  3e9da06
  • Loading branch information
gshank authored and iknox-fa committed Feb 8, 2022
1 parent 75f01fe commit b2d411b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
7 changes: 2 additions & 5 deletions core/dbt/config/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ class DbtProjectYamlRenderer(BaseRenderer):
_KEYPATH_HANDLERS = ProjectPostprocessor()

def __init__(
self, profile: Optional[HasCredentials] = None,
cli_vars: Optional[Dict[str, Any]] = None
self, profile: Optional[HasCredentials] = None, cli_vars: Optional[Dict[str, Any]] = None
) -> None:
# Generate contexts here because we want to save the context
# object in order to retrieve the env_vars. This is almost always
Expand Down Expand Up @@ -176,9 +175,7 @@ def name(self):


class SecretRenderer(BaseRenderer):
def __init__(
self, cli_vars: Optional[Dict[str, Any]] = None
) -> None:
def __init__(self, cli_vars: Optional[Dict[str, Any]] = None) -> None:
# Generate contexts here because we want to save the context
# object in order to retrieve the env_vars.
if cli_vars is None:
Expand Down
20 changes: 12 additions & 8 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class ReparseReason(StrEnum):
project_config_changed = '06_project_config_changed'
load_file_failure = '07_load_file_failure'
exception = '08_exception'
proj_env_vars_changed = '09_project_env_vars_changed'
prof_env_vars_changed = '10_profile_env_vars_changed'
proj_env_vars_changed = "09_project_env_vars_changed"
prof_env_vars_changed = "10_profile_env_vars_changed"


# Part of saved performance info
Expand Down Expand Up @@ -565,13 +565,17 @@ def is_partial_parsable(self, manifest: Manifest) -> Tuple[bool, Optional[str]]:
fire_event(PartialParsingFailedBecauseProfileChange())
valid = False
reparse_reason = ReparseReason.profile_changed
if self.manifest.state_check.project_env_vars_hash != \
manifest.state_check.project_env_vars_hash:
if (
self.manifest.state_check.project_env_vars_hash
!= manifest.state_check.project_env_vars_hash
):
fire_event(PartialParsingProjectEnvVarsChanged())
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:
if (
self.manifest.state_check.profile_env_vars_hash
!= manifest.state_check.profile_env_vars_hash
):
fire_event(PartialParsingProfileEnvVarsChanged())
valid = False
reparse_reason = ReparseReason.prof_env_vars_changed
Expand Down Expand Up @@ -690,15 +694,15 @@ def build_manifest_state_check(self):
# Create a FileHash of the env_vars in the project
key_list = list(config.project_env_vars.keys())
key_list.sort()
env_var_str = ''
env_var_str = ""
for key in key_list:
env_var_str += f'{key}:{config.project_env_vars[key]}|'
project_env_vars_hash = FileHash.from_contents(env_var_str)

# Create a FileHash of the env_vars in the project
key_list = list(config.profile_env_vars.keys())
key_list.sort()
env_var_str = ''
env_var_str = ""
for key in key_list:
env_var_str += f'{key}:{config.profile_env_vars[key]}|'
profile_env_vars_hash = FileHash.from_contents(env_var_str)
Expand Down

0 comments on commit b2d411b

Please sign in to comment.