Skip to content

Commit

Permalink
Update update_monitor_table to use django models
Browse files Browse the repository at this point in the history
  • Loading branch information
bhilbert4 committed Dec 2, 2024
1 parent a2fec04 commit 64780ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions jwql/utils/monitor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import numpy as np
from django import setup

from jwql.database.database_interface import Monitor, engine
from jwql.utils.constants import ASIC_TEMPLATES, JWST_DATAPRODUCTS, MAST_QUERY_LIMIT
from jwql.utils.constants import ON_GITHUB_ACTIONS, ON_READTHEDOCS
from jwql.utils.logging_functions import configure_logging, get_log_status
from jwql.utils import mast_utils
from jwql.website.apps.jwql.monitor_models.common import Monitor


# Increase the limit on the number of entries that can be returned by
Expand Down Expand Up @@ -285,5 +285,5 @@ def update_monitor_table(module, start_time, log_file):
new_entry['status'] = get_log_status(log_file)
new_entry['log_file'] = os.path.basename(log_file)

with engine.begin() as connection:
connection.execute(Monitor.__table__.insert(), new_entry)
entry = Monitor(**new_entry)
entry.save()
8 changes: 7 additions & 1 deletion jwql/website/apps/jwql/monitor_models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,17 @@ class Meta:
from django.contrib.postgres.fields import ArrayField


class StatusEnum(models.TextChoices):
SUCCESS = "SUCCESS"
FAILURE = "FAILURE"


class Monitor(models.Model):
monitor_name = models.CharField()
start_time = models.DateTimeField()
end_time = models.DateTimeField(blank=True, null=True)
status = models.TextField(blank=True, null=True) # This field type is a guess.
status = models.EnumField(StatusEnum)
#status = models.TextField(blank=True, null=True) # This field type is a guess.
log_file = models.CharField()

class Meta:
Expand Down

0 comments on commit 64780ca

Please sign in to comment.