Add file uploader for .eval files
Browse files
app.py
CHANGED
|
@@ -718,17 +718,32 @@ def main() -> None:
|
|
| 718 |
st.title("π΄ github_red")
|
| 719 |
st.subheader("Trajectory Viewer")
|
| 720 |
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 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(
|
| 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.")
|