rufimelo commited on
Commit
6e557be
Β·
verified Β·
1 Parent(s): f20d268

Add file uploader for .eval files

Browse files
Files changed (1) hide show
  1. app.py +25 -13
app.py CHANGED
@@ -718,17 +718,32 @@ def main() -> None:
718
  st.title("πŸ”΄ github_red")
719
  st.subheader("Trajectory Viewer")
720
 
721
- log_files = sorted(glob.glob(str(LOGS_DIR / "*.eval")), reverse=True)
722
- if not log_files:
723
- st.error(f"No .eval files found in:\n`{LOGS_DIR}`")
724
- return
725
-
726
- selected = st.selectbox(
727
- "Run log",
728
- log_files,
729
- format_func=lambda p: Path(p).stem[:50],
730
  )
731
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
732
  st.markdown("---")
733
  st.markdown("**Legend**")
734
  for role, color in ROLE_COLOR.items():
@@ -739,12 +754,9 @@ def main() -> None:
739
  unsafe_allow_html=True,
740
  )
741
 
742
- if not selected:
743
- return
744
-
745
  # ── Load ──────────────────────────────────────────────────────────
746
  try:
747
- with zipfile.ZipFile(selected) as z:
748
  sample_files = [n for n in z.namelist() if n.startswith("samples/")]
749
  if not sample_files:
750
  st.error("No sample files found in this eval log.")
 
718
  st.title("πŸ”΄ github_red")
719
  st.subheader("Trajectory Viewer")
720
 
721
+ # File uploader takes priority; fall back to local disk files
722
+ uploaded = st.file_uploader(
723
+ "Upload .eval file",
724
+ type=["eval"],
725
+ accept_multiple_files=False,
726
+ help="Upload an .eval log produced by inspect-ai",
 
 
 
727
  )
728
 
729
+ eval_source = None # will be a file-like or path string
730
+
731
+ if uploaded is not None:
732
+ eval_source = uploaded
733
+ else:
734
+ log_files = sorted(glob.glob(str(LOGS_DIR / "*.eval")), reverse=True)
735
+ if log_files:
736
+ selected_path = st.selectbox(
737
+ "Or pick a local run log",
738
+ log_files,
739
+ format_func=lambda p: Path(p).stem[:50],
740
+ )
741
+ eval_source = selected_path
742
+
743
+ if eval_source is None:
744
+ st.info("Upload an .eval file above to get started.")
745
+ return
746
+
747
  st.markdown("---")
748
  st.markdown("**Legend**")
749
  for role, color in ROLE_COLOR.items():
 
754
  unsafe_allow_html=True,
755
  )
756
 
 
 
 
757
  # ── Load ──────────────────────────────────────────────────────────
758
  try:
759
+ with zipfile.ZipFile(eval_source) as z:
760
  sample_files = [n for n in z.namelist() if n.startswith("samples/")]
761
  if not sample_files:
762
  st.error("No sample files found in this eval log.")