-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'u/emanehab99/restructure-codebase' into tickets/PREOPS-…
…5505
- Loading branch information
Showing
9 changed files
with
681 additions
and
552 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
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,39 @@ | ||
import importlib.resources | ||
|
||
import bokeh | ||
from astropy.time import Time | ||
|
||
# Change styles using CSS variables. | ||
h1_stylesheet = """ | ||
:host { | ||
--mono-font: Helvetica; | ||
color: white; | ||
font-size: 16pt; | ||
font-weight: 500; | ||
} | ||
""" | ||
h2_stylesheet = """ | ||
:host { | ||
--mono-font: Helvetica; | ||
color: white; | ||
font-size: 14pt; | ||
font-weight: 300; | ||
} | ||
""" | ||
h3_stylesheet = """ | ||
:host { | ||
--mono-font: Helvetica; | ||
color: white; | ||
font-size: 13pt; | ||
font-weight: 300; | ||
} | ||
""" | ||
|
||
DEFAULT_CURRENT_TIME = Time.now() | ||
DEFAULT_TIMEZONE = "UTC" # "America/Santiago" | ||
LOGO = "/schedview-snapshot/assets/lsst_white_logo.png" | ||
COLOR_PALETTES = [color for color in bokeh.palettes.__palettes__ if "256" in color] | ||
DEFAULT_COLOR_PALETTE = "Viridis256" | ||
DEFAULT_NSIDE = 16 | ||
PACKAGE_DATA_DIR = importlib.resources.files("schedview.data").as_posix() | ||
LFA_DATA_DIR = "s3://rubin:" |
86 changes: 86 additions & 0 deletions
86
schedview/app/scheduler_dashboard/lfa_scheduler_snapshot_dashboard.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,86 @@ | ||
from datetime import datetime | ||
from zoneinfo import ZoneInfo | ||
|
||
import panel as pn | ||
import param | ||
from astropy.time import Time | ||
from pandas import Timestamp | ||
|
||
from schedview.app.scheduler_dashboard.constants import DEFAULT_TIMEZONE | ||
from schedview.app.scheduler_dashboard.unrestricted_scheduler_snapshot_dashboard import ( | ||
SchedulerSnapshotDashboard, | ||
) | ||
from schedview.app.scheduler_dashboard.utils import query_night_schedulers | ||
|
||
|
||
class LFASchedulerSnapshotDashboard(SchedulerSnapshotDashboard): | ||
"""A Parametrized container for parameters, data, and panel objects for the | ||
scheduler dashboard working in LFA mode where data files are loaded from | ||
a certain S3 bucket. | ||
""" | ||
|
||
scheduler_fname_doc = """Recent pickles from LFA | ||
""" | ||
|
||
# Precedence is used to make sure fields are displayed | ||
# in the right order regardless of the dashboard mode. | ||
scheduler_fname = param.Selector( | ||
default="", | ||
objects=[], | ||
doc=scheduler_fname_doc, | ||
precedence=3, | ||
) | ||
|
||
pickles_date = param.Date( | ||
default=datetime.now(), | ||
label="Snapshot selection cutoff date and time", | ||
doc="Show snapshots that are recent as of this date and time in the scheduler snapshot file dropdown", | ||
precedence=1, | ||
) | ||
|
||
telescope = param.Selector( | ||
default=None, objects={"All": None, "Simonyi": 1, "Auxtel": 2}, doc="Source Telescope", precedence=2 | ||
) | ||
|
||
# Summary widget and Reward widget heights are different in this mode | ||
# because there are more data loading parameters. | ||
_summary_widget_height = 310 | ||
_reward_widget_height = 350 | ||
|
||
data_loading_parameters = [ | ||
"scheduler_fname", | ||
"pickles_date", | ||
"telescope", | ||
"widget_datetime", | ||
"widget_tier", | ||
] | ||
# Set specific widget props for data loading parameters | ||
# in LFA mode. | ||
data_loading_widgets = { | ||
"pickles_date": pn.widgets.DatetimePicker, | ||
"widget_datetime": pn.widgets.DatetimePicker, | ||
} | ||
# Set the data loading parameter section height in LFA mode. | ||
data_params_grid_height = 42 | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
async def query_schedulers(self, selected_time, selected_tel): | ||
"""Query snapshots that have a timestamp between the start of the | ||
night and selected datetime and generated by selected telescope | ||
""" | ||
selected_time = Time( | ||
Timestamp( | ||
selected_time, | ||
tzinfo=ZoneInfo(DEFAULT_TIMEZONE), | ||
) | ||
) | ||
self.show_loading_indicator = True | ||
self._debugging_message = "Starting retrieving snapshots" | ||
self.logger.debug("Starting retrieving snapshots") | ||
scheduler_urls = await query_night_schedulers(selected_time, selected_tel) | ||
self.logger.debug("Finished retrieving snapshots") | ||
self._debugging_message = "Finished retrieving snapshots" | ||
self.show_loading_indicator = False | ||
return scheduler_urls |
39 changes: 39 additions & 0 deletions
39
schedview/app/scheduler_dashboard/restricted_scheduler_snapshot_dashboard.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,39 @@ | ||
import panel as pn | ||
|
||
import schedview | ||
import schedview.param | ||
from schedview.app.scheduler_dashboard.constants import PACKAGE_DATA_DIR | ||
from schedview.app.scheduler_dashboard.unrestricted_scheduler_snapshot_dashboard import ( | ||
SchedulerSnapshotDashboard, | ||
) | ||
|
||
|
||
class RestrictedSchedulerSnapshotDashboard(SchedulerSnapshotDashboard): | ||
"""A Parametrized container for parameters, data, and panel objects for the | ||
scheduler dashboard working in restricted more where data files can only | ||
be loaded from a certain data directory that is set through constructor. | ||
""" | ||
|
||
scheduler_fname_doc = """URL or file name of the scheduler pickle file. | ||
Such a pickle file can either be of an instance of a subclass of | ||
rubin_scheduler.scheduler.schedulers.CoreScheduler, or a tuple of the form | ||
(scheduler, conditions), where scheduler is an instance of a subclass of | ||
rubin_scheduler.scheduler.schedulers.CoreScheduler, and conditions is an | ||
instance of rubin_scheduler.scheduler.conditions.Conditions. | ||
""" | ||
scheduler_fname = schedview.param.FileSelectorWithEmptyOption( | ||
path=f"{PACKAGE_DATA_DIR}/*scheduler*.p*", | ||
doc=scheduler_fname_doc, | ||
default=None, | ||
allow_None=True, | ||
) | ||
|
||
data_loading_widgets = { | ||
"widget_datetime": pn.widgets.DatetimePicker, | ||
} | ||
|
||
def __init__(self, data_dir=None): | ||
super().__init__() | ||
|
||
if data_dir is not None: | ||
self.param["scheduler_fname"].update(path=f"{data_dir}/*scheduler*.p*") |
Oops, something went wrong.