Skip to content
Snippets Groups Projects

Use transcriptions IDs returned by CreateElementTranscriptions endpoint

Merged Eva Bardou requested to merge store-transcriptions-id into master
2 files
+ 39
23
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 8
6
@@ -687,7 +687,7 @@ class ElementsWorker(BaseWorker):
f"A sub_element of {element.id} with type {sub_element_type} was created during transcriptions bulk creation"
)
self.report.add_element(element.id, sub_element_type)
self.report.add_transcription(annotation["id"])
self.report.add_transcription(annotation["element_id"])
if self.cache:
# Store transcriptions and their associated element (if created) in local cache
@@ -698,8 +698,11 @@ class ElementsWorker(BaseWorker):
worker_version_id_hex = convert_str_uuid_to_hex(self.worker_version_id)
for index, annotation in enumerate(annotations):
transcription = transcriptions[index]
element_id_hex = convert_str_uuid_to_hex(annotation["id"])
if annotation["created"] and annotation["id"] not in created_ids:
element_id_hex = convert_str_uuid_to_hex(annotation["element_id"])
if (
annotation["created"]
and annotation["element_id"] not in created_ids
):
elements_to_insert.append(
CachedElement(
id=element_id_hex,
@@ -709,12 +712,11 @@ class ElementsWorker(BaseWorker):
worker_version_id=worker_version_id_hex,
)
)
created_ids.append(annotation["id"])
created_ids.append(annotation["element_id"])
transcriptions_to_insert.append(
CachedTranscription(
# TODO: Retrieve real transcription_id through API
id=convert_str_uuid_to_hex(str(uuid.uuid4())),
id=convert_str_uuid_to_hex(annotation["id"]),
element_id=element_id_hex,
text=transcription["text"],
confidence=transcription["score"],
Loading