Skip to content

Commit

Permalink
Come up with a set of working migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
york-stsci committed Feb 23, 2024
1 parent 312c1b3 commit fb00490
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 51 deletions.
1 change: 0 additions & 1 deletion jwql/instrument_monitors/nircam_monitors/claw_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ def make_background_plots(self, plot_type='bkg'):
df = df[df['stddev'] != 0] # older data has no accurate stddev measures
plot_data = df['stddev'].values
if plot_type == 'model':
total_bkg = [1. for x in df['median'].values]
plot_data = df['median'].values / df['total_bkg'].values
plot_expstarts = df['expstart_mjd'].values

Expand Down
84 changes: 42 additions & 42 deletions jwql/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,48 +655,48 @@

# Names of all of the monitor database tables
MONITOR_TABLE_NAMES = [
"FGSBadPixelQueryHistory", "FGSBadPixelStats",
"MIRIBadPixelQueryHistory", "MIRIBadPixelStats",
"NIRCamBadPixelQueryHistory", "NIRCamBadPixelStats",
"NIRISSBadPixelQueryHistory", "NIRISSBadPixelStats",
"NIRSpecBadPixelQueryHistory", "NIRSpecBadPixelStats",
"NIRCamBiasQueryHistory", "NIRCamBiasStats",
"NIRISSBiasQueryHistory", "NIRISSBiasStats",
"NIRSpecBiasQueryHistory", "NIRSpecBiasStats",
"NIRCamClawQueryHistory", "NIRCamClawStats",
"Monitor",
"CentralStorage",
"FilesystemCharacteristics",
"FilesystemGeneral",
"FilesystemInstrument",
"FgsAnomaly",
"MiriAnomaly",
"NircamAnomaly",
"NirissAnomaly",
"NirspecAnomaly",
"FGSCosmicRayQueryHistory", "FGSCosmicRayStats",
"MIRICosmicRayQueryHistory", "MIRICosmicRayStats",
"NIRCamCosmicRayQueryHistory", "NIRCamCosmicRayStats",
"NIRISSCosmicRayQueryHistory", "NIRISSCosmicRayStats",
"NIRSpecCosmicRayQueryHistory", "NIRSpecCosmicRayStats",
"FGSDarkDarkCurrent", "FGSDarkPixelStats", "FGSDarkQueryHistory",
"MIRIDarkDarkCurrent", "MIRIDarkPixelStats", "MIRIDarkQueryHistory",
"NIRCamDarkDarkCurrent", "NIRCamDarkPixelStats", "NIRCamDarkQueryHistory",
"NIRISSDarkDarkCurrent", "NIRISSDarkPixelStats", "NIRISSDarkQueryHistory",
"NIRSpecDarkDarkCurrent", "NIRSpecDarkPixelStats", "NIRSpecDarkQueryHistory",
"FGSEdbBlocksStats", "FGSEdbDailyStats", "FGSEdbEveryChangeStats", "FGSEdbTimeIntervalStats", "FGSEdbTimeStats",
"MIRIEdbBlocksStats", "MIRIEdbDailyStats", "MIRIEdbEveryChangeStats", "MIRIEdbTimeIntervalStats", "MIRIEdbTimeStats",
"NIRCamEdbBlocksStats", "NIRCamEdbDailyStats", "NIRCamEdbEveryChangeStats", "NIRCamEdbTimeIntervalStats", "NIRCamEdbTimeStats",
"NIRISSEdbBlocksStats", "NIRISSEdbDailyStats", "NIRISSEdbEveryChangeStats", "NIRISSEdbTimeIntervalStats", "NIRISSEdbTimeStats",
"NIRSpecEdbBlocksStats", "NIRSpecEdbDailyStats", "NIRSpecEdbEveryChangeStats", "NIRSpecEdbTimeIntervalStats", "NIRSpecEdbTimeStats",
"NIRSpecGratingStats",
"FGSReadnoiseQueryHistory", "FGSReadnoiseStats",
"MIRIReadnoiseQueryHistory", "MIRIReadnoiseStats",
"NIRCamReadnoiseQueryHistory", "NIRCamReadnoiseStats",
"NIRISSReadnoiseQueryHistory", "NIRISSReadnoiseStats",
"NIRSpecReadnoiseQueryHistory", "NIRSpecReadnoiseStats",
"MIRITaQueryHistory", "MIRITaStats",
"NIRSpecTaQueryHistory", "NIRSpecTaStats"
"fgs_bad_pixel_query_history", "fgs_bad_pixel_stats",
"miri_bad_pixel_query_history", "miri_bad_pixel_stats",
"nircam_bad_pixel_query_history", "nircam_bad_pixel_stats",
"niriss_bad_pixel_query_history", "niriss_bad_pixel_stats",
"nirspec_bad_pixel_query_history", "nirspec_bad_pixel_stats",
"nircam_bias_query_history", "nircam_bias_stats",
"niriss_bias_query_history", "niriss_bias_stats",
"nirspec_bias_query_history", "nirspec_bias_stats",
"nircam_claw_query_history", "nircam_claw_stats",
"monitor",
"central_storage",
"filesystem_characteristics",
"filesystem_general",
"filesystem_instrument",
"fgs_anomaly",
"miri_anomaly",
"nircam_anomaly",
"niriss_anomaly",
"nirspec_anomaly",
"fgs_cosmic_ray_query_history", "fgs_cosmic_ray_stats",
"miri_cosmic_ray_query_history", "miri_cosmic_ray_stats",
"nircam_cosmic_ray_query_history", "nircam_cosmic_ray_stats",
"niriss_cosmic_ray_query_history", "niriss_cosmic_ray_stats",
"nirspec_cosmic_ray_query_history", "nirspec_cosmic_ray_stats",
"fgs_dark_dark_current", "fgs_dark_pixel_stats", "fgs_dark_query_history",
"miri_dark_dark_current", "miri_dark_pixel_stats", "miri_dark_query_history",
"nircam_dark_dark_current", "nircam_dark_pixel_stats", "nircam_dark_query_history",
"niriss_dark_dark_current", "niriss_dark_pixel_stats", "niriss_dark_query_history",
"nirspec_dark_dark_current", "nirspec_dark_pixel_stats", "nirspec_dark_query_history",
"fgs_edb_blocks_stats", "fgs_edb_daily_stats", "fgs_edb_every_change_stats", "fgs_edb_time_interval_stats", "fgs_edb_time_stats",
"miri_edb_blocks_stats", "miri_edb_daily_stats", "miri_edb_every_change_stats", "miri_edb_time_interval_stats", "miri_edb_time_stats",
"nircam_edb_blocks_stats", "nircam_edb_daily_stats", "nircam_edb_every_change_stats", "nircam_edb_time_interval_stats", "nircam_edb_time_stats",
"niriss_edb_blocks_stats", "niriss_edb_daily_stats", "niriss_edb_every_change_stats", "niriss_edb_time_interval_stats", "niriss_edb_time_stats",
"nirspec_edb_blocks_stats", "nirspec_edb_daily_stats", "nirspec_edb_every_change_stats", "nirspec_edb_time_interval_stats", "nirspec_edb_time_stats",
"nirspec_grating_stats",
"fgs_readnoise_query_history", "fgs_readnoise_stats",
"miri_readnoise_query_history", "miri_readnoise_stats",
"nircam_readnoise_query_history", "nircam_readnoise_stats",
"niriss_readnoise_query_history", "niriss_readnoise_stats",
"nirspec_readnoise_query_history", "nirspec_readnoise_stats",
"miri_ta_query_history", "miri_ta_stats",
"nirspec_ta_query_history", "nirspec_ta_stats"
]

