Skip to content

Commit

Permalink
Merge pull request #21 from EmnaTay/newint
Browse files Browse the repository at this point in the history
updates to support dashboard
  • Loading branch information
hzaatiti-NYU authored Jul 11, 2024
2 parents 353d415 + 963bcb5 commit 0c0dd7e
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 41 deletions.
33 changes: 33 additions & 0 deletions dashboards/generate_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import plotly.graph_objects as go
import plotly.io as pio

# Data for the table example
status = ["Active", "Inactive", "Active", "Inactive"]
system_name = ["System A", "System B", "System C", "System D"]

# Create the table
fig = go.Figure(
data=[
go.Table(
header=dict(
values=["Status", "System Name"],
fill_color="paleturquoise",
align="left",
),
cells=dict(
values=[status, system_name], fill_color="lavender", align="left"
),
)
]
)

# Update layout
fig.update_layout(title="System Status Dashboard", width=500, height=300)


# Save the figure as an HTML file
pio.write_html(
fig,
file="C:/Users/Admin/meg-pipeline-main/docs/source/_static/plotly_dashboard02.html",
auto_open=False,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. _helium_recovery_dashboard:

Helium Recovery Dashboard
==========================


.. raw:: html

<iframe src="../_static/plotly_dashboard02.html" width="100%" height="600px"></iframe>
8 changes: 8 additions & 0 deletions docs/source/9-dashboard/KIT-MEG_system_status_dashboard.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. _kit_meg_system_dashboard:

KIT MEG system Dashboard Test
=============================

.. raw:: html

<iframe src="../_static/plotly_dashboard.html" width="100%" height="600px"></iframe>
9 changes: 9 additions & 0 deletions docs/source/9-dashboard/KIT_data_quality_dashboard.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. _kit_data_quality_dashboard:

KIT Data Quality Dashboard
==========================


.. raw:: html

<iframe src="../_static/plotly_dashboard.html" width="100%" height="600px"></iframe>
8 changes: 8 additions & 0 deletions docs/source/9-dashboard/OPM-MEG_system_status_dashboard.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. _opm_meg_system_status_dashboard:

OPM MEG system status dashboard
===============================

.. raw:: html

<iframe src="../_static/plotly_dashboard.html" width="100%" height="600px"></iframe>
8 changes: 8 additions & 0 deletions docs/source/9-dashboard/OPM_data_quality_dashboard.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. _opm_data_quality_dashboard:

OPM Data Quality dashboard
==========================

.. raw:: html

<iframe src="../_static/plotly_dashboard.html" width="100%" height="600px"></iframe>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. _vpixx_devices_system_status_dashboard:

VPIXX devices system status dashboard
=====================================

.. raw:: html

<iframe src="../_static/plotly_dashboard.html" width="100%" height="600px"></iframe>
8 changes: 8 additions & 0 deletions docs/source/9-dashboard/systems-dashboard.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. _systems_dashboard:

Plotly Dashboard Test
=====================

.. raw:: html

<iframe src="../_static/plotly_dashboard.html" width="100%" height="600px"></iframe>
14 changes: 14 additions & 0 deletions docs/source/_static/plotly_dashboard.html

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions docs/source/_static/plotly_dashboard02.html

Large diffs are not rendered by default.

91 changes: 52 additions & 39 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,80 +7,93 @@
from sphinx.application import Sphinx


project = 'MEG Pipeline'
copyright = '2024, Hadi Zaatiti'
author = 'Hadi Zaatiti [email protected]'
# Dashboard Generation
import os
import subprocess
import logging
from sphinx.application import Sphinx

release = '0.1'
version = '0.1.0'

project = "MEG Pipeline"
copyright = "2024, Hadi Zaatiti"
author = "Hadi Zaatiti [email protected]"

release = "0.1"
version = "0.1.0"

# -- General configuration

extensions = [
'sphinx.ext.duration',
'sphinx.ext.doctest',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.intersphinx',
'nbsphinx',
'sphinx_gallery.load_style',
"sphinx.ext.duration",
"sphinx.ext.doctest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"nbsphinx",
"sphinx_gallery.load_style",
]

intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
"python": ("https://docs.python.org/3/", None),
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
}
intersphinx_disabled_domains = ['std']
intersphinx_disabled_domains = ["std"]

templates_path = ['_templates']
templates_path = ["_templates"]

# -- Options for HTML output

