Skip to content

Normalise Experimenters, Groups, Details #22

@will-moore

Description

@will-moore

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions