-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
10 changed files
with
307 additions
and
27 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
34 changes: 34 additions & 0 deletions
34
backend/seqvars/management/commands/buildseqvarsinhousedb.py
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,34 @@ | ||
"""Manually (re-)build the seqvars inhouse database.""" | ||
|
||
import traceback | ||
|
||
from django.core.management.base import BaseCommand, CommandError | ||
|
||
from seqvars.models.base import SeqvarsInhouseDbBuildBackgroundJob | ||
from seqvars.models.executors import run_seqvarsbuildinhousedbbackgroundjob | ||
|
||
|
||
class Command(BaseCommand): | ||
#: Help message displayed on the command line. | ||
help = "(Re-) build the seqvars inhouse database." | ||
|
||
def handle(self, *_args, **options): | ||
"""Entrypoint from command line""" | ||
|
||
try: | ||
self._handle() | ||
except Exception as e: | ||
self.stderr.write( | ||
self.style.ERROR( | ||
"A problem occured (see below).\n\n--- BEGIN TRACEBACK ---\n" | ||
f"{traceback.format_exc()}--- END TRACEBACK ---\n" | ||
) | ||
) | ||
raise CommandError("Could not re-build the seqvars inhouse db.") from e | ||
|
||
def _handle(self): | ||
# Create a new job to execute. | ||
job = SeqvarsInhouseDbBuildBackgroundJob.objects.create_full() | ||
self.stderr.write(self.style.SUCCESS("Executing seqvars inhouse db build job...")) | ||
run_seqvarsbuildinhousedbbackgroundjob(pk=job.pk) | ||
self.stderr.write(self.style.SUCCESS("... done executing job")) |
43 changes: 43 additions & 0 deletions
43
backend/seqvars/migrations/0015_seqvarsinhousedbbuildbackgroundjob.py
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,43 @@ | ||
# Generated by Django 3.2.25 on 2024-10-30 07:38 | ||
|
||
import uuid | ||
|
||
import bgjobs.models | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("bgjobs", "0006_auto_20200526_1657"), | ||
("seqvars", "0014_seqvarsquerypresetsset_is_factory_default"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="SeqvarsInhouseDbBuildBackgroundJob", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
("sodar_uuid", models.UUIDField(default=uuid.uuid4, unique=True)), | ||
( | ||
"bg_job", | ||
models.ForeignKey( | ||
help_text="Background job for state etc.", | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="seqvarsinhousedbbuildbackgroundjob", | ||
to="bgjobs.backgroundjob", | ||
), | ||
), | ||
], | ||
options={ | ||
"ordering": ["-pk"], | ||
}, | ||
bases=(bgjobs.models.JobModelMessageMixin, models.Model), | ||
), | ||
] |
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
Oops, something went wrong.