Skip to content

Commit

Permalink
Split ConfigRenderer into parts
Browse files Browse the repository at this point in the history
Docs now get the schema.yml parser vars
The SchemaParser now renders the entire schema.yml except tests/descriptions
  • Loading branch information
Jacob Beck committed Apr 20, 2020
1 parent c7d8031 commit 070e13d
Show file tree
Hide file tree
Showing 13 changed files with 298 additions and 173 deletions.
1 change: 0 additions & 1 deletion core/dbt/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
from .profile import Profile, PROFILES_DIR, read_user_config # noqa
from .project import Project # noqa
from .runtime import RuntimeConfig, UnsetProfileConfig # noqa
from .renderer import ConfigRenderer # noqa
12 changes: 6 additions & 6 deletions core/dbt/config/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.utils import coerce_dict_str

from .renderer import ConfigRenderer
from .renderer import ProfileRenderer

DEFAULT_THREADS = 1
DEFAULT_PROFILES_DIR = os.path.join(os.path.expanduser('~'), '.dbt')
Expand Down Expand Up @@ -240,7 +240,7 @@ def render_profile(
raw_profile: Dict[str, Any],
profile_name: str,
target_override: Optional[str],
renderer: ConfigRenderer,
renderer: ProfileRenderer,
) -> Tuple[str, Dict[str, Any]]:
"""This is a containment zone for the hateful way we're rendering
profiles.
Expand Down Expand Up @@ -268,15 +268,15 @@ def render_profile(
raw_profile, profile_name, target_name
)

profile_data = renderer.render_profile_data(raw_profile_data)
profile_data = renderer.render_data(raw_profile_data)
return target_name, profile_data

@classmethod
def from_raw_profile_info(
cls,
raw_profile: Dict[str, Any],
profile_name: str,
renderer: ConfigRenderer,
renderer: ProfileRenderer,
user_cfg: Optional[Dict[str, Any]] = None,
target_override: Optional[str] = None,
threads_override: Optional[int] = None,
Expand Down Expand Up @@ -330,7 +330,7 @@ def from_raw_profiles(
cls,
raw_profiles: Dict[str, Any],
profile_name: str,
renderer: ConfigRenderer,
renderer: ProfileRenderer,
target_override: Optional[str] = None,
threads_override: Optional[int] = None,
) -> 'Profile':
Expand Down Expand Up @@ -380,7 +380,7 @@ def from_raw_profiles(
def render_from_args(
cls,
args: Any,
renderer: ConfigRenderer,
renderer: ProfileRenderer,
project_profile_name: Optional[str],
) -> 'Profile':
"""Given the raw profiles as read from disk and the name of the desired
Expand Down
17 changes: 12 additions & 5 deletions core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

from hologram import ValidationError

from .renderer import ConfigRenderer
from .renderer import DbtProjectYamlRenderer


INVALID_VERSION_ERROR = """\
Expand Down Expand Up @@ -191,6 +191,9 @@ def _query_comment_from_cfg(

@dataclass
class PartialProject:
config_version: int = field(metadata=dict(
description='The version of the configuration file format'
))
profile_name: Optional[str] = field(metadata=dict(
description='The unrendered profile name in the project, if set'
))
Expand Down Expand Up @@ -562,11 +565,12 @@ def render_from_dict(
project_root: str,
project_dict: Dict[str, Any],
packages_dict: Dict[str, Any],
renderer: ConfigRenderer,
renderer: DbtProjectYamlRenderer,
) -> 'Project':
rendered_project = renderer.render_project(project_dict)
rendered_project = renderer.render_data(project_dict)
rendered_project['project-root'] = project_root
rendered_packages = renderer.render_packages_data(packages_dict)
package_renderer = renderer.get_package_renderer()
rendered_packages = package_renderer.render_data(packages_dict)
return cls.from_project_config(rendered_project, rendered_packages)

@classmethod
Expand All @@ -578,8 +582,10 @@ def partial_load(

project_name = project_dict.get('name')
profile_name = project_dict.get('profile')
config_version = project_dict.get('config-version', 1)

return PartialProject(
config_version=config_version,
profile_name=profile_name,
project_name=project_name,
project_root=project_root,
Expand All @@ -588,9 +594,10 @@ def partial_load(

@classmethod
def from_project_root(
cls, project_root: str, renderer: ConfigRenderer
cls, project_root: str, renderer: DbtProjectYamlRenderer
) -> 'Project':
partial = cls.partial_load(project_root)
renderer.version = partial.config_version
return partial.render(renderer)

def hashed_name(self):
Expand Down
Loading

0 comments on commit 070e13d

Please sign in to comment.