Spaces:
Sleeping
Sleeping
Pointf5ive commited on
Commit ·
36268c6
1
Parent(s): 600a5ed
fix: add explicit dashboard workbook intake and set-active-workbook flow
Browse files
app.py
CHANGED
|
@@ -2724,6 +2724,21 @@ def load_uploaded(uploaded_file):
|
|
| 2724 |
return load_workbook(persisted, f"Workbook uploaded and saved to {persisted}.")
|
| 2725 |
|
| 2726 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2727 |
def load_local_path(path_text: str):
|
| 2728 |
path = _validate_workbook_path(Path(path_text or "").expanduser())
|
| 2729 |
log_df = score_log(path)
|
|
@@ -2847,6 +2862,20 @@ with gr.Blocks(title="TOTEM Studio") as demo:
|
|
| 2847 |
)
|
| 2848 |
run_button = gr.Button("Run TOTEM Analysis", variant="secondary", scale=1)
|
| 2849 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2850 |
with gr.Accordion("Manuscript Intake (score pipeline)", open=False, elem_id="codex-panel"):
|
| 2851 |
with gr.Column(elem_classes=["codex-body"]):
|
| 2852 |
gr.Markdown(
|
|
@@ -3032,6 +3061,11 @@ with gr.Blocks(title="TOTEM Studio") as demo:
|
|
| 3032 |
# demo.load removed: user triggers load via Run TOTEM Analysis button
|
| 3033 |
workbook_upload.upload(load_uploaded, inputs=[workbook_upload],
|
| 3034 |
outputs=[active_path, dashboard, log_state, score_status])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3035 |
run_button.click(run_analysis, inputs=[active_path],
|
| 3036 |
outputs=[dashboard, log_state, score_status])
|
| 3037 |
path_button.click(load_local_path, inputs=[path_input],
|
|
|
|
| 2724 |
return load_workbook(persisted, f"Workbook uploaded and saved to {persisted}.")
|
| 2725 |
|
| 2726 |
|
| 2727 |
+
def set_active_workbook(uploaded_file):
|
| 2728 |
+
"""
|
| 2729 |
+
Explicit workbook intake handler for dashboard use.
|
| 2730 |
+
Uses a visible file picker + button flow to avoid upload-event ambiguity.
|
| 2731 |
+
"""
|
| 2732 |
+
if uploaded_file is None:
|
| 2733 |
+
raise gr.Error("Select a workbook (.xlsx or .xlsm) first.")
|
| 2734 |
+
persisted = _persist_uploaded_workbook(uploaded_file)
|
| 2735 |
+
return (
|
| 2736 |
+
str(persisted),
|
| 2737 |
+
str(persisted),
|
| 2738 |
+
*load_workbook(persisted, f"Active workbook set: {persisted.name}"),
|
| 2739 |
+
)
|
| 2740 |
+
|
| 2741 |
+
|
| 2742 |
def load_local_path(path_text: str):
|
| 2743 |
path = _validate_workbook_path(Path(path_text or "").expanduser())
|
| 2744 |
log_df = score_log(path)
|
|
|
|
| 2862 |
)
|
| 2863 |
run_button = gr.Button("Run TOTEM Analysis", variant="secondary", scale=1)
|
| 2864 |
|
| 2865 |
+
with gr.Accordion("Workbook Intake (required for scoring)", open=True, elem_id="path-panel"):
|
| 2866 |
+
with gr.Column(elem_classes=["wrap"]):
|
| 2867 |
+
dashboard_workbook_file = gr.File(
|
| 2868 |
+
label="Workbook (.xlsx or .xlsm)",
|
| 2869 |
+
file_types=[".xlsx", ".xlsm"],
|
| 2870 |
+
type="filepath",
|
| 2871 |
+
)
|
| 2872 |
+
dashboard_set_workbook = gr.Button("Set Active Workbook", variant="primary")
|
| 2873 |
+
workbook_home_display = gr.Textbox(
|
| 2874 |
+
label="Active workbook home path",
|
| 2875 |
+
value=str(_preferred_workbook_path()),
|
| 2876 |
+
interactive=False,
|
| 2877 |
+
)
|
| 2878 |
+
|
| 2879 |
with gr.Accordion("Manuscript Intake (score pipeline)", open=False, elem_id="codex-panel"):
|
| 2880 |
with gr.Column(elem_classes=["codex-body"]):
|
| 2881 |
gr.Markdown(
|
|
|
|
| 3061 |
# demo.load removed: user triggers load via Run TOTEM Analysis button
|
| 3062 |
workbook_upload.upload(load_uploaded, inputs=[workbook_upload],
|
| 3063 |
outputs=[active_path, dashboard, log_state, score_status])
|
| 3064 |
+
dashboard_set_workbook.click(
|
| 3065 |
+
set_active_workbook,
|
| 3066 |
+
inputs=[dashboard_workbook_file],
|
| 3067 |
+
outputs=[workbook_home_display, path_input, active_path, dashboard, log_state, score_status],
|
| 3068 |
+
)
|
| 3069 |
run_button.click(run_analysis, inputs=[active_path],
|
| 3070 |
outputs=[dashboard, log_state, score_status])
|
| 3071 |
path_button.click(load_local_path, inputs=[path_input],
|