Skip to content

Commit

Permalink
Updating types for filesystem monitor migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
mfixstsci committed Jan 16, 2025
1 parent 2ada48a commit 561ea01
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1 on 2024-11-13 14:56
# Generated by Django 5.1.4 on 2025-01-16 21:35

import django.contrib.postgres.fields
from django.db import migrations, models
Expand All @@ -16,9 +16,24 @@ class Migration(migrations.Migration):
name='filter_pupil',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(default='empty', help_text='filter and/or pupil name', max_length=7), blank=True, null=True, size=None),
),
migrations.AlterField(
model_name='filesystemcharacteristics',
name='instrument',
field=models.CharField(),
),
migrations.AlterField(
model_name='filesystemcharacteristics',
name='obs_per_filter_pupil',
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), blank=True, null=True, size=None),
),
migrations.AlterField(
model_name='filesysteminstrument',
name='filetype',
field=models.CharField(),
),
migrations.AlterField(
model_name='filesysteminstrument',
name='instrument',
field=models.CharField(default='empty', help_text='JWST instrument name', max_length=7),
),
]
28 changes: 13 additions & 15 deletions jwql/website/apps/jwql/monitor_models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,19 @@ class Meta:
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
from django.contrib.postgres.fields import ArrayField
from django_enum import EnumField
from enum import StrEnum

from jwql.utils.constants import DEFAULT_MODEL_CHARFIELD, MAX_LEN_FILTER, FILE_SUFFIX_TYPES
from jwql.utils.constants import (
DEFAULT_MODEL_CHARFIELD,
MAX_LEN_FILTER,
MAX_LEN_INSTRUMENT,
)

FILE_SUFFIX_CLASS = StrEnum('FILE_SUFFIX_CLASS', FILE_SUFFIX_TYPES)

class InstrumentEnum(StrEnum):
FGS_TYPE = "fgs"
MIRI_TYPE = "miri"
NIRCAM_TYPE = "nircam"
NIRISS_TYPE = "niriss"
NIRSPEC_TYPE = "nirspec"

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.TextField(blank=True, null=True)
log_file = models.CharField()

class Meta:
Expand All @@ -217,7 +211,7 @@ class Meta:

class FilesystemCharacteristics(models.Model):
date = models.DateTimeField()
instrument = EnumField(InstrumentEnum) # This field type is a guess.
instrument = models.CharField()
filter_pupil = ArrayField(
models.CharField(
max_length=MAX_LEN_FILTER,
Expand Down Expand Up @@ -254,8 +248,12 @@ class Meta:

class FilesystemInstrument(models.Model):
date = models.DateTimeField()
instrument = EnumField(InstrumentEnum) # This field type is a guess.
filetype = EnumField(FILE_SUFFIX_CLASS) # This field type is a guess.
instrument = models.CharField(
max_length=MAX_LEN_INSTRUMENT,
help_text="JWST instrument name",
default=DEFAULT_MODEL_CHARFIELD,
)
filetype = models.CharField()
count = models.IntegerField()
size = models.FloatField()

Expand Down

0 comments on commit 561ea01

Please sign in to comment.