ome / omero-scripts

Core OMERO Scripts
https://pypi.org/project/omero-scripts/
12 stars 32 forks source link

Populate metadata Image dtype #184

Closed will-moore closed 3 years ago

will-moore commented 3 years ago

This allows the Populate_Metadata script UI to pick Image types.

To test:

sbesson commented 3 years ago

I am aware that https://github.com/ome/omero-cli-server/pull/5 contains the ongoing discussion about how to express the dependencies for this Python packages on OMERO.server. However, I wonder whether setup.py should not include and install_requires block that would capture these requirements as well (in the case of this PR, I assume omero-metadata>=0.6.0)

sbesson commented 3 years ago

Tested in conjunction with https://github.com/ome/omero-web/pull/264. The script works as expected, taking the input CSV and generating a table alongside the original CSV

Screenshot 2021-02-25 at 16 08 34

Two additional thoughts:

will-moore commented 3 years ago

We only add Image to the types if from omero_metadata.populate import ParsingContext passes. However, if I have installed an older version of omero-metadata e.g. v0.5.1 when Image wasn't supported, I get this error if I try to use an Image:

    self.value_resolver = ValueResolver(client, target_object)
  File "/Users/wmoore/Desktop/METADATA/omero-metadata/src/omero_metadata/populate.py", line 338, in __init__
    'Unsupported target object class: %s' % self.target_class)
omero_metadata.populate.MetadataError: Unsupported target object class: <class 'omero.model.ImageI'>

I guess we could detect the support for Image with from omero_metadata.populate import ImageWrapper, but that might not be very reliable. It could be renamed or removed. I don't know if there's a reliable way to get the version number and show "Please upgrade" if it's not recent or latest?

Otherwise, we should at least state on the omero-metadata README (and omero-guides if they mention this workflow) that Image/ROIs support was added in v0.6.0. Although, a user won't necessarily know what version is installed on their server.

will-moore commented 3 years ago

That last commit tests to see if ImageWrapper is supported in the current version of omero-metadata if the user has chosen an "Image" dtype. If not, return a suitable message:

Screenshot 2021-06-16 at 12 32 04