Skip to content

Commit

Permalink
Index newly ingested volume
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed May 2, 2024
1 parent f001e90 commit 686a429
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
17 changes: 17 additions & 0 deletions readux_ingest_ecds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .services.metadata_services import metadata_from_file, clean_metadata
from .helpers import get_iiif_models
from .storages import TmpStorage
from .mail import send_email_on_success, send_email_on_failure

Manifest = get_iiif_models()['Manifest']
ImageServer = get_iiif_models()['ImageServer']
Expand Down Expand Up @@ -213,6 +214,22 @@ def create_canvases(self):

upload_trigger_file(self.trigger_file)

def success(self):
LOGGER.info(f'SUCCESS!!! {self.manifest.pid}')
send_email_on_success(creator=self.creator, manifest=self.manifest)
self.manifest.save()
if os.environ["DJANGO_ENV"] != 'test':
from apps.iiif.manifests.documents import ManifestDocument
index = ManifestDocument()
index.update(self.manifest, True, 'index')
self.delete()

def failure(self, exc):
LOGGER.info(f'FAIL!!! {self.manifest.pid}')
send_email_on_failure(bundle=self.bundle.name, creator=self.creator, exception=str(exc))
self.delete()


class Bulk(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
collections = models.ManyToManyField(
Expand Down
9 changes: 2 additions & 7 deletions readux_ingest_ecds/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ def on_success(self, retval, task_id, args, kwargs):
None: The return value of this handler is ignored.
"""
ingest = Local.objects.get(id=args[0])
LOGGER.info(f'SUCCESS!!! {ingest.manifest.pid}')
send_email_on_success(creator=ingest.creator, manifest=ingest.manifest)
ingest.manifest.save()
ingest.delete()
ingest.success()

def on_failure(self, exc, task_id, args, kwargs, einfo):
"""Error handler.
Expand All @@ -58,9 +55,7 @@ def on_failure(self, exc, task_id, args, kwargs, einfo):
None: The return value of this handler is ignored.
"""
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.delete()
ingest.failure(exc)

app = Celery('readux_ingest_ecds', result_extended=True)
app.config_from_object('django.conf:settings')
Expand Down

0 comments on commit 686a429

Please sign in to comment.