-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CU-8692nnx2z: resubmit all validated docs on startup, default is true.
- Loading branch information
1 parent
009279a
commit d39bd79
Showing
6 changed files
with
59 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
default_app_config = 'api.apps.ApiConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
import logging | ||
import os | ||
|
||
from django.apps import AppConfig | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ApiConfig(AppConfig): | ||
name = 'api' | ||
|
||
class AnnoappConfig(AppConfig): | ||
name = 'annoapp' | ||
def ready(self): | ||
from api.views import _submit_document | ||
from api.models import ProjectAnnotateEntities | ||
resubmit_all = os.environ.get('RESUBMIT_ALL_ON_STARTUP', False) | ||
if resubmit_all: | ||
logger.info('Found env var RESUBMIT_ALL_ON_STARTUP is True. ' | ||
'Attempting to resubmit all currently submitted state documents') | ||
projects = ProjectAnnotateEntities.objects.all() | ||
for project in projects: | ||
validated_docs = project.validated_documents.all() | ||
if len(validated_docs): | ||
for doc in validated_docs: | ||
try: | ||
_submit_document(project, doc) | ||
logger.info("Submitted doc: %s", doc.name) | ||
except Exception as e: | ||
logger.error("Failed to re-submit doc on startup with exception %s", e) | ||
logger.info("Finished resubmitting Project %s", project.name) | ||
logger.info("MedCATTrainer App API ready...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters