Example #1
0
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)
Example #2
0
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)
Example #3
0
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
Example #4
0
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
Example #5
0
 def read_fields(self) -> Iterable[Tuple[Dict[str, Any], Path]]:
     """Parse field files."""
     for f in self.field_files:
         yield read_yaml(f), f
Example #6
0
 def read_models(self) -> Iterable[Tuple[Dict[str, Any], Path]]:
     """Parse model files."""
     for f in self.model_files:
         yield read_yaml(f), f
Example #7
0
 def read_data_source(self) -> Dict[str, Any]:
     """Parse data source file."""
     return read_yaml(self.data_source_file)
Example #8
0
 def read_transforms(self) -> Iterable[Tuple[Dict[str, str], Path]]:
     """Parse transform files."""
     for f in self.transform_files:
         yield read_yaml(f), f