def _project_configs(self, project: Project, fqn: List[str], resource_type: NodeType) -> Iterator[Dict[str, Any]]: src = self.get_config_source(project) model_configs = src.get_config_dict(resource_type) for level_config in fqn_search(model_configs, fqn): result = {} for key, value in level_config.items(): if key.startswith('+'): result[key[1:]] = deepcopy(value) elif not isinstance(value, dict): result[key] = deepcopy(value) yield result
def get_project_config(self, model: IsFQNResource, project: HasConfigFields) -> Dict[str, Any]: # most configs are overwritten by a more specific config, but pre/post # hooks are appended! config: Dict[str, Any] = {} for k in self.AppendListFields: config[k] = [] for k in self.ExtendDictFields: config[k] = {} if model.resource_type == NodeType.Seed: model_configs = project.seeds elif model.resource_type == NodeType.Snapshot: model_configs = project.snapshots elif model.resource_type == NodeType.Source: model_configs = project.sources else: model_configs = project.models if model_configs is None: return config # mutates config self.update_config_keys_into(config, model_configs) for level_config in fqn_search(model_configs, model.fqn): relevant_configs = self.update_config_keys_into( config, level_config) # mutates config relevant_configs = self.update_config_keys_into( config, level_config) # TODO: does this do anything? Doesn't update_config_keys_into # handle the clobber case? clobber_configs = { k: v for (k, v) in relevant_configs.items() if k not in self.AppendListFields and k not in self.ExtendDictFields } config.update(clobber_configs) return config
def _project_configs(self, project: Project, fqn: List[str], resource_type: NodeType) -> Iterator[Dict[str, Any]]: if resource_type == NodeType.Seed: model_configs = project.seeds elif resource_type == NodeType.Snapshot: model_configs = project.snapshots elif resource_type == NodeType.Source: model_configs = project.sources else: model_configs = project.models for level_config in fqn_search(model_configs, fqn): result = {} for key, value in level_config.items(): if key.startswith('+'): result[key[1:]] = deepcopy(value) elif not isinstance(value, dict): result[key] = deepcopy(value) yield result