示例#1
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)
示例#2
0
 def write_data_source(self,
                       data_source: PanoVirtualDataSource,
                       *,
                       package: Optional[str] = None):
     """Write data source to local filesystem."""
     # Default to name of slugified name of DS
     package = package if package is not None else data_source.dataset_slug
     path = self.cwd / package / PresetFileName.DATASET_YAML.value
     logger.debug(f'About to write data source {data_source.id}')
     write_yaml(path, data_source.to_dict())
示例#3
0
 def write_model(self,
                 model: PanoModel,
                 *,
                 package: Optional[str] = None,
                 file_name: Optional[str] = None):
     """Write model to local filesystem."""
     # Default to name of slugified name of DS
     package_name = model.virtual_data_source if package is None else package
     assert package_name is not None  # TODO: virtual_data_source is Optional but shouldn't be
     if file_name is None:
         file_name = f'{model.model_name}{FileExtension.MODEL_YAML.value}'
     path = self.cwd / package_name / file_name
     logger.debug(f'About to write model {model.id}')
     write_yaml(path, model.to_dict())
示例#4
0
    def write_field(self,
                    field: PanoField,
                    *,
                    package: Optional[str] = None,
                    file_name: Optional[str] = None):
        """Write model to local filesystem."""
        if file_name is None:
            file_name = f'{field.slug}{FileExtension.FIELD_YAML.value}'

        package = package if package is not None else field.data_source
        if package is not None:
            # dataset-scope field
            path = Paths.fields_dir(self.cwd / package) / file_name
        else:
            # company-scope field
            path = Paths.fields_dir(self.cwd) / file_name

        logger.debug(f'About to write field {field.id}')
        write_yaml(path, field.to_dict())
示例#5
0
 def write_scanned_model(self, model: PanoModel):
     """Write scanned model to local filesystem."""
     path = Paths.scanned_dir(
     ) / f'{model.model_name}{FileExtension.MODEL_YAML.value}'
     logger.debug(f'About to write model {model.id}')
     write_yaml(path, model.to_dict())
示例#6
0
    def write_transform(self, transform: PanoTransform):
        file_name = f'{transform.name}{FileExtension.TRANSFORM_YAML.value}'
        path = Paths.transforms_dir() / file_name

        write_yaml(path, transform.to_dict())
示例#7
0
 def write_scanned_field(self, field: PanoField):
     """"Write scanned field to local filesystem."""
     path = Paths.scanned_fields_dir(
     ) / f'{field.slug}{FileExtension.FIELD_YAML.value}'
     logger.debug(f'About to write field {field.slug}')
     write_yaml(path, field.to_dict())