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

Normalise Experimenters, Groups, Details #22

Open
will-moore opened this issue Sep 15, 2016 · 0 comments
Open

Normalise Experimenters, Groups, Details #22

will-moore opened this issue Sep 15, 2016 · 0 comments

Comments

@will-moore
Copy link
Member

It would be great if omero-marshal could ease the burden of normalising owners, groups and possibly even details too, to reduce the size of the python dict / json object that is needed.

This would need an encode() to be able to take a list of IObjects and return either a tuple of 3 dicts: (obj, owners, groups) or a single dict that included all three.

My current simplistic approach in ome/openmicroscopy#4708 for normalising encoded dicts doesn't handle nested objects:

def normalize_objects(objects):
    experimenters = {}
    groups = {}
    objs = []
    for o in objects:
        exp = o['omero:details']['owner']
        experimenters[exp['@id']] = exp
        o['omero:details']['owner'] = {'@id': exp['@id']}
        grp = o['omero:details']['group']
        groups[grp['@id']] = grp
        o['omero:details']['group'] = {'@id': grp['@id']}
        objs.append(o)
    experimenters = experimenters.values()
    groups = groups.values()
    return objs, {'experimenters': experimenters, 'experimenterGroups': groups}
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

No branches or pull requests

1 participant