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

get objects by map annotations list #392

Closed

Conversation

Josuerc026
Copy link

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')

@Josuerc026 Josuerc026 marked this pull request as ready for review January 27, 2024 21:12
vals = set()
for kv in key_vals:
keys.add(kv['key'])
vals.add(kv['value'])
Copy link
Member

Choose a reason for hiding this comment

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

Since you are adding both the keys and vals to different sets here, you lose the key-value pairing?

@will-moore
Copy link
Member

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
Copy link
Author

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 😄

@will-moore will-moore closed this Jan 31, 2024
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.

2 participants