Skip to content

add frontend app file that #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the cache files from this PR. They shouldn’t be included.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
76 changes: 76 additions & 0 deletions Frontend/App.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import streamlit as st
import requests
import time

st.title("Data Processing Pipeline")
gse_id = st.text_input("Enter GSE ID (e.g. GSE17833)")

PROGRESS_STEPS = [
("Processing GSE pipeline for ID", 10),
("Fetching GSE data...", 20),
("GSE data fetched successfully", 30),
("Extracting PubMed ID...", 40),
("PubMed ID extracted", 50),
("Fetching PubMed article...", 60),
("PubMed article fetched successfully", 70),
("Generating predicates from GSE metadata", 80),
("Predicates from abstract generated successfully", 90),
("Predicates from GSE metadata generated successfully", 95),
("Combining predicates", 100)
]

def process_gse(gse_id):
"""Process GSE ID and display actual results"""
progress_bar = st.progress(0)
status_text = st.empty()
result_container = st.empty()

try:
for step, progress in PROGRESS_STEPS:
progress_bar.progress(progress)
status_text.info(step)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hardcoding progress steps, consider fetching real-time progress status from the backend. This will make the UI reflect the actual processing state.

time.sleep(0.3)

response = requests.post(
"http://localhost:8000/process",
json={"query": gse_id},
timeout=60
)

progress_bar.progress(100)

if response.status_code == 200:
response_data = response.json()

if isinstance(response_data, dict):
response_data.pop("result", None)
response_data.pop("status", None)

if response_data:
status_text.success("Processing complete! Here are the results:")
result_container.json(response_data)
else:
status_text.success("Processing complete")
result_container.info("No additional data returned from backend")
else:
status_text.success("Processing complete")
result_container.json(response_data)

else:
status_text.error("Processing failed")
try:
error_data = response.json()
result_container.error(error_data)
except:
result_container.error(f"Error {response.status_code}: {response.text}")

except Exception as e:
progress_bar.progress(100)
status_text.error("Processing failed")
result_container.error(f"Error: {str(e)}")

if st.button("Submit"):
if gse_id:
process_gse(gse_id)
else:
st.warning("Please enter a valid GSE ID")