Skip to content

Commit

Permalink
Convert separate notebooks into tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Jul 19, 2023
1 parent e514da5 commit 8c80ad2
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 87 deletions.
26 changes: 12 additions & 14 deletions aurora.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,9 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as ipw\n",
"from IPython.display import display"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aurora.interface.menus import MainPanel"
"from IPython.display import display\n",
"\n",
"from aurora.main import MainPanel"
]
},
{
Expand All @@ -78,7 +70,7 @@
"metadata": {},
"outputs": [],
"source": [
"w_main = MainPanel()"
"main = MainPanel()"
]
},
{
Expand All @@ -87,7 +79,7 @@
"metadata": {},
"outputs": [],
"source": [
"display(w_main)"
"display(main)"
]
},
{
Expand All @@ -112,8 +104,14 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"name": "python",
"version": "3.8.13"
},
"orig_nbformat": 4
},
Expand Down
4 changes: 2 additions & 2 deletions aurora/interface/menus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .manage_samples import ManageSamplesMenu
from .submit_experiment import MainPanel
from .submit_experiment import ExperimentBuilder
from .visualize_results import CyclingResultsWidget

__all__ = [
"ManageSamplesMenu",
"MainPanel",
"ExperimentBuilder",
"CyclingResultsWidget",
]
18 changes: 0 additions & 18 deletions aurora/interface/menus/manage_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ipywidgets as ipw
from ipyfilechooser import FileChooser

from aurora import __version__
from aurora.interface.sample.sample_filter import SampleFilterWidget
from aurora.models import AvailableSamplesModel, BatteryExperimentModel

Expand All @@ -15,22 +14,6 @@ def __init__(self):
self.available_samples_model = AvailableSamplesModel()
self.experiment_model = BatteryExperimentModel()

# ------------------------------------------------------------ #
# HEADER BOX
# ------------------------------------------------------------ #
self.w_header_box = ipw.VBox(
[
ipw.HTML(value="<h1>Aurora - Manage Samples</h1>"),
ipw.HTML(value=f"Aurora app version {__version__}"),
],
layout={
'width': '100%',
'border': 'solid black 4px',
'padding': '10px'
},
)
# ------------------------------------------------------------ #

self.w_sample_filter = SampleFilterWidget(self.available_samples_model)

home_directory = os.path.expanduser('~')
Expand Down Expand Up @@ -89,7 +72,6 @@ def __init__(self):

super().__init__()
self.children = [
self.w_header_box,
ipw.VBox([
ipw.HTML(value="<h3>Available Samples</h3>"),
self.w_sample_filter,
Expand Down
6 changes: 1 addition & 5 deletions aurora/interface/menus/submit_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from aurora.engine import submit_experiment
from aurora.interface.cycling import CyclingCustom, CyclingStandard
from aurora.interface.menus.utils import get_header_box
from aurora.interface.sample import (SampleFromId, SampleFromRecipe,
SampleFromSpecs)
from aurora.interface.tomato import TomatoSettings
Expand All @@ -16,7 +15,7 @@
CODE_NAME = "ketchup-0.2rc2"


class MainPanel(ipw.VBox):
class ExperimentBuilder(ipw.VBox):
"""Aurora's main widgets panel."""

_SECTION_TITLE = "Submit Experiment"
Expand Down Expand Up @@ -219,8 +218,6 @@ def _build_accordion(self) -> None:
def _build_widgets(self) -> None:
"""Build panel widgets."""

self.w_header_box = get_header_box(self._SECTION_TITLE)

self._build_sample_selection_section()

self._build_cycling_protocol_section()
Expand All @@ -236,7 +233,6 @@ def _build_widgets(self) -> None:
super().__init__()

self.children = [
self.w_header_box,
self.w_main_accordion,
self.w_reset_button,
self.w_submission_output,
Expand Down
33 changes: 0 additions & 33 deletions aurora/interface/menus/utils.py

This file was deleted.

15 changes: 0 additions & 15 deletions aurora/interface/menus/visualize_results.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ipywidgets as ipw

from aurora import __version__
from aurora.interface.analyze import (OutputExplorerComponent,
ResultsPlotterComponent)

Expand All @@ -11,26 +10,12 @@ class CyclingResultsWidget(ipw.VBox):
def __init__(self):
"""Description pending"""

# HEADER BOX
self.w_header_box = ipw.VBox(
[
ipw.HTML(value="<h1>Aurora - Visualize Results</h1>"),
ipw.HTML(value=f"Aurora app version {__version__}"),
],
layout={
'width': '100%',
'border': 'solid black 4px',
'padding': '10px'
},
)

# SUB-COMPONENTS
self.w_output_explorer = OutputExplorerComponent()
self.w_results_plotter = ResultsPlotterComponent()

super().__init__()
self.children = [
self.w_header_box,
self.w_output_explorer,
self.w_results_plotter,
]
77 changes: 77 additions & 0 deletions aurora/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import ipywidgets as ipw

from aurora import __version__
from aurora.interface.menus import (CyclingResultsWidget, ExperimentBuilder,
ManageSamplesMenu)


class MainPanel(ipw.VBox):
"""
Aurora's main panel containing the tab sections for submitting
experiments, managing the samples/protocols inventory, and
visualizing experiment results.
"""

TITLE = f"""
<div style="text-align: center;">
<h1>AURORA</h1>
<p>Version {__version__}</p>
</div>
"""

TAB_LABELS = (
"Experiment",
"Inventory",
"Results",
)

def __init__(self) -> None:
"""`MainPanel` constructor."""

header = ipw.VBox(
layout={
'width': '100%',
'border': 'solid black 4px',
'padding': '10px'
},
children=[
ipw.HTML(self.TITLE),
],
)

tabs = self._build_tabs()

super().__init__(
layout={},
children=[
header,
tabs,
],
)

def _build_tabs(self) -> ipw.Tab:
"""Build the main tab sections.
Returns
-------
`ipw.Tab`
The tab sections of the main panel.
"""

experiment = ExperimentBuilder()
manager = ManageSamplesMenu()
visualizer = CyclingResultsWidget()

tabs = ipw.Tab(
children=[
experiment,
manager,
visualizer,
],
selected_index=0,
)

for i, title in enumerate(self.TAB_LABELS):
tabs.set_title(i, title)

return tabs

0 comments on commit 8c80ad2

Please sign in to comment.