Skip to content

Commit

Permalink
Updated UI styling and layout
Browse files Browse the repository at this point in the history
- Changed general UI layout to be more streamlined
- Removed 'default' visualisations
- Added new 'menu' to select analysis
  • Loading branch information
headmetal committed Jul 5, 2024
1 parent b2f7b5b commit 17e7d8f
Show file tree
Hide file tree
Showing 6 changed files with 1,603 additions and 33 deletions.
Empty file modified docs/make.bat
100755 → 100644
Empty file.
1,511 changes: 1,511 additions & 0 deletions docs/notebooks/dev_notebook.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/notebooks/getting_started_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.9.2"
}
},
"nbformat": 4,
Expand Down
Empty file modified setup.py
100755 → 100644
Empty file.
38 changes: 17 additions & 21 deletions src/med_diagnostics/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import intake
import panel as pn

from apscheduler.schedulers.background import BackgroundScheduler
#from apscheduler.schedulers.background import BackgroundScheduler
from med_diagnostics import data, ui
from distributed import Client

Expand Down Expand Up @@ -51,24 +51,12 @@ def __init__(self, model_type, model_path, period=None, timezone=None):
# Start dask client
self.client = Client(threads_per_worker=1)

print()
print('----------------------- Live diagnostics session started -----------------------')
print()
print('Model type:', str(model_type))
print('Model data path:', self.model_path)
print('Model data update period:', self.period, 'mins')
print()
print('Started dask client:', self.client.dashboard_link)
print()
print('--------------------------------------------------------------------------------')
print()

# Start UserUI instance and display initial status text
self.ui = ui.UserInterface()
self.ui._display_status_text()
self.ui._display_status_text(str(model_type), self.model_path, self.client.dashboard_link)

# Start data scheduler
self._start_scheduler()
# self._start_scheduler() - not being used for now as rate of typical model output is too slow (~4-5h)

# Get initial model data
self._get_data()
Expand All @@ -92,12 +80,12 @@ def end_session(self):
Stop background scheduler and close dask client to end current CreateModelDiagnosticsSession instance.
"""

self.scheduler.shutdown()
#self.scheduler.shutdown()
self.client.close()

self.ui.widget_container.clear()


print('------------------------ Live diagnostics session ended ------------------------')
print('--- Interactive diagnostics session ended ---')


def _get_data(self):
Expand All @@ -121,6 +109,8 @@ def _get_data(self):
pass

else:

# Add in new step here with menu for interactive plot, 4-up plot etc.

# Data loading procedure for initial step
if self.data_update == False:
Expand All @@ -134,8 +124,14 @@ def _get_data(self):
# Load access_nri catalog for model comparison filtered by model type
self.access_nri_cat = data._load_access_nri_catalog(self.model_type)

# Generate UI
self.ui._display_dataset_selection_ui(self.model_cat, self.access_nri_cat)


# Load UI main menu
self.ui._display_main_menu_selection_ui()

#self.ui._display_dataset_selection_ui(self.model_cat, self.access_nri_cat)



self.data_update == True

Expand Down
85 changes: 74 additions & 11 deletions src/med_diagnostics/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@ def __init__(self):
# Import panel extensions
pn.extension()

# Build and style panel widgets
self.last_data_load_textbox = pn.widgets.StaticText(styles={'background': 'orange', 'font-size': '18px', 'color': 'black', 'padding': '5px'}, margin=(10, 0, 10, 0))
self.status_textbox = pn.widgets.StaticText(styles={'background': 'lightblue', 'font-size': '18px', 'color': 'black', 'padding': '5px'}, margin=(10, 0, 10, 0))
self.ref_status_textbox = pn.widgets.StaticText(styles={'background': 'lightblue', 'font-size': '18px', 'color': 'black', 'padding': '5px'}, margin=(10, 0, 10, 0))
#### Build and style panel widgets

# Textboxes
self.last_data_load_textbox = pn.widgets.StaticText(styles={'background': 'orange', 'font-size': '18px', 'color': 'black', 'padding': '5px'},
margin=(10, 0, 10, 0))
self.status_textbox = pn.widgets.StaticText(styles={'background': 'lightblue', 'font-size': '18px', 'color': 'black', 'padding': '5px'},
margin=(10, 0, 10, 0))
self.ref_status_textbox = pn.widgets.StaticText(styles={'background': 'lightblue', 'font-size': '18px', 'color': 'black', 'padding': '5px'},
margin=(10, 0, 10, 0))

self.ref_model_metadata = pn.widgets.StaticText(styles={'color': 'white'})


# Main UI menu items
self.menu_variables_vis_button = pn.widgets.Button(styles={}, margin=(10, 0, 0, 0))
self.menu_4up_report_button = pn.widgets.Button(styles={}, margin=(10, 0, 0, 0))

# Selection menu itemsf
self.keys_dropdown = pn.widgets.Select()
self.keys_button = pn.widgets.Button(styles={}, margin=(23, 0, 0, 0))
self.plot_variable_dropdown = pn.widgets.Select()
Expand Down Expand Up @@ -82,25 +92,39 @@ def _ref_clear_data_button_click(event):
self.ref_data_keys_button.on_click(_ref_data_keys_button_click)
self.clear_ref_model_data_button.on_click(_ref_clear_data_button_click)
self.ref_model_info_button.on_click(_ref_model_info_button_click)




def _display_status_text(self):

def _display_status_text(self, model_type, model_path, dashboard_link):

"""
Create widget_container then add status_textbox and last_data_load_textbox widgets. Private.
"""

# Create panel column
self.widget_container = pn.Column()
self.widget_container = pn.Column(styles={'font-size': '16pt'})

# Add horizontal line divider to widget_container
self.widget_container.append(pn.layout.Divider(styles={'color': 'white'}))

# Append widget_container with model params textbox widgets
self.widget_container.append(pn.pane.Str("--- Interactive diagnostics session started ---\n" +
" \n" +
"Model type: " + model_type + "\n" +
"Model path: " + model_path + "\n" +
" \n" +
"Dask URL: " + dashboard_link, styles={'font-size': '10pt'}))

# Add horizontal line divider to widget_container
self.widget_container.append(pn.layout.Divider(styles={'color': 'white'}))

# Append widget_container with textbox widgets
self.widget_container.append(self.last_data_load_textbox)
self.widget_container.append(self.status_textbox)

# Display widget_container in notebook
display(self.widget_container)
print()



def _update_status_text(self, text):
Expand Down Expand Up @@ -160,6 +184,45 @@ def _get_current_time(self):
"""

