Skip to content

Conversion to webknossos dataset from Zarr fails due to UPath being passed to ternsorstore.open() #1404

@cppprp

Description

@cppprp

Context

  • Affected library: Webknossos CLI

Trying to convert a Zarr dataset to WBK dataset using webknossos convert-zarr

Current Behavior

The path to the Zarr dataset is converted to a UPath before being opened with Tensorstore.
UPath cannot be serialised to JSON and throws an error:
return tensorstore.open(
TypeError: Object does not support conversion to JSON

When in the except clause the wrong exception is caught:
except tensorstore.TensorStoreError:
AttributeError: module 'tensorstore' has no attribute 'TensorStoreError'.

Steps to Reproduce the bug

pulled from webknossos convert-zarr

def _try_open_zarr(path: UPath) -> tensorstore.TensorStore:
    try:
        return tensorstore.open(
            {"driver": "zarr3", "kvstore": {"driver": "file", "path": path}}
        ).result()
    except tensorstore.TensorStoreError:
        return tensorstore.open(
            {"driver": "zarr", "kvstore": {"driver": "file", "path": path}}
        ).result()
source = "/Path/to/zarr/directory/"
source_u = UPath(source)
res = _try_open_zarr(source_u)

Your Environment for bug

  • webknossos version: 3.0.4
  • Python version: 3.12
  • OS: Rocky Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions