Git Product home page Git Product logo

Comments (7)

jni avatar jni commented on June 2, 2024 2

thoughts?

I actually have no memory of supporting multi-arrays at all, that's neat! 😜

I think we can be a little more proactive in the iteration — we should only iterate directories in that list comprehension. So:

for subpath is sorted(os.listdir(path))
if not subpath.startswith('.')
and os.path.isdir(path)
and (os.path.exists(os.path.join(path, '.zarray'))
     or os.path.exists(os.path.join(path, '.zgroup')))

At this point I think wrap path in a pathlib.Path to make that whole thing less of a mouthful, but you get my drift. Basically, only recurse subdirectories and only if they are actually zarr arrays or nested groups.

from napari.

d-v-b avatar d-v-b commented on June 2, 2024 2

for reference, in zarr-python right now, contains_group and contains_array both do what you would expect for checking if a path denotes a group or array.

Once you have a handle to a group, you can iterate over its sub-groups / sub-arrays with Group.items() (because Group is a MutableMapping, or just sub-arrays with Group.arrays, or just sub-groups with Group.groups.

Note that some of this will change in v3, but not too drastically -- e.g., we might make contains_array / contains_group take a zarr_format keyword argument, since zarr v3 and zarr v2 arrays can co-exist in the same directory.

from napari.

DragaDoncila avatar DragaDoncila commented on June 2, 2024 1

Great well, that should be an easy PR!

@imagejan if you are at all interested in contributing this fix yourself, let us know and we can guide you through it. Otherwise one of the core team will get to it as soon as we can!

from napari.

d-v-b avatar d-v-b commented on June 2, 2024 1

Is there any reason to not use the zarr-python api for listing groups and arrays here?

In zarr v3, .zarray and .zgroup are gone, and so this code will need to handle the names of the new metadata document (zarr.json). But if instead this code uses zarr-python to abstract over the names of the metadata documents, things are a lot simpler for napari, IMO

from napari.

jni avatar jni commented on June 2, 2024 1

Is there any reason to not use the zarr-python api for listing groups and arrays here?

ignorance! 😂 Since @imagejan already opened #6857 which is strictly better than the current situation, I suggest we merge that, then iterate. Thanks for the suggestion @d-v-b, that's indeed the right path forward.

from napari.

psobolewskiPhD avatar psobolewskiPhD commented on June 2, 2024

Thanks for reporting. I agree with the suggested expected behavior.
There's a couple builtins issues, looks like that part of napari needs a closer look.

from napari.

DragaDoncila avatar DragaDoncila commented on June 2, 2024

The problem code is here. It tries to read everything in the directory that doesn't start with a .. We should either try..except this and only raise later if the image is empty, or find a better way to identify the arrays than paths that don't start with a .. @jni thoughts?

from napari.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.