1515from webknossos .geometry import BoundingBox
1616
1717
18- def make_dataset (dataset_path : Path ) -> tuple [Dataset , SegmentationLayer ]:
18+ def make_dataset (dataset_path : UPath ) -> tuple [Dataset , SegmentationLayer ]:
1919 dataset = Dataset (dataset_path / "test_attachments" , voxel_size = (10 , 10 , 10 ))
2020 seg_layer = dataset .add_layer (
2121 "seg" ,
@@ -26,8 +26,8 @@ def make_dataset(dataset_path: Path) -> tuple[Dataset, SegmentationLayer]:
2626 return dataset , seg_layer
2727
2828
29- def test_attachments (tmp_path : Path ) -> None :
30- dataset , seg_layer = make_dataset (tmp_path )
29+ def test_attachments (tmp_upath : UPath ) -> None :
30+ dataset , seg_layer = make_dataset (tmp_upath )
3131
3232 # meshes
3333 seg_layer .attachments .add_mesh (
@@ -142,14 +142,14 @@ def test_attachments(tmp_path: Path) -> None:
142142 assert "attachments" not in properties_json ["dataLayers" ][0 ]
143143
144144
145- def test_copy_layer (tmp_path : Path ) -> None :
146- dataset , seg_layer = make_dataset (tmp_path )
145+ def test_copy_layer (tmp_upath : UPath ) -> None :
146+ dataset , seg_layer = make_dataset (tmp_upath )
147147
148148 mesh_path = dataset .path / "seg" / "meshes" / "meshfile.hdf5"
149149 mesh_path .parent .mkdir (parents = True , exist_ok = True )
150150 mesh_path .write_text ("test" )
151151
152- agglomerate_path = (tmp_path / "agglomerate_view_15" ).resolve ()
152+ agglomerate_path = (tmp_upath / "agglomerate_view_15" ).resolve ()
153153 agglomerate_path .mkdir (parents = True , exist_ok = True )
154154 (agglomerate_path / "zarr.json" ).write_text ("test" )
155155
@@ -164,7 +164,7 @@ def test_copy_layer(tmp_path: Path) -> None:
164164 data_format = AttachmentDataFormat .Zarr3 ,
165165 )
166166
167- copy_dataset = Dataset (tmp_path / "test_copy" , voxel_size = (10 , 10 , 10 ))
167+ copy_dataset = Dataset (tmp_upath / "test_copy" , voxel_size = (10 , 10 , 10 ))
168168 copy_layer = copy_dataset .add_copy_layer (seg_layer ).as_segmentation_layer ()
169169
170170 assert (
@@ -189,14 +189,14 @@ def test_copy_layer(tmp_path: Path) -> None:
189189 )
190190
191191
192- def test_fs_copy_layer (tmp_path : Path ) -> None :
193- dataset , seg_layer = make_dataset (tmp_path )
192+ def test_fs_copy_layer (tmp_upath : UPath ) -> None :
193+ dataset , seg_layer = make_dataset (tmp_upath )
194194
195195 mesh_path = dataset .path / "seg" / "meshes" / "meshfile.hdf5"
196196 mesh_path .parent .mkdir (parents = True , exist_ok = True )
197197 mesh_path .write_text ("test" )
198198
199- agglomerate_path = (tmp_path / "agglomerate_view_15" ).resolve ()
199+ agglomerate_path = (tmp_upath / "agglomerate_view_15" ).resolve ()
200200 agglomerate_path .mkdir (parents = True , exist_ok = True )
201201 (agglomerate_path / "zarr.json" ).write_text ("test" )
202202
@@ -212,7 +212,7 @@ def test_fs_copy_layer(tmp_path: Path) -> None:
212212 data_format = AttachmentDataFormat .Zarr3 ,
213213 )
214214
215- copy_dataset = Dataset (tmp_path / "test_copy" , voxel_size = (10 , 10 , 10 ))
215+ copy_dataset = Dataset (tmp_upath / "test_copy" , voxel_size = (10 , 10 , 10 ))
216216 copy_layer = copy_dataset .add_fs_copy_layer (seg_layer ).as_segmentation_layer ()
217217
218218 # has been copied
@@ -229,14 +229,14 @@ def test_fs_copy_layer(tmp_path: Path) -> None:
229229 )
230230
231231
232- def test_symlink_layer (tmp_path : Path ) -> None :
233- dataset , seg_layer = make_dataset (tmp_path )
232+ def test_symlink_layer (tmp_upath : UPath ) -> None :
233+ dataset , seg_layer = make_dataset (tmp_upath )
234234
235235 mesh_path = dataset .path / "seg" / "meshes" / "meshfile.hdf5"
236236 mesh_path .parent .mkdir (parents = True , exist_ok = True )
237237 mesh_path .write_text ("test" )
238238
239- agglomerate_path = (tmp_path / "agglomerate_view_15" ).resolve ()
239+ agglomerate_path = (tmp_upath / "agglomerate_view_15" ).resolve ()
240240 agglomerate_path .mkdir (parents = True , exist_ok = True )
241241 (agglomerate_path / "zarr.json" ).write_text ("test" )
242242
@@ -252,7 +252,7 @@ def test_symlink_layer(tmp_path: Path) -> None:
252252 data_format = AttachmentDataFormat .Zarr3 ,
253253 )
254254
255- copy_dataset = Dataset (tmp_path / "test_copy" , voxel_size = (10 , 10 , 10 ))
255+ copy_dataset = Dataset (tmp_upath / "test_copy" , voxel_size = (10 , 10 , 10 ))
256256 copy_layer = copy_dataset .add_symlink_layer (
257257 seg_layer , make_relative = True
258258 ).as_segmentation_layer ()
@@ -276,8 +276,8 @@ def test_symlink_layer(tmp_path: Path) -> None:
276276 )
277277
278278
279- def test_remote_layer (tmp_path : Path ) -> None :
280- dataset , seg_layer = make_dataset (tmp_path )
279+ def test_remote_layer (tmp_upath : UPath ) -> None :
280+ dataset , seg_layer = make_dataset (tmp_upath )
281281
282282 mesh_path = UPath (
283283 "s3://bucket/meshfile.zarr" ,
@@ -290,7 +290,7 @@ def test_remote_layer(tmp_path: Path) -> None:
290290 data_format = AttachmentDataFormat .Zarr3 ,
291291 )
292292
293- copy_dataset = Dataset (tmp_path / "test_copy" , voxel_size = (10 , 10 , 10 ))
293+ copy_dataset = Dataset (tmp_upath / "test_copy" , voxel_size = (10 , 10 , 10 ))
294294 copy_layer = copy_dataset .add_remote_layer (seg_layer ).as_segmentation_layer ()
295295
296296 assert copy_layer .attachments .meshes [0 ].path == mesh_path
@@ -301,8 +301,8 @@ def test_remote_layer(tmp_path: Path) -> None:
301301 )
302302
303303
304- def test_upload_fail (tmp_path : Path ) -> None :
305- dataset , seg_layer = make_dataset (tmp_path )
304+ def test_upload_fail (tmp_upath : UPath ) -> None :
305+ dataset , seg_layer = make_dataset (tmp_upath )
306306 seg_layer .attachments .add_mesh (
307307 dataset .path / "seg" / "meshfile" ,
308308 name = "meshfile" ,
@@ -313,8 +313,8 @@ def test_upload_fail(tmp_path: Path) -> None:
313313 dataset .upload ()
314314
315315
316- def test_unique_attachment_names (tmp_path : Path ) -> None :
317- dataset , seg_layer = make_dataset (tmp_path )
316+ def test_unique_attachment_names (tmp_upath : UPath ) -> None :
317+ dataset , seg_layer = make_dataset (tmp_upath )
318318
319319 seg_layer .attachments .add_mesh (
320320 UPath ("http://example.com/meshfile.zarr" ),
@@ -329,8 +329,8 @@ def test_unique_attachment_names(tmp_path: Path) -> None:
329329 )
330330
331331
332- def test_acceptable_attachment_names (tmp_path : Path ) -> None :
333- dataset , seg_layer = make_dataset (tmp_path )
332+ def test_acceptable_attachment_names (tmp_upath : UPath ) -> None :
333+ dataset , seg_layer = make_dataset (tmp_upath )
334334
335335 with pytest .raises (ValueError ):
336336 seg_layer .attachments .add_mesh (
@@ -356,8 +356,8 @@ def test_remote_dataset() -> None:
356356 assert seg_layer .attachments .meshes [0 ]._properties .path == "seg/meshes/meshfile"
357357
358358
359- def test_add_attachments (tmp_path : Path ) -> None :
360- dataset , seg_layer = make_dataset (tmp_path )
359+ def test_add_attachments (tmp_upath : UPath ) -> None :
360+ dataset , seg_layer = make_dataset (tmp_upath )
361361
362362 mesh = MeshAttachment .from_path_and_name (
363363 dataset .path / "seg" / "meshes" / "meshfile" ,
@@ -370,11 +370,11 @@ def test_add_attachments(tmp_path: Path) -> None:
370370 assert seg_layer .attachments .meshes [0 ].name == "meshfile_4-4-1"
371371
372372
373- def test_add_copy_attachments (tmp_path : Path ) -> None :
374- dataset , seg_layer = make_dataset (tmp_path )
373+ def test_add_copy_attachments (tmp_upath : UPath ) -> None :
374+ dataset , seg_layer = make_dataset (tmp_upath )
375375
376376 # meshes
377- mesh_path = tmp_path / "meshfile"
377+ mesh_path = tmp_upath / "meshfile"
378378 mesh_path .write_text ("test" )
379379
380380 mesh = MeshAttachment .from_path_and_name (
@@ -393,7 +393,7 @@ def test_add_copy_attachments(tmp_path: Path) -> None:
393393 assert mesh_path .exists ()
394394
395395 # segment index (has camel-casing)
396- segment_index_path = tmp_path / "segment_index"
396+ segment_index_path = tmp_upath / "segment_index"
397397 segment_index_path .write_text ("test" )
398398
399399 segment_index = SegmentIndexAttachment .from_path_and_name (
@@ -408,11 +408,11 @@ def test_add_copy_attachments(tmp_path: Path) -> None:
408408 )
409409
410410
411- def test_add_symlink_attachments (tmp_path : Path ) -> None :
412- dataset , seg_layer = make_dataset (tmp_path )
411+ def test_add_symlink_attachments (tmp_upath : UPath ) -> None :
412+ dataset , seg_layer = make_dataset (tmp_upath )
413413
414414 # meshes
415- mesh_path = tmp_path .resolve () / "meshfile"
415+ mesh_path = tmp_upath .resolve () / "meshfile"
416416 mesh_path .write_text ("test" )
417417
418418 mesh = MeshAttachment .from_path_and_name (
@@ -430,7 +430,7 @@ def test_add_symlink_attachments(tmp_path: Path) -> None:
430430 assert mesh_path .exists ()
431431
432432 # segment index (has camel-casing)
433- segment_index_path = tmp_path / "segment_index"
433+ segment_index_path = tmp_upath / "segment_index"
434434 segment_index_path .write_text ("test" )
435435
436436 segment_index = SegmentIndexAttachment .from_path_and_name (
@@ -450,8 +450,8 @@ def test_add_symlink_attachments(tmp_path: Path) -> None:
450450 ).resolve () == segment_index_path
451451
452452
453- def test_detect_legacy_attachments (tmp_path : Path ) -> None :
454- _ , seg_layer = make_dataset (tmp_path )
453+ def test_detect_legacy_attachments (tmp_upath : UPath ) -> None :
454+ _ , seg_layer = make_dataset (tmp_upath )
455455
456456 # legacy meshes
457457 mesh_path = seg_layer .path / "meshes" / "meshfile_4-4-1.hdf5"
0 commit comments