ome / omero-py

Python project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
20 stars 31 forks source link

get objects by map annotations list #392

Closed Josuerc026 closed 5 months ago

Josuerc026 commented 5 months ago

This pull request adds an additional gateway method, getObjectsByMapAnnotationsList to filter objects by a user provided list of map annotations, derived from the already provided getObjectsByMapAnnotations

# List of key/value pairs to filter by
kv_pairs = [
    {
        'key': 'key1',
        'value': 'val1'
    },
    {
        'key': 'key2',
        'value': 'val2'
    },
    {
        'key': 'key3',
        'value': 'key3'
    }
]

# filter by object type and key/val filter
conn.getObjectsByMapAnnotationsList('Image', key_vals=kv_pairs)

#filter by object type, key/val filter, and namespace
conn.getObjectsByMapAnnotationsList('Image', key_vals=kv_pairs, ns='openmicroscopy.org/omero/client/mapAnnotation')
will-moore commented 5 months ago

Hi @Josuerc026 and thanks for your proposed contribution.

I don't have a clear idea of the use-case is for this, but I'm not sure that this functionality will be needed by enough users to justify it's inclusion in the BlitzGateway?

If you want to extend the BlitzGateway in your code to add this method to the class, you could adopt the approach we use in the webclient. See https://github.com/ome/omero-web/blob/9841167a70df2f0174aed2820bcd302873b53df3/omeroweb/webclient/webclient_gateway.py#L99

There we update the omero.gateway.BlitzGateway https://github.com/ome/omero-web/blob/9841167a70df2f0174aed2820bcd302873b53df3/omeroweb/webclient/webclient_gateway.py#L2101 so after importing the webclient_gateway, we can then import the BlitzGateway as usual and you will get the derived class with additional methods on it.

Josuerc026 commented 5 months ago

Hi @Josuerc026 and thanks for your proposed contribution.

I don't have a clear idea of the use-case is for this, but I'm not sure that this functionality will be needed by enough users to justify it's inclusion in the BlitzGateway?

If you want to extend the BlitzGateway in your code to add this method to the class, you could adopt the approach we use in the webclient. See https://github.com/ome/omero-web/blob/9841167a70df2f0174aed2820bcd302873b53df3/omeroweb/webclient/webclient_gateway.py#L99

There we update the omero.gateway.BlitzGateway https://github.com/ome/omero-web/blob/9841167a70df2f0174aed2820bcd302873b53df3/omeroweb/webclient/webclient_gateway.py#L2101 so after importing the webclient_gateway, we can then import the BlitzGateway as usual and you will get the derived class with additional methods on it.

Hi @will-moore, no problem at all. I encountered a scenario where the above was helpful for my use case but I appreciate you taking the time to review it.

Feel free to close this out, and I will take a look at those resources you linked to 😄