def _check_resource_uniqueness( manifest: Manifest, config: RuntimeConfig, ) -> None: names_resources: Dict[str, ManifestNode] = {} alias_resources: Dict[str, ManifestNode] = {} for resource, node in manifest.nodes.items(): if node.resource_type not in NodeType.refable(): continue # appease mypy - sources aren't refable! assert not isinstance(node, ParsedSourceDefinition) name = node.name # the full node name is really defined by the adapter's relation relation_cls = get_relation_class_by_name(config.credentials.type) relation = relation_cls.create_from(config=config, node=node) full_node_name = str(relation) existing_node = names_resources.get(name) if existing_node is not None: dbt.exceptions.raise_duplicate_resource_name(existing_node, node) existing_alias = alias_resources.get(full_node_name) if existing_alias is not None: dbt.exceptions.raise_ambiguous_alias(existing_alias, node, full_node_name) names_resources[name] = node alias_resources[full_node_name] = node
def from_parts( cls, project: Project, profile: Profile, args: Any, dependencies: Optional[Mapping[str, 'RuntimeConfig']] = None, ) -> 'RuntimeConfig': """Instantiate a RuntimeConfig from its components. :param profile: A parsed dbt Profile. :param project: A parsed dbt Project. :param args: The parsed command-line arguments. :returns RuntimeConfig: The new configuration. """ quoting: Dict[str, Any] = (get_relation_class_by_name( profile.credentials.type).get_default_quote_policy().replace_dict( project.quoting)).to_dict() cli_vars: Dict[str, Any] = parse_cli_vars(getattr(args, 'vars', '{}')) return cls( project_name=project.project_name, version=project.version, project_root=project.project_root, source_paths=project.source_paths, macro_paths=project.macro_paths, data_paths=project.data_paths, test_paths=project.test_paths, analysis_paths=project.analysis_paths, docs_paths=project.docs_paths, target_path=project.target_path, snapshot_paths=project.snapshot_paths, clean_targets=project.clean_targets, log_path=project.log_path, modules_path=project.modules_path, quoting=quoting, models=project.models, on_run_start=project.on_run_start, on_run_end=project.on_run_end, seeds=project.seeds, snapshots=project.snapshots, dbt_version=project.dbt_version, packages=project.packages, query_comment=project.query_comment, sources=project.sources, vars=project.vars, config_version=project.config_version, profile_name=profile.profile_name, target_name=profile.target_name, config=profile.config, threads=profile.threads, credentials=profile.credentials, args=args, cli_vars=cli_vars, dependencies=dependencies, )
def from_parts(cls, project, profile, args, allow_archive_configs=False): """Instantiate a RuntimeConfig from its components. :param profile Profile: A parsed dbt Profile. :param project Project: A parsed dbt Project. :param args argparse.Namespace: The parsed command-line arguments. :param allow_archive_configs bool: If True, ignore archive blocks in configs. This flag exists to enable archive migration. :returns RuntimeConfig: The new configuration. """ quoting = deepcopy( get_relation_class_by_name( profile.credentials.type).DEFAULTS['quote_policy']) quoting.update(project.quoting) if project.archive and not allow_archive_configs: # if the user has an `archive` section, raise an error raise DbtProjectError(_ARCHIVE_REMOVED_MESSAGE) return cls(project_name=project.project_name, version=project.version, project_root=project.project_root, source_paths=project.source_paths, macro_paths=project.macro_paths, data_paths=project.data_paths, test_paths=project.test_paths, analysis_paths=project.analysis_paths, docs_paths=project.docs_paths, target_path=project.target_path, snapshot_paths=project.snapshot_paths, clean_targets=project.clean_targets, log_path=project.log_path, modules_path=project.modules_path, quoting=quoting, models=project.models, on_run_start=project.on_run_start, on_run_end=project.on_run_end, archive=project.archive, seeds=project.seeds, dbt_version=project.dbt_version, packages=project.packages, profile_name=profile.profile_name, target_name=profile.target_name, config=profile.config, threads=profile.threads, credentials=profile.credentials, args=args)
def from_parts(cls, project, profile, args): """Instantiate a RuntimeConfig from its components. :param profile Profile: A parsed dbt Profile. :param project Project: A parsed dbt Project. :param args argparse.Namespace: The parsed command-line arguments. :returns RuntimeConfig: The new configuration. """ quoting = deepcopy( get_relation_class_by_name(profile.credentials.type) .DEFAULTS['quote_policy'] ) quoting.update(project.quoting) return cls( project_name=project.project_name, version=project.version, project_root=project.project_root, source_paths=project.source_paths, macro_paths=project.macro_paths, data_paths=project.data_paths, test_paths=project.test_paths, analysis_paths=project.analysis_paths, docs_paths=project.docs_paths, target_path=project.target_path, clean_targets=project.clean_targets, log_path=project.log_path, modules_path=project.modules_path, quoting=quoting, models=project.models, on_run_start=project.on_run_start, on_run_end=project.on_run_end, archive=project.archive, seeds=project.seeds, dbt_version=project.dbt_version, packages=project.packages, profile_name=profile.profile_name, target_name=profile.target_name, config=profile.config, threads=profile.threads, credentials=profile.credentials, args=args )
def from_parts(cls, project, profile, args): """Instantiate a RuntimeConfig from its components. :param profile Profile: A parsed dbt Profile. :param project Project: A parsed dbt Project. :param args argparse.Namespace: The parsed command-line arguments. :returns RuntimeConfig: The new configuration. """ quoting = (get_relation_class_by_name( profile.credentials.type).get_default_quote_policy().replace_dict( project.quoting)).to_dict() return cls(project_name=project.project_name, version=project.version, project_root=project.project_root, source_paths=project.source_paths, macro_paths=project.macro_paths, data_paths=project.data_paths, test_paths=project.test_paths, analysis_paths=project.analysis_paths, docs_paths=project.docs_paths, target_path=project.target_path, snapshot_paths=project.snapshot_paths, clean_targets=project.clean_targets, log_path=project.log_path, modules_path=project.modules_path, quoting=quoting, models=project.models, on_run_start=project.on_run_start, on_run_end=project.on_run_end, seeds=project.seeds, snapshots=project.snapshots, dbt_version=project.dbt_version, packages=project.packages, query_comment=project.query_comment, profile_name=profile.profile_name, target_name=profile.target_name, config=profile.config, threads=profile.threads, credentials=profile.credentials, args=args)
def from_parts(cls, project, profile, args): """Instantiate a RuntimeConfig from its components. :param profile Profile: A parsed dbt Profile. :param project Project: A parsed dbt Project. :param args argparse.Namespace: The parsed command-line arguments. :returns RuntimeConfig: The new configuration. """ quoting = deepcopy( get_relation_class_by_name(profile.credentials.type) .DEFAULTS['quote_policy'] ) quoting.update(project.quoting) return cls( project_name=project.project_name, version=project.version, project_root=project.project_root, source_paths=project.source_paths, macro_paths=project.macro_paths, data_paths=project.data_paths, test_paths=project.test_paths, analysis_paths=project.analysis_paths, docs_paths=project.docs_paths, target_path=project.target_path, clean_targets=project.clean_targets, log_path=project.log_path, modules_path=project.modules_path, quoting=quoting, models=project.models, on_run_start=project.on_run_start, on_run_end=project.on_run_end, archive=project.archive, seeds=project.seeds, packages=project.packages, profile_name=profile.profile_name, target_name=profile.target_name, config=profile.config, threads=profile.threads, credentials=profile.credentials, args=args )
def from_parts(cls, project, profile, cli_vars): """Instantiate a RuntimeConfig from its components. :param profile Profile: A parsed dbt Profile. :param project Project: A parsed dbt Project. :param cli_vars dict: A dict of vars, as provided from the command line. :returns RuntimeConfig: The new configuration. """ quoting = deepcopy( get_relation_class_by_name( profile.credentials.type).DEFAULTS['quote_policy']) quoting.update(project.quoting) return cls( project_name=project.project_name, version=project.version, project_root=project.project_root, source_paths=project.source_paths, macro_paths=project.macro_paths, data_paths=project.data_paths, test_paths=project.test_paths, analysis_paths=project.analysis_paths, docs_paths=project.docs_paths, target_path=project.target_path, clean_targets=project.clean_targets, log_path=project.log_path, modules_path=project.modules_path, quoting=quoting, models=project.models, on_run_start=project.on_run_start, on_run_end=project.on_run_end, archive=project.archive, seeds=project.seeds, packages=project.packages, profile_name=profile.profile_name, target_name=profile.target_name, send_anonymous_usage_stats=profile.send_anonymous_usage_stats, use_colors=profile.use_colors, threads=profile.threads, credentials=profile.credentials, cli_vars=cli_vars)