Compare commits

...

1 Commits

Author SHA1 Message Date
Jeremy Cohen
9c6142ef1b Naive fix for 4752 2022-02-19 15:59:37 +01:00
2 changed files with 26 additions and 12 deletions

View File

@@ -570,7 +570,7 @@ class Project:
with_packages=True
)
def to_project_config(self, with_packages=False):
def to_project_config(self, with_packages=False, path_info_only=True):
"""Return a dict representation of the config that could be written to
disk with `yaml.safe_dump` to get this configuration.
@@ -595,16 +595,16 @@ class Project:
"snapshot-paths": self.snapshot_paths,
"clean-targets": self.clean_targets,
"log-path": self.log_path,
"quoting": self.quoting,
"models": self.models,
"on-run-start": self.on_run_start,
"on-run-end": self.on_run_end,
"dispatch": self.dispatch,
"seeds": self.seeds,
"snapshots": self.snapshots,
"sources": self.sources,
"tests": self.tests,
"vars": self.vars.to_dict(),
"quoting": {} if path_info_only else self.quoting,
"models": {} if path_info_only else self.models,
"on-run-start": [] if path_info_only else self.on_run_start,
"on-run-end": [] if path_info_only else self.on_run_end,
"dispatch": [] if path_info_only else self.dispatch,
"seeds": {} if path_info_only else self.seeds,
"snapshots": {} if path_info_only else self.snapshots,
"sources": {} if path_info_only else self.sources,
"tests": {} if path_info_only else self.tests,
"vars": {} if path_info_only else self.vars.to_dict(),
"require-dbt-version": [v.to_version_string() for v in self.dbt_version],
"config-version": self.config_version,
}

View File

@@ -161,7 +161,7 @@ class RuntimeConfig(Project, Profile, AdapterRequiredConfig):
:returns dict: The serialized configuration.
"""
result = self.to_project_config(with_packages=True)
result = self.to_project_config(with_packages=True, path_info_only=False)
result.update(self.to_profile_info(serialize_credentials=True))
result["cli_vars"] = deepcopy(self.cli_vars)
return result
@@ -494,6 +494,20 @@ class UnsetProfileConfig(RuntimeConfig):
cli_vars=cli_vars,
dependencies=dependencies,
)
def serialize(self) -> Dict[str, Any]:
"""Serialize the full configuration to a single dictionary. For any
instance that has passed validate() (which happens in __init__), it
matches the Configuration contract.
Note that args are not serialized.
:returns dict: The serialized configuration.
"""
result = self.to_project_config(with_packages=True, path_info_only=True)
result.update(self.to_profile_info(serialize_credentials=True))
result["cli_vars"] = deepcopy(self.cli_vars)
return result
@classmethod
def _get_rendered_profile(