return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")


def _display_main_menu_selection_ui(self):

"""
Label, populate and append main menu-related widgets to widget_container. Private.
"""

# Add horizontal line divider to widget_container
self.widget_container.append(pn.layout.Divider(styles={'color': 'white'}))

# Add title text
self.widget_container.append(pn.pane.Str("Data loaded. Please select from the options below:", styles={'font-size': '10pt'}))

# Label menu buttons
self.menu_variables_vis_button.name = 'Visualise model variables'
self.menu_variables_vis_button.button_type = 'primary'

self.menu_4up_report_button.name = 'Generate model snapshot'
self.menu_4up_report_button.button_type = 'primary'

# Add menu button widgets to main_menu_selection_row
#self.main_menu_selection_row = pn.Row()
self.widget_container.append(pn.Row(self.menu_variables_vis_button, pn.pane.Str(" - Plots.",
styles={'font-size': '10pt'}, margin=(17, 0, 0, 10))))

self.widget_container.append(pn.Row(self.menu_4up_report_button, pn.pane.Str(" - 4-Up.",
styles={'font-size': '10pt'}, margin=(17, 0, 10, 10))))

# self.main_menu_selection_col.append(pn.Row(self.menu_4up_report_button, pn.pane.Str("4-Up.", styles={'font-size': '10pt'})))

#self.main_menu_selection_row.append(self.menu_variables_vis_button)
#self.main_menu_selection_row.append(self.menu_4up_report_button)

#self.widget_container.append(self.main_menu_selection_row)

# Add horizontal line divider to widget_container
self.widget_container.append(pn.layout.Divider(styles={'color': 'white'}))


def _display_dataset_selection_ui(self, model_cat, access_nri_cat):
Expand Down Expand Up @@ -209,7 +272,7 @@ def _display_reference_model_selection_ui(self):
"""

# Add refrence data status text box
# Add reference data status text box
self.widget_container.append(self.ref_status_textbox)

# Populate reference/comparison model widgets
Expand Down

0 comments on commit 17e7d8f

Please sign in to comment.