def test_sync_to_dir_local(self): path = os.path.join(self.tmp_dir.name, 'lorem', 'ipsum.txt') src = os.path.dirname(path) dst = os.path.join(self.tmp_dir.name, 'xxx') make_dir(src, check_empty=False) make_dir(dst, check_empty=False) fs = FileSystem.get_file_system(path, 'r') fs.write_bytes(path, bytes([0x00, 0x01])) sync_to_dir(src, dst, delete=True) self.assertEqual(len(list_paths(dst)), 1)
def save(self, labels: SemanticSegmentationLabels) -> None: """Save labels to disk. More info on rasterio IO: - https://github.com/mapbox/rasterio/blob/master/docs/quickstart.rst - https://rasterio.readthedocs.io/en/latest/topics/windowed-rw.html Args: labels - (SemanticSegmentationLabels) labels to be saved """ local_root = get_local_path(self.root_uri, self.tmp_dir) make_dir(local_root) out_profile = { 'driver': 'GTiff', 'height': self.extent.ymax, 'width': self.extent.xmax, 'transform': self.crs_transformer.get_affine_transform(), 'crs': self.crs_transformer.get_image_crs(), 'blockxsize': self.rasterio_block_size, 'blockysize': self.rasterio_block_size } # if old scores exist, combine them with the new ones if self.score_raster_source: log.info('Old scores found. Merging with current scores.') old_labels = self.get_scores() labels += old_labels self.write_discrete_raster_output( out_profile, get_local_path(self.label_uri, self.tmp_dir), labels) if self.smooth_output: self.write_smooth_raster_output( out_profile, get_local_path(self.score_uri, self.tmp_dir), get_local_path(self.hits_uri, self.tmp_dir), labels, chip_sz=self.rasterio_block_size) if self.vector_outputs: self.write_vector_outputs(labels) sync_to_dir(local_root, self.root_uri)
def test_sync_to_http(self): src = self.tmp_dir.name dst = 'http://localhost/' self.assertRaises(NotWritableError, lambda: sync_to_dir(src, dst))
def sync_to_cloud(self): """Sync any output to the cloud at output_uri.""" sync_to_dir(self.output_dir, self.cfg.output_uri)
def sync_to_cloud(self): """Sync any output to the cloud at output_uri.""" if self.cfg.output_uri.startswith('s3://'): sync_to_dir(self.output_dir, self.cfg.output_uri)