Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extinfo command #167

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Add extinfo command #167

wants to merge 5 commits into from

Conversation

dominikl
Copy link
Member

@dominikl dominikl commented Feb 25, 2025

This command will automatically set the ExternalInfo for ome.zarr images imported using the omero-zarr-pixel-buffer.

I takes the path from the Fileset "usedFiles", which is assumed to only have one entry ..../SOME.ome.zarr/OME/METADATA.ome.xml and then set the ExternalInfo lsid to the full path of the multiscale 5d image; ..../SOME.ome.zarr/0 for an image ..../SOME.ome.zarr/A/1/1 etc. for plates.

Limitations: Only works for ome.zarr imported from the filesystem. And it's expected that the ome.zarr is a series with only that one image (/0) or a plate which path structure <row>/<column>/<field index>

@joshmoore
Copy link
Member

💯 As a part of this I can imagine wanting to get and to reset as well.

@will-moore
Copy link
Member

$ omero login
Error loading: /Users/wmoore/Desktop/ZARR/omero-cli-zarr/src/omero/plugins/zarr.py
Traceback (most recent call last):
  File "/Users/wmoore/Desktop/PY/omero-py/target/omero/cli.py", line 1677, in loadpath
    exec(f.read(), loc)
  File "<string>", line 1, in <module>
  File "/Users/wmoore/Desktop/ZARR/omero-cli-zarr/src/omero_zarr/cli.py", line 32, in <module>
    from .extinfo import external_info_str, get_extinfo, get_images, set_external_info
  File "/Users/wmoore/Desktop/ZARR/omero-cli-zarr/src/omero_zarr/extinfo.py", line 92, in <module>
    ) -> tuple[ImageWrapper, str | None, int | None]:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

@dominikl
Copy link
Member Author

dominikl commented Mar 3, 2025

Interesting... is this a python version thing? I use 3.12.9.

@will-moore
Copy link
Member

It could be, I'm on an old env python 3.9.15.

@dominikl
Copy link
Member Author

dominikl commented Mar 3, 2025

Yes, looks like it's supported from 3.10 on. As we still recommend 3.9 I'll remove that stuff again.

select e from ExternalInfo as e
where e.id = :id
"""
extinfo = conn.getQueryService().findByQuery(query, params)
Copy link
Member

Choose a reason for hiding this comment

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

In think this needs to be a cross-group query findByQuery(query, params, conn.SERVICE_OPTS) otherwise you won't see it if the extinfo isn't in your default group.

join fetch usedFile.originalFile as f
join fetch f.hasher where image.id = :id
"""
fs = conn.getQueryService().findByQuery(query, params)
Copy link
Member

Choose a reason for hiding this comment

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

cross-group query here too

@@ -108,6 +109,12 @@

POLYGONS_HELP = """Export ROI Polygons on the Image or Plate in zarr format"""

EXTINFO_HELP = """Get the ExternalInfo path of an ome.zarr image.
Copy link
Member

Choose a reason for hiding this comment

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

Get or set...

Copy link
Member Author

Choose a reason for hiding this comment

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

Get, because that's the default action.

@will-moore
Copy link
Member

I was trying to test this on a non-zarr image, by specifying the --path but...

$ omero zarr extinfo Image:2856 --set --path test_extinfo_path
Previous session expired for will on localhost:4064
Server: [localhost:4064]
Username: [will]
Password:
Created session for will@localhost:4064. Idle timeout: 10 min. Current group: Swedlow Lab
Failed to set external info for image (2856) 438CTR_01_4_R3D_D3D.dv_1: Doesn't seem to be an ome.zarr: Users/wmoore/Desktop/images/DVs/438CTR_01_4_R3D_D3D.dv

It seems that there's something strange about --path, like it's being swallowed / overwritten somehow so that args.path was always None. Renaming this argument to anything else seemed to fix it. I suggest using lsid since that corresponds to the field in the extInfo.

@dominikl
Copy link
Member Author

dominikl commented Mar 7, 2025

There's a check if it is a ome.zarr: https://github.com/ome/omero-cli-zarr/pull/167/files#diff-2d64f99479103ff3050c633344ddf895f61491094e9dab65218a3ec17cbfcb59R177 As that's actually only intended to be used with zarr. Otherwise it wouldn't make sense to have it as omero-cli-zarr plugin!?

@will-moore
Copy link
Member

The point is that you have a --path argument for...

help="Use a specific path (default: Determine from clientPath) (only used in combination with --set)",

but it doesn't work for me. Does it work for you?

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.

3 participants