Beispiel #1
0
def img_collection_record_to_encodable(image_record: Iterable[Image], trace, step):
    img_list = []
    for idx, img in image_record:
        img_dump = img.json()
        image_resource_path = generate_resource_path(trace.values.tree.container, (step, idx, 'data'))
        img_dump['blob_uri'] = URIService.generate_uri(trace.run.repo, trace.run.hash, 'seqs', image_resource_path)
        img_dump['index'] = idx
        img_list.append(img_dump)
    return img_list
Beispiel #2
0
def audio_record_to_encodable(obj, trace, step, index=None):
    if index is None:
        resource_path = generate_resource_path(trace.values.tree.container, (step, 'data'))
    else:
        resource_path = generate_resource_path(trace.values.tree.container, (step, index, 'data'))
    return [{
        'index': index or 0,
        'format': obj.storage.get('format'),
        'caption': obj.storage.get('caption'),
        'blob_uri': URIService.generate_uri(trace.run.repo, trace.run.hash, 'seqs', resource_path)
    }]
Beispiel #3
0
def preparer(obj: Figure, trace, step, decode=False):
    assert isinstance(obj, Figure)

    if decode:
        return json.loads(obj.json())
    resource_path = generate_resource_path(trace.values.tree.container, (step, 'data'))
    return {
        'blob_uri': URIService.generate_uri(
            trace.run.repo, trace.run.hash, 'seqs', resource_path
        )
    }
Beispiel #4
0
def audios_batch_result_streamer(uri_batch: List[str], repo: 'Repo'):
    uri_service = URIService(repo=repo)
    batch_iterator = uri_service.request_batch(uri_batch=uri_batch)
    for it in batch_iterator:
        yield collect_run_streamable_data(encode_tree(it))
Beispiel #5
0
def img_record_to_encodable(image_record: Image, trace, step):
    img_dump = image_record.json()
    image_resource_path = generate_resource_path(trace.values.tree.container, (step, 'data'))
    img_dump['blob_uri'] = URIService.generate_uri(trace.run.repo, trace.run.hash, 'seqs', image_resource_path)
    img_dump['index'] = 0
    return [img_dump]