Skip to content

Conversation

@will-moore
Copy link
Member

@will-moore will-moore commented Aug 12, 2025

What do we call this command?

Please indicate your preferred name for the command. We will obviously need to add documentation

  • Will - import
  • JM: - record
  • Petr: - record
  • Dom: import
  • Jason: 'import'
  • Josh: "No objections [to import]"

This takes the register.py script from BioNGFF/omero-import-utils#24 and adds it to omero-cli-zarr.

This still gives us nice features:

To test:

$ omero zarr register --target 21520 https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0101A/13457227.zarr

@will-moore
Copy link
Member Author

This looks like similar issues to those discussed at #172 (comment) (also still failing checks there)...

"The jobs above are failing on the mypy check being run by omero-test-infra, so that's where we need to fix the python version.

How do I find out the version of python used by omero-test-infra, and can I control it?

The issue of python-version for omero-test-infra was also asked about at ome/omero-web-zarr#19 (comment)

cc @joshmoore

@will-moore
Copy link
Member Author

Checks above are failing, but test is running and passing locally:

(omeroweb2) M-002366:omero-cli-zarr wmoore$ cd test/
(omeroweb2) M-002366:test wmoore$ pytest integration/clitest/test_register.py 
============================ test session starts ============================
platform darwin -- Python 3.9.15, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/wmoore/Desktop/ZARR/omero-cli-zarr
plugins: hypothesis-6.100.1, dash-2.9.3, napari-0.4.17, napari-plugin-engine-0.2.0, django-4.8.0, anyio-4.2.0
collected 6 items                                                                                                                                    

integration/clitest/test_register.py ......                                                        [100%]

============= warnings summary =========================
../../../../opt/anaconda3/envs/omeroweb2/lib/python3.9/site-packages/Ice.py:14
  /Users/wmoore/opt/anaconda3/envs/omeroweb2/lib/python3.9/site-packages/Ice.py:14: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import sys, string, imp, os, threading, warnings, datetime

../../../../opt/anaconda3/envs/omeroweb2/lib/python3.9/site-packages/skimage/util/dtype.py:27
  /Users/wmoore/opt/anaconda3/envs/omeroweb2/lib/python3.9/site-packages/skimage/util/dtype.py:27: DeprecationWarning: `np.bool8` is a deprecated alias for `np.bool_`.  (Deprecated NumPy 1.24)
    np.bool8: (False, True),

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================== 6 passed, 2 warnings in 28.30s =========================

@will-moore
Copy link
Member Author

Build errors seem to be due to Zarr v3 references:

src/omero_zarr/register.py:88: error: Name "zarr.core.Array" is not defined  [name-defined]
src/omero_zarr/register.py:89: error: Module has no attribute "open"  [attr-defined]
src/omero_zarr/register.py:97: error: Module has no attribute "open"  [attr-defined]
src/omero_zarr/register.py:633: error: Module has no attribute "errors"  [attr-defined]

@snoopycrimecop
Copy link
Member

snoopycrimecop commented Aug 27, 2025

Conflicting PR. Removed from build OMERO-plugins-push#516. See the console output for more details.
Possible conflicts:

--conflicts Conflict resolved in build OMERO-plugins-push#517. See the console output for more details.

Copy link
Member

@dominikl dominikl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks Will. I guess before mergeing we have to discuss/decide on the name import/register/??? .

@dominikl
Copy link
Member

dominikl commented Sep 9, 2025

Actually, just noticed that this doesn't seem to work with local files on the file system:

> omero zarr register --target 3751 /data/testing/sarscov2-phenomics-repurposing/bioformats-convert-PP103554
...
  File "/home/dlindner/micromamba/envs/import/lib/python3.12/site-packages/omero_zarr/register.py", line 639, in register_zarr
    store = zarr.storage.LocalStore(uri, read_only=True)
            ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'LocalStore'

@will-moore
Copy link
Member Author

@dominikl I think that looks like you have zarr v3 in your local env. You need zarr v2

@dominikl
Copy link
Member

dominikl commented Sep 9, 2025

Indeed. There's something odd going on. I simply checkout this branch and pip install . This will install zarr-2.18.7. Then pip install -U zarr will install zarr 3 but uninstall omero-cli-zarr. Then installing omero-cli-zarr again, will remove zarr 3 and install zarr 2 again. Doesn't seem to be possible to have both!?

@dominikl
Copy link
Member

dominikl commented Sep 9, 2025

Sorry, installing zarr 3 does not uninstall omero-cli-zarr, it just break it:

  File "/home/dlindner/micromamba/envs/import/lib/python3.12/site-packages/ome_zarr/format.py", line 7, in <module>
    from zarr.storage import FSStore
ImportError: cannot import name 'FSStore' from 'zarr.storage'

@will-moore
Copy link
Member Author

DON'T INSTALL ZARR V3.
YOU NEED ZARR V2.

@dominikl
Copy link
Member

dominikl commented Sep 9, 2025

> git log
commit b8c63a5b03b25b3a39748b27729f50d97a5385de (HEAD, will/register_command)
Author: William Moore <[email protected]>
Date:   Thu Aug 28 16:38:32 2025 +0100

    don't use delete_on_close for tempfile (py312 only)

> pip install .
...
Successfully installed aiobotocore-2.24.2 aiohappyeyeballs-2.6.1 aiohttp-3.12.15 aioitertools-0.12.0 aiosignal-1.4.0 asciitree-0.3.3 attrs-25.3.0 botocore-1.40.18 click-8.2.1 cloudpickle-3.1.1 dask-2025.7.0 deprecated-1.2.18 fasteners-0.20 frozenlist-1.7.0 fsspec-2025.9.0 imageio-2.37.0 jmespath-1.0.1 lazy-loader-0.4 locket-1.0.0 multidict-6.6.4 networkx-3.5 numcodecs-0.15.1 ome-zarr-0.11.1 omero-cli-zarr-0.5.6.dev72+gb8c63a5 partd-1.4.2 propcache-0.3.2 s3fs-2025.9.0 scikit-image-0.25.2 scipy-1.16.1 tifffile-2025.8.28 toolz-1.0.0 typing-extensions-4.15.0 wrapt-1.17.3 yarl-1.20.1 zarr-2.18.7

> pip freeze
zarr==2.18.7

> omero zarr register --target 3751 /data/testing/sarscov2-phenomics-repurposing/bioformats-convert-PP103554
Using session for demo@localhost:4064. Idle timeout: 10 min. Current group: Public
Registering zarr file as an Image in OMERO /data/testing/sarscov2-phenomics-repurposing/bioformats-convert-PP103554
Traceback (most recent call last):
...
  File "/home/dlindner/micromamba/envs/import_2/lib/python3.12/site-packages/omero_zarr/register.py", line 639, in register_zarr
    store = zarr.storage.LocalStore(uri, read_only=True)
            ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'zarr.storage' has no attribute 'LocalStore'

@will-moore
Copy link
Member Author

Sorry, my bad. It is a case of zarr 3 vv 2 mixup, and you do need zarr v2, but that line is wrong.

Try

store = zarr.storage.NestedDirectoryStore(uri)

@dominikl
Copy link
Member

dominikl commented Sep 9, 2025

Thanks Will, that fixes the problem!

@will-moore
Copy link
Member Author

@dominikl I added that fix, and also ported the labels code from https://github.com/BioNGFF/omero-import-utils/pull/7/files.

Tested with:

$ omero zarr register https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr --target 22521 --labels

),
)
register.add_argument(
import_cmd.add_argument(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understood that we were not going to include labels for now as part of this workflow

@will-moore
Copy link
Member Author

@jburel I understood that we were going to prioritise the migration from BioNGFF/omero-import-utils to here ahead of merging the labels PR there (which we've done).
But the labels functionality is useful (Dom was using it for IDR and was asking about it) so it makes sense to bring it along too. It's still under an optional flag, so doesn't change the default behaviour (NB: I still need to find some suitable Plates and bioformats2raw samples with labels to test those).

@dominikl dominikl self-requested a review September 15, 2025 08:38
@jburel
Copy link
Member

jburel commented Sep 15, 2025

@jburel I understood that we were going to prioritise the migration from BioNGFF/omero-import-utils to here ahead of merging the labels PR there (which we've done). But the labels functionality is useful (Dom was using it for IDR and was asking about it) so it makes sense to bring it along too. It's still under an optional flag, so doesn't change the default behaviour (NB: I still need to find some suitable Plates and bioformats2raw samples with labels to test those).

BioNGFF/omero-import-utils#7 The PR was closed. We decided not to merge it due to the time it was taking, we have to read the binary data when supporting labels. I understand that it can be useful but I think we need more tests before pushing forward with that option
I believe the files are local in @dominikl case.
Labels support should be investigated as a follow-up

@will-moore
Copy link
Member Author

The PR was only closed after copying it over to this PR.

I just uploaded a new sample that is bioformats2raw layout containing 3 images, 2 of which have labels.

Imported into merge-ci...

$ omero zarr import https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0079A/idr0079_images.zarr --labels --target 23619
Screenshot 2025-09-15 at 21 51 23

I could revert that and move it to another branch, on top of this one, but it might be nicer to just do a bit more testing on this one? @dominikl

@jburel
Copy link
Member

jburel commented Sep 15, 2025

I don't think it was solely closed because we started working on this repository.
We discussed not involving the reading of the binary due to potential performance issues

My preference:

  • Create a release candidate with support for images and not labels. I will also disable plate support for now
  • Look at asynchronous support for plate and labels as follow up works

@will-moore will-moore changed the title Register command Import command Sep 16, 2025
Copy link
Member

@dominikl dominikl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me. Tested with some examples from BioNGFF/omero-import-utils#13. Also no --labels option any longer, and trying to import plate says that it's not supported yet. 👍
Hopefully you can easily revert your last two commits and open separate PRs for them (I think there's a git command for it?).

@jburel
Copy link
Member

jburel commented Sep 17, 2025

suggestion: 0.7.0rc1

@will-moore
Copy link
Member Author

@dominikl I just pushed a couple of commits to update the README, to add import info, and also to update a VERY old like to the spec! Staged at https://github.com/will-moore/omero-cli-zarr/tree/register_command

@dominikl
Copy link
Member

👍 Thanks, looks good to me!

@will-moore will-moore merged commit 2d456d0 into ome:master Sep 17, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants