def main(self, image_url, mex_url=None, bisque_token=None, bq=None): # Allow for testing by passing an alreay initialized session if bq is None: bq = BQSession().init_mex(mex_url, bisque_token) # Fetch the image metadata image = bq.load(image_url) # Fetch embedded tags from image service meta = image.pixels().meta().fetch() meta = ET.XML(meta) tags = [] # Create a new tag 'MetaData' to be placed on the image md = BQTag(name='MetaData') # Filter the embedded metadata and place subtags in MetaData for t in meta.getiterator('tag'): if t.get('name') in wanted_tags: md.addTag(name=t.get('name'), value=t.get('value')) # Add the new tag to the image image.addTag(tag=md) metadata_tag = bq.save(md, image.uri + "/tag") bq.finish_mex(tags=[{ 'name': 'outputs', 'tag': [{ 'name': 'metadata', 'value': metadata_tag.uri, 'type': 'tag' }] }]) sys.exit(0)