Skip to content

Commit

Permalink
Rework object creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Apr 24, 2024
1 parent 2aa542e commit a3ecdeb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions readux_ingest_ecds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def open_metadata(self):

def create_canvases(self):
Canvas = get_iiif_models()['Canvas']
new_canvases = []
images = None
with open(self.trigger_file, 'r') as t_file:
images = t_file.read().splitlines()
Expand All @@ -193,15 +194,17 @@ def create_canvases(self):
except IndexError:
ocr_file_path = None

Canvas.objects.get_or_create(
new_canvases.append(Canvas(
manifest=self.manifest,
image_server=self.image_server,
pid=canvas_pid,
ocr_file_path=ocr_file_path,
position=position,
width=width,
height=height
)
))

Canvas.objects.bulk_create(new_canvases)

upload_trigger_file(self.trigger_file)

Expand Down
1 change: 0 additions & 1 deletion readux_ingest_ecds/services/ocr_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,4 +491,3 @@ def add_ocr_to_canvases(manifest):
new_ocr_annotations += add_ocr_annotations(canvas, ocr)

OCR.objects.bulk_create(new_ocr_annotations)
list(map(lambda canvas: canvas.save(), manifest.canvas_set.all()))
1 change: 1 addition & 0 deletions readux_ingest_ecds/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def on_failure(self, exc, task_id, args, kwargs, einfo):
ingest = Local.objects.get(id=args[0])
LOGGER.info(f'FAIL!!! {ingest.manifest.pid}')
send_email_on_failure(bundle=ingest.bundle.name, creator=ingest.creator, exception=str(exc))
ingest.manifest.save()
ingest.delete()

app = Celery('readux_ingest_ecds', result_extended=True)
Expand Down

0 comments on commit a3ecdeb

Please sign in to comment.