Skip to content

Commit

Permalink
issue #1124 - check annotation range lock dupes (warning only for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
davmlaw committed Jul 19, 2024
1 parent 9da5e96 commit 4330ab7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions variantgrid/deployment_validation/annotation_status_checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django.db.models import Count

from annotation.models import AnnotationRangeLock


def check_annotation_status() -> dict:
# I am going to make this a warning for a while - before making it an error
ARL_DUPE_ERROR = False
# see https://github.com/SACGF/variantgrid_shariant/issues/177
arl_qs = AnnotationRangeLock.objects.values('version_id', 'min_variant_id', 'max_variant_id')
arl_qs = arl_qs.annotate(id_count=Count('id')).filter(id_count__gt=1)
arl_message = "Remove duplicate AnnotationRangeLock objects"
has_dupes = arl_qs.exists()
if ARL_DUPE_ERROR:
arl_data = {
"valid": has_dupes,
"fix": arl_message,
}
else:
arl_data = {
"valid": True, # Just a warning
"warning": arl_message + " (this is a just a warning but will become an error in the future)"
}
annotation_status = {
"AnnotationRangeLock duplicates": arl_data,
}
return annotation_status
5 changes: 5 additions & 0 deletions variantopedia/management/commands/deployment_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.core.management.base import BaseCommand

from annotation.annotation_files_check import annotation_data_exists
from variantgrid.deployment_validation.annotation_status_checks import check_annotation_status
from variantgrid.deployment_validation.celery_checks import check_celery_tasks
from variantgrid.deployment_validation.library_version_checks import check_library_versions
from variantgrid.deployment_validation.tool_version_checks import check_tool_versions
Expand All @@ -19,6 +20,7 @@ def handle(self, *args, **options):

checks = {
"Annotation data exists": annotation_data_exists(flat=True),
"Annotation status": check_annotation_status(),
"Library versions": check_library_versions(),
"Tool versions": check_tool_versions(),
"Celery Tasks": check_celery_tasks(),
Expand All @@ -36,3 +38,6 @@ def handle(self, *args, **options):
raise ValueError(msg)
else:
logging.info(msg)

if warning := data.get("warning"):
logging.warning(warning)

0 comments on commit 4330ab7

Please sign in to comment.