def _validate_file(fp: Path, schema: Dict[str, Any]): """Validate file against schema.""" try: data = read_yaml(fp) _validate_data(data, schema) except JsonSchemaValidationError as e: raise JsonSchemaError(path=fp, error=e)
def update_config(section: str, data: Dict[str, Any]) -> None: data = {section: data} config_file = Paths.config_file() if config_file.is_file(): config_yaml = read_yaml(config_file) config_yaml.update(data) write_yaml(config_file, config_yaml) else: write_yaml(config_file, data)
def read_config(section: str = '') -> Dict[str, Any]: config_file = Paths.config_file() if not config_file.is_file(): return {} config = read_yaml(config_file) if section != '': return config.get(section, {}) return config
def _check_properties_deprecations(fp: Path, schema: Dict[str, Any]): """Check for deprecated properties in config file. WARNING: this check currently doesn't support recursive lookup of properties!""" errors = [] data = read_yaml(fp) for name, value in schema.get('properties', {}).items(): if value.get("deprecated", False) and data.get(name) is not None: errors.append( DeprecatedConfigProperty(name, value.get("deprecationMessage"))) return errors
def read_fields(self) -> Iterable[Tuple[Dict[str, Any], Path]]: """Parse field files.""" for f in self.field_files: yield read_yaml(f), f
def read_models(self) -> Iterable[Tuple[Dict[str, Any], Path]]: """Parse model files.""" for f in self.model_files: yield read_yaml(f), f
def read_data_source(self) -> Dict[str, Any]: """Parse data source file.""" return read_yaml(self.data_source_file)
def read_transforms(self) -> Iterable[Tuple[Dict[str, str], Path]]: """Parse transform files.""" for f in self.transform_files: yield read_yaml(f), f