From 5c4ab3b009bf4fba71d8a72bceb3b242699b11ed Mon Sep 17 00:00:00 2001 From: David Manthey Date: Wed, 24 Jan 2024 12:03:23 -0500 Subject: [PATCH 1/2] Reorder docker build We need to do "girder build" after copying the girder config. The annotation plugin has to be added after "girder build" because it accesses the database on first import (we should change that). --- devops/girder/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/devops/girder/Dockerfile b/devops/girder/Dockerfile index 9379bfa7..a88b4281 100644 --- a/devops/girder/Dockerfile +++ b/devops/girder/Dockerfile @@ -13,12 +13,12 @@ WORKDIR /src/large_image RUN pip install -e .[all] -r requirements-test.txt --find-links https://girder.github.io/large_image_wheels RUN pip install girder[mount] girder girder-user-quota # RUN pip install .[all] ./girder[tasks] girder[mount] --find-links https://girder.github.io/large_image_wheels + +COPY ./provision.py /src/provision.py +COPY ./girder.cfg /etc/girder.cfg RUN girder build COPY plugins/AnnotationPlugin /src/AnnotationPlugin RUN pip install -e /src/AnnotationPlugin -COPY ./provision.py /src/provision.py -COPY ./girder.cfg /etc/girder.cfg - ENTRYPOINT ["bash"] From 8335e3c98c27a48552420f09d22ac0ae567412d4 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 25 Jan 2024 10:28:02 -0500 Subject: [PATCH 2/2] Defer importing functions that connect to the database This allows girder build to be run after the plugin is installed. --- devops/girder/Dockerfile | 3 +- .../upenncontrast_annotation/__init__.py | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/devops/girder/Dockerfile b/devops/girder/Dockerfile index a88b4281..38cf7c46 100644 --- a/devops/girder/Dockerfile +++ b/devops/girder/Dockerfile @@ -16,9 +16,10 @@ RUN pip install girder[mount] girder girder-user-quota COPY ./provision.py /src/provision.py COPY ./girder.cfg /etc/girder.cfg -RUN girder build COPY plugins/AnnotationPlugin /src/AnnotationPlugin RUN pip install -e /src/AnnotationPlugin +RUN girder build + ENTRYPOINT ["bash"] diff --git a/devops/girder/plugins/AnnotationPlugin/upenncontrast_annotation/__init__.py b/devops/girder/plugins/AnnotationPlugin/upenncontrast_annotation/__init__.py index b23eb218..39297a49 100644 --- a/devops/girder/plugins/AnnotationPlugin/upenncontrast_annotation/__init__.py +++ b/devops/girder/plugins/AnnotationPlugin/upenncontrast_annotation/__init__.py @@ -22,28 +22,32 @@ from .server.models.history import History as HistoryModel from .server.models.documentChange import DocumentChange as DocumentChangeModel -from .server.api.annotation import Annotation -from .server.api.connections import AnnotationConnection -from .server.api.propertyValues import PropertyValues -from .server.api.property import AnnotationProperty -from .server.api.workerInterfaces import WorkerInterfaces -from .server.api.workerPreviews import WorkerPreviews -from .server.api.datasetView import DatasetView -from .server.api.history import History - - class UPennContrastAnnotationAPIPlugin(GirderPlugin): DISPLAY_NAME = 'UPennContrast Annotation Plugin' def load(self, info): + # Laziliy do these imports as they can connect to the database + from .server.api.annotation import Annotation + from .server.api.connections import AnnotationConnection + from .server.api.propertyValues import PropertyValues + from .server.api.property import AnnotationProperty + from .server.api.workerInterfaces import WorkerInterfaces + from .server.api.workerPreviews import WorkerPreviews + from .server.api.datasetView import DatasetView + from .server.api.history import History + ModelImporter.registerModel('upenn_annotation', AnnotationModel, 'upenncontrast_annotation') - ModelImporter.registerModel('annotation_connection', ConnectionModel, 'upenncontrast_annotation') - ModelImporter.registerModel('annotation_property_values', PropertyValuesModel, 'upenncontrast_annotation') - ModelImporter.registerModel('annotation_property', PropertyModel, 'upenncontrast_annotation') + ModelImporter.registerModel( + 'annotation_connection', ConnectionModel, 'upenncontrast_annotation') + ModelImporter.registerModel( + 'annotation_property_values', PropertyValuesModel, 'upenncontrast_annotation') + ModelImporter.registerModel( + 'annotation_property', PropertyModel, 'upenncontrast_annotation') ModelImporter.registerModel('worker_interface', InterfaceModel, 'upenncontrast_annotation') ModelImporter.registerModel('worker_preview', PreviewModel, 'upenncontrast_annotation') ModelImporter.registerModel('dataset_view', DatasetViewModel, 'upenncontrast_annotation') ModelImporter.registerModel('history', HistoryModel, 'upenncontrast_annotation') - ModelImporter.registerModel('document_change', DocumentChangeModel, 'upenncontrast_annotation') + ModelImporter.registerModel( + 'document_change', DocumentChangeModel, 'upenncontrast_annotation') info['apiRoot'].upenn_annotation = Annotation() info['apiRoot'].annotation_connection = AnnotationConnection()