Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +34 -0
src/streamlit_app.py
CHANGED
|
@@ -240,6 +240,40 @@ with st.sidebar:
|
|
| 240 |
st.markdown("**Data source:** [OpenAlex](https://openalex.org)")
|
| 241 |
st.markdown("**Rate limit:** ~0.15s per author")
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
# Main content
|
| 244 |
uploaded_file = st.file_uploader(
|
| 245 |
"Upload CSV file",
|
|
|
|
| 240 |
st.markdown("**Data source:** [OpenAlex](https://openalex.org)")
|
| 241 |
st.markdown("**Rate limit:** ~0.15s per author")
|
| 242 |
|
| 243 |
+
# Add test button BEFORE file uploader
|
| 244 |
+
st.subheader("🧪 Test Mode")
|
| 245 |
+
if st.button("Run with Sample Data"):
|
| 246 |
+
# Create sample dataframe
|
| 247 |
+
test_data = pd.DataFrame({
|
| 248 |
+
'Name': ['Albert Einstein', 'Marie Curie', 'Isaac Newton'],
|
| 249 |
+
'Institution_Hint': ['Princeton', 'Paris', 'Cambridge']
|
| 250 |
+
})
|
| 251 |
+
|
| 252 |
+
# Process immediately
|
| 253 |
+
results = []
|
| 254 |
+
progress_bar = st.progress(0)
|
| 255 |
+
status_text = st.empty()
|
| 256 |
+
|
| 257 |
+
for idx, row in test_data.iterrows():
|
| 258 |
+
name = row['Name']
|
| 259 |
+
hint = row.get('Institution_Hint')
|
| 260 |
+
|
| 261 |
+
status_text.text(f"Processing {idx+1}/{len(test_data)}: {name}")
|
| 262 |
+
result = process_author(str(name).strip(), str(hint).strip() if pd.notna(hint) else None)
|
| 263 |
+
results.append(result)
|
| 264 |
+
time.sleep(RATE_LIMIT_DELAY)
|
| 265 |
+
progress_bar.progress((idx + 1) / len(test_data))
|
| 266 |
+
|
| 267 |
+
status_text.text("✅ Processing complete!")
|
| 268 |
+
results_df = pd.DataFrame(results)
|
| 269 |
+
st.dataframe(results_df, use_container_width=True)
|
| 270 |
+
|
| 271 |
+
st.divider()
|
| 272 |
+
|
| 273 |
+
# Then your existing file uploader code
|
| 274 |
+
uploaded_file = st.file_uploader("Upload CSV file", type=['csv'])
|
| 275 |
+
|
| 276 |
+
|
| 277 |
# Main content
|
| 278 |
uploaded_file = st.file_uploader(
|
| 279 |
"Upload CSV file",
|