|
40 | 40 | ) |
41 | 41 | from ..geometry.mag import MagLike |
42 | 42 | from ..geometry.nd_bounding_box import derive_nd_bounding_box_from_shape |
43 | | -from ._array import ArrayException, ArrayInfo, BaseArray |
| 43 | +from ._array import ArrayException, ArrayInfo, BaseArray, Zarr3ArrayInfo, Zarr3Config |
44 | 44 | from ._metadata import DatasetMetadata |
45 | 45 | from ._utils import pims_images |
46 | 46 | from .defaults import ( |
@@ -522,7 +522,7 @@ def announce_manual_upload( |
522 | 522 | datastore_url = _cached_get_upload_datastore(context) |
523 | 523 | datastore_api = context.get_datastore_api_client(datastore_url) |
524 | 524 | response = datastore_api.dataset_reserve_manual_upload( |
525 | | - dataset_announce, token=token |
| 525 | + dataset_announce=dataset_announce, token=token |
526 | 526 | ) |
527 | 527 | return response.new_dataset_id, response.directory_name |
528 | 528 |
|
@@ -563,7 +563,9 @@ def trigger_reload_in_datastore( |
563 | 563 | context = _get_context() |
564 | 564 | upload_url = datastore_url or _cached_get_upload_datastore(context) |
565 | 565 | datastore_api = context.get_datastore_api_client(upload_url) |
566 | | - datastore_api.dataset_trigger_reload(organization, dataset_name, token=token) |
| 566 | + datastore_api.dataset_trigger_reload( |
| 567 | + organization_id=organization, dataset_name=dataset_name, token=token |
| 568 | + ) |
567 | 569 |
|
568 | 570 | @classmethod |
569 | 571 | def trigger_dataset_import( |
@@ -2235,7 +2237,7 @@ def add_layer_as_copy( |
2235 | 2237 | shard_shape: Vec3IntLike | int | None = None, |
2236 | 2238 | chunks_per_shard: Vec3IntLike | int | None = None, |
2237 | 2239 | data_format: str | DataFormat | None = None, |
2238 | | - compress: bool | None = None, |
| 2240 | + compress: bool | Zarr3Config | None = None, |
2239 | 2241 | exists_ok: bool = False, |
2240 | 2242 | executor: Executor | None = None, |
2241 | 2243 | with_attachments: bool = True, |
@@ -2315,17 +2317,48 @@ def add_layer_as_copy( |
2315 | 2317 | f"Copying {mag_view.layer.name}/{mag_view.mag.to_layer_name()}" |
2316 | 2318 | ) |
2317 | 2319 |
|
2318 | | - layer.add_mag_as_copy( |
2319 | | - mag_view, |
2320 | | - extend_layer_bounding_box=False, |
2321 | | - chunk_shape=chunk_shape, |
2322 | | - shard_shape=shard_shape, |
2323 | | - chunks_per_shard=chunks_per_shard, |
2324 | | - compress=compress, |
2325 | | - exists_ok=exists_ok, |
2326 | | - executor=executor, |
2327 | | - progress_desc=progress_desc, |
2328 | | - ) |
| 2320 | + can_use_fs_copy = True |
| 2321 | + if ( |
| 2322 | + (chunk_shape is not None and chunk_shape != mag_view.info.chunk_shape) |
| 2323 | + or ( |
| 2324 | + shard_shape is not None and shard_shape != mag_view.info.shard_shape |
| 2325 | + ) |
| 2326 | + or ( |
| 2327 | + chunks_per_shard is not None |
| 2328 | + and chunks_per_shard != mag_view.info.chunks_per_shard |
| 2329 | + ) |
| 2330 | + or ( |
| 2331 | + data_format is not None and data_format != mag_view.info.data_format |
| 2332 | + ) |
| 2333 | + or ( |
| 2334 | + compress is not None |
| 2335 | + and ( |
| 2336 | + isinstance(compress, Zarr3Config) |
| 2337 | + and isinstance(mag_view.info, Zarr3ArrayInfo) |
| 2338 | + and compress != mag_view.info.zarr3_config |
| 2339 | + ) |
| 2340 | + or compress != mag_view.info.compression_mode |
| 2341 | + ) |
| 2342 | + ): |
| 2343 | + can_use_fs_copy = False |
| 2344 | + |
| 2345 | + if can_use_fs_copy: |
| 2346 | + layer.add_fs_copy_mag( |
| 2347 | + mag_view, |
| 2348 | + extend_layer_bounding_box=False, |
| 2349 | + ) |
| 2350 | + else: |
| 2351 | + layer.add_mag_as_copy( |
| 2352 | + mag_view, |
| 2353 | + extend_layer_bounding_box=False, |
| 2354 | + chunk_shape=chunk_shape, |
| 2355 | + shard_shape=shard_shape, |
| 2356 | + chunks_per_shard=chunks_per_shard, |
| 2357 | + compress=compress, |
| 2358 | + exists_ok=exists_ok, |
| 2359 | + executor=executor, |
| 2360 | + progress_desc=progress_desc, |
| 2361 | + ) |
2329 | 2362 |
|
2330 | 2363 | if ( |
2331 | 2364 | with_attachments |
@@ -2743,7 +2776,7 @@ def fs_copy_dataset( |
2743 | 2776 |
|
2744 | 2777 | if any(layer.data_format == DataFormat.WKW for layer in self.layers.values()): |
2745 | 2778 | assert is_fs_path(new_dataset_path), ( |
2746 | | - "Cannot create WKW layers in remote datasets. Use explicit `data_format='zarr3'`." |
| 2779 | + "Cannot create WKW layers in remote datasets. Use `Dataset.copy_dataset` with `data_format='zarr3'`." |
2747 | 2780 | ) |
2748 | 2781 |
|
2749 | 2782 | new_dataset = Dataset( |
@@ -3579,7 +3612,7 @@ def download_mesh( |
3579 | 3612 | "When you attempt to download a mesh without a tracing_id, the layer_name must be set." |
3580 | 3613 | ) |
3581 | 3614 | mesh_download = datastore.download_mesh( |
3582 | | - mesh_info, |
| 3615 | + mesh_info=mesh_info, |
3583 | 3616 | organization_id=organization_id or context.organization_id, |
3584 | 3617 | directory_name=directory_name, |
3585 | 3618 | layer_name=layer_name, |
|
0 commit comments