Beispiel #1
0
def project_name_from_path(include_path: str) -> str:
    # avoid an import cycle
    from dbt.config.project import Project
    partial = Project.partial_load(include_path)
    if partial.project_name is None:
        raise CompilationException(
            f'Invalid project at {include_path}: name not set!')
    return partial.project_name
Beispiel #2
0
 def __init__(self, adapter, credentials, include_path, dependencies=None):
     self.adapter = adapter
     self.credentials = credentials
     self.include_path = include_path
     project = Project.from_project_root(include_path, {})
     self.project_name = project.project_name
     if dependencies is None:
         dependencies = []
     self.dependencies = dependencies
Beispiel #3
0
 def __init__(self, adapter, credentials, include_path, dependencies=None):
     self.adapter = adapter
     self.credentials = credentials
     self.include_path = include_path
     project = Project.from_project_root(include_path, {})
     self.project_name = project.project_name
     if dependencies is None:
         dependencies = []
     self.dependencies = dependencies
Beispiel #4
0
    def partial_project(self) -> PartialProject:
        """Return a PartialProject for the dbt project given by this configuration.

        A PartialProject loads a dbt project configuration and handles access to
        configuration values. It is used by us to determine the profile name to use.

        Returns:
            A PartialProject instance for this configuration.
        """
        project_root = self.project_dir if self.project_dir else os.getcwd()
        version_check = bool(flags.VERSION_CHECK)
        partial_project = Project.partial_load(
            project_root, verify_version=version_check
        )

        return partial_project
Beispiel #5
0
    def __init__(self,
                 adapter: Type[BaseAdapter],
                 credentials: Type[Credentials],
                 include_path: str,
                 dependencies: Optional[List[str]] = None):
        # avoid an import cycle
        from dbt.config.project import Project

        self.adapter: Type[BaseAdapter] = adapter
        self.credentials: Type[Credentials] = credentials
        self.include_path: str = include_path
        project = Project.from_project_root(include_path, {})
        self.project_name: str = project.project_name
        self.dependencies: List[str]
        if dependencies is None:
            self.dependencies = []
        else:
            self.dependencies = dependencies
Beispiel #6
0
    def create_dbt_project_and_profile(
        self, extra_targets: Optional[dict[str, Any]] = None
    ) -> tuple[Project, Profile]:
        """Create a dbt Project and Profile using this configuration.

        Args:
            extra_targets: Additional targets for a dbt project's Profile.

        Returns:
            A tuple with an instance of Project and Profile.
        """
        profile = self.create_dbt_profile(extra_targets)

        project_renderer = DbtProjectYamlRenderer(profile, self.parsed_vars)
        project = Project.from_project_root(
            self.project_dir, project_renderer, verify_version=bool(flags.VERSION_CHECK)
        )
        project.project_env_vars = project_renderer.ctx_obj.env_vars

        return (project, profile)
Beispiel #7
0
    def __init__(
        self,
        adapter: Type[BaseAdapter],
        credentials: Type[Credentials],
        include_path: str,
        dependencies: Optional[List[str]] = None
    ):
        # avoid an import cycle
        from dbt.config.project import Project

        self.adapter: Type[BaseAdapter] = adapter
        self.credentials: Type[Credentials] = credentials
        self.include_path: str = include_path
        partial = Project.partial_load(include_path)
        if partial.project_name is None:
            raise CompilationException(
                f'Invalid project at {include_path}: name not set!'
            )
        self.project_name: str = partial.project_name
        self.dependencies: List[str]
        if dependencies is None:
            self.dependencies = []
        else:
            self.dependencies = dependencies