Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add some comments to methods constructing Project/RuntimeConfig
  • Loading branch information
gshank committed Jun 20, 2023
commit a0d7bd2ed968dbd67656f1a78323a743590fec6a
8 changes: 7 additions & 1 deletion core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ class RenderComponents:

@dataclass
class PartialProject(RenderComponents):
# This class includes the project_dict, packages_dict, selectors_dict, etc from RenderComponents
profile_name: Optional[str] = field(
metadata=dict(description="The unrendered profile name in the project, if set")
)
Expand Down Expand Up @@ -324,7 +325,7 @@ def get_rendered(
selectors_dict=rendered_selectors,
)

# Called by 'collect_parts' in RuntimeConfig
# Called by Project.from_project_root (not PartialProject.from_project_root!)
def render(self, renderer: DbtProjectYamlRenderer) -> "Project":
try:
rendered = self.get_rendered(renderer)
Expand Down Expand Up @@ -538,6 +539,7 @@ def from_dicts(
project_name = project_dict.get("name")
profile_name = project_dict.get("profile")

# Create a PartialProject
return cls(
profile_name=profile_name,
project_name=project_name,
Expand All @@ -555,6 +557,7 @@ def from_project_root(
) -> "PartialProject":
project_root = os.path.normpath(project_root)
project_dict = load_raw_project(project_root)
# Read packages.yml and dependencies.yml and pass dictionaries to "from_dicts" method
packages_dict, dependent_projects_dict = package_and_project_data_from_root(project_root)
selectors_dict = selector_data_from_root(project_root)
return cls.from_dicts(
Expand Down Expand Up @@ -715,6 +718,9 @@ def partial_load(cls, project_root: str, *, verify_version: bool = False) -> Par
verify_version=verify_version,
)

# Called by:
# RtConfig.load_dependencies => RtConfig.load_projects => RtConfig.new_project => Project.from_project_root
# RtConfig.from_args => RtConfig.collect_parts => load_project => Project.from_project_root
@classmethod
def from_project_root(
cls,
Expand Down
4 changes: 3 additions & 1 deletion core/dbt/config/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from .renderer import DbtProjectYamlRenderer, ProfileRenderer


# Called by RuntimeConfig.collect_parts class method
def load_project(
project_root: str,
version_check: bool,
Expand Down Expand Up @@ -237,6 +238,7 @@ def validate(self):
except ValidationError as e:
raise ConfigContractBrokenError(e) from e

# Called by RuntimeConfig.from_args
@classmethod
def collect_parts(cls: Type["RuntimeConfig"], args: Any) -> Tuple[Project, Profile]:
# profile_name from the project
Expand All @@ -251,7 +253,7 @@ def collect_parts(cls: Type["RuntimeConfig"], args: Any) -> Tuple[Project, Profi
project = load_project(project_root, bool(flags.VERSION_CHECK), profile, cli_vars)
return project, profile

# Called in main.py, lib.py, task/base.py
# Called in task/base.py, in BaseTask.from_args
@classmethod
def from_args(cls, args: Any) -> "RuntimeConfig":
"""Given arguments, read in dbt_project.yml from the current directory,
Expand Down