Skip to content

Commit

Permalink
Merge branch '23-show-all-status-instead-of-only-the-overall-status' …
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
dbirman committed Nov 12, 2024
2 parents cea4d70 + 42cc915 commit a40ac0d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
31 changes: 27 additions & 4 deletions src/aind_qc_portal/panel/quality_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import boto3

import panel as pn
import pandas as pd
import param
from aind_data_schema.core.quality_control import QualityControl

Expand Down Expand Up @@ -139,6 +140,30 @@ def update_objects(self):

self.tabs.objects = objects

def status_panel(self):
"""Build a Panel table that shows the current status of all evaluations"""
# We'll loop over stage and modality to build a table

data = []
for modality in self.modalities:
for stage in self.stages:
data.append({
"Modality": modality,
"Stage": stage,
"Status": status_html(self._data.status(modality=modality, stage=stage))
})

df = pd.DataFrame(data, columns=["Modality", "Stage", "Status"])

# Reshape the DataFrame using pivot_table
df_squashed = df.pivot_table(index="Stage", columns="Modality", values="Status", aggfunc="first")

# Optional: Clean up column names by flattening the MultiIndex if needed
df_squashed.columns.name = None
df_squashed.reset_index(inplace=True)

return pn.pane.DataFrame(df_squashed, index=False, escape=False)

def panel(self):
"""Build a Panel object representing this QC action"""
if not self._has_data or not self._data:
Expand All @@ -159,16 +184,14 @@ def panel(self):
<span style="font-size:10pt">Status: **{status_html((self._data.status()))}**</span>
<span style="font-size:10pt">Contains {len(self.evaluations)} evaluations. {failing_eval_str}</span>
"""

state_pane = pn.pane.Markdown(state_md)

notes_box = pn.widgets.TextAreaInput(name='Notes:', value=self._data.notes, placeholder="no notes provided")
notes_box.param.watch(self.set_dirty, "value")

# state row
state_row = pn.Row(state_pane, notes_box)
quality_control_pane = pn.Column(header, state_row)

state_row = pn.Row(state_pane, notes_box, self.status_panel())
quality_control_pane = pn.Column(header, state_row)

# button
header_row = pn.Row(
Expand Down
2 changes: 1 addition & 1 deletion src/aind_qc_portal/qc_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# State sync
class Settings(param.Parameterized):
id = param.String(default="4ceba2a9-ecb0-458e-b874-9923762d7725")
id = param.String(default="a61f285e-c79b-46cd-b554-991d711b6e53")


settings = Settings()
Expand Down

0 comments on commit a40ac0d

Please sign in to comment.