html_theme = 'sphinx_rtd_theme'
html_logo = 'graphic/NYU_Logo.png'
html_theme = "sphinx_rtd_theme"
html_logo = "graphic/NYU_Logo.png"
html_theme_options = {

'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': False,
'vcs_pageview_mode': '',
'style_nav_header_background': '#561A70',
"logo_only": False,
"display_version": True,
"prev_next_buttons_location": "bottom",
"style_external_links": False,
"vcs_pageview_mode": "",
"style_nav_header_background": "#561A70",
# Toc options
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': 4,
'includehidden': True,
'titles_only': False
"collapse_navigation": True,
"sticky_navigation": True,
"navigation_depth": 4,
"includehidden": True,
"titles_only": False,
}

suppress_warnings = ['epub.unknown_project_files'] #This allows us to avoid the warning caused by html files in _static directory (regarding mime types)
suppress_warnings = [
"epub.unknown_project_files"
] # This allows us to avoid the warning caused by html files in _static directory (regarding mime types)

html_css_files = [
'custom.css',
"custom.css",
]

html_static_path = ['_static']
html_static_path = ["_static"]
# -- Options for EPUB output
epub_show_urls = 'footnote'
epub_show_urls = "footnote"


def run_dashboard_generation(app: Sphinx):
"""Run the dashboard generation script."""
logger = logging.getLogger(__name__)
script_path = os.path.join(app.confdir, 'dashboards', 'generate_snr_dashboard.py')
script_path = os.path.join(app.confdir, "dashboards", "generate_snr_dashboard.py")
if os.path.exists(script_path):
logger.info(f"Found generate_snr_dashboard.py at {script_path}, running it now.")
result = subprocess.run(['python', script_path], capture_output=True, text=True)
logger.info(
f"Found generate_snr_dashboard.py at {script_path}, running it now."
)
result = subprocess.run(["python", script_path], capture_output=True, text=True)
if result.returncode == 0:
logger.info("generate_snr_dashboard.py ran successfully.")
else:
logger.error(f"generate_snr_dashboard.py failed with return code {result.returncode}")
logger.error(
f"generate_snr_dashboard.py failed with return code {result.returncode}"
)
logger.error(result.stdout)
logger.error(result.stderr)
else:
logger.error(f"The script {script_path} does not exist.")


def setup(app: Sphinx):
logging.basicConfig(level=logging.INFO)
app.connect('builder-inited', run_dashboard_generation)
app.connect("builder-inited", run_dashboard_generation)
52 changes: 52 additions & 0 deletions docs/source/dashboards/generate_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This file will be updated to contain the script to generate the dashboard
# the script to automate its update is conf.py

import plotly.graph_objs as go
import plotly.io as pio

# Sample data
x = [1, 2, 3, 4, 5, 6, 7, 8]
y = [10, 14, 12, 20, 18, 20, 22, 23]

# Create a scatter plot
fig = go.Figure(data=go.Scatter(x=x, y=y, mode="lines+markers"))

# Save the figure as an HTML file
pio.write_html(fig, file="_static/plotly_dashboard.html", auto_open=False)


################################################################################################
import os

# Data for the table
status = ["Active", "Inactive", "Active", "Inactive"]
system_name = ["System A", "System B", "System C", "System D"]

# Create the table
fig = go.Figure(
data=[
go.Table(
header=dict(
values=["Status", "System Name"],
fill_color="paleturquoise",
align="left",
),
cells=dict(
values=[status, system_name], fill_color="lavender", align="left"
),
)
]
)

# Update layout
fig.update_layout(title="System Status Dashboard", width=500, height=300)

# Ensure the directory exists
output_dir = os.path.abspath(os.path.join("..", "docs", "source", "_static"))
os.makedirs(output_dir, exist_ok=True)

# Define the output file path
output_file = os.path.join(output_dir, "plotly_dashboard02.html")

# Save the figure as an HTML file
pio.write_html(fig, output_file)
10 changes: 8 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ Check out the :doc:`1-systems/megsystem` section for further information.
1-systems/opmsystem
1-systems/eegsystem
1-systems/quizz

1-systems/systems-dashboard

.. toctree::
:maxdepth: 2
:caption: Performance Dashboard

1-systems/systems-dashboard
9-dashboard/systems-dashboard
9-dashboard/Helium_recovery_system_status_dashboard
9-dashboard/KIT_data_quality_dashboard
9-dashboard/KIT-MEG_system_status_dashboard
9-dashboard/OPM_data_quality_dashboard
9-dashboard/OPM-MEG_system_status_dashboard
9-dashboard/Vpixx_devices_system_status_dashboard


.. toctree::
Expand Down

0 comments on commit 0c0dd7e

Please sign in to comment.