# Suffix for msa files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.5 on 2024-02-22 21:16
# Generated by Django 4.2.5 on 2024-02-23 16:50

import django.contrib.postgres.fields
from django.db import migrations, models
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Generated by Django 4.2.5 on 2024-02-22 21:17
# Generated by Django 4.2.5 on 2024-02-23 16:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('jwql', '0017_added_monitor_tables'),
('jwql', '0017_nirspecreadnoisestats_nirspecreadnoisequeryhistory_and_more'),
]

operations = [
Expand Down
11 changes: 6 additions & 5 deletions jwql/website/apps/jwql/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def db_for_read(self, model, **hints):
"""
Attempts to read monitor models go to monitors db.
"""
if model.__name__ in MONITOR_TABLE_NAMES:
if model._meta.db_table in MONITOR_TABLE_NAMES:
return "monitors"
return None

def db_for_write(self, model, **hints):
"""
Attempts to write monitor models go to monitors db.
"""
if model.__name__ in MONITOR_TABLE_NAMES:
if model._meta.db_table in MONITOR_TABLE_NAMES:
return "monitors"
return None

Expand All @@ -48,8 +48,8 @@ def allow_relation(self, obj1, obj2, **hints):
Allow relations between tables in the monitors DB.
"""
if (
obj1.__class__.__name__ in MONITOR_TABLE_NAMES
and obj2.__class__.__name__ in MONITOR_TABLE_NAMES
obj1._meta.db_table in MONITOR_TABLE_NAMES
and obj2._meta.db_table in MONITOR_TABLE_NAMES
):
return True
return None
Expand All @@ -58,6 +58,7 @@ def allow_migrate(self, db, app_label, model_name=None, **hints):
"""
Make sure the monitors apps only appear in the 'monitors' database.
"""
if app_label == 'jwql' and model_name in MONITOR_TABLE_NAMES:
model_names = [name.replace("_", "") for name in MONITOR_TABLE_NAMES]
if app_label == 'jwql' and model_name in model_names:
return db == "monitors"
return None

0 comments on commit fb00490

Please sign in to comment.