Skip to content

Commit

Permalink
Merge pull request stanford-oval#181 from evidencebp/174-Pylint-alert…
Browse files Browse the repository at this point in the history
…s-corrections

174 pylint alerts corrections
  • Loading branch information
shaoyijia authored Sep 27, 2024
2 parents 9ac901d + 3aad8d3 commit 735f547
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Process `arxiv_data_210930-054931.csv` from https://www.kaggle.com/datasets/spsayakpaul/arxiv-paper-abstracts
"""Process `arxiv_data_210930-054931.csv`
from https://www.kaggle.com/datasets/spsayakpaul/arxiv-paper-abstracts
to a csv file that is compatible with VectorRM.
"""

Expand Down
34 changes: 26 additions & 8 deletions frontend/demo_light/pages_util/CreateNewArticle.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
import streamlit as st
from demo_util import DemoFileIOHelper, DemoTextProcessingHelper, DemoUIHelper, truncate_filename


def create_new_article_page():
demo_util.clear_other_page_session_state(page_index=3)

if "page3_write_article_state" not in st.session_state:
st.session_state["page3_write_article_state"] = "not started"

def handle_not_started():
if st.session_state["page3_write_article_state"] == "not started":

_, search_form_column, _ = st.columns([2, 5, 2])
Expand Down Expand Up @@ -42,6 +36,7 @@ def create_new_article_page():
else:
st.session_state["page3_write_article_state"] = "initiated"

def handle_initiated():
if st.session_state["page3_write_article_state"] == "initiated":
current_working_dir = os.path.join(demo_util.get_demo_dir(), "DEMO_WORKING_DIR")
if not os.path.exists(current_working_dir):
Expand All @@ -52,7 +47,8 @@ def create_new_article_page():
st.session_state["page3_current_working_dir"] = current_working_dir
st.session_state["page3_write_article_state"] = "pre_writing"

if st.session_state["page3_write_article_state"] == "pre_writing":
def handle_pre_writing():
if st.session_state["page3_write_article_state"] == "pre_writing":
status = st.status("I am brain**STORM**ing now to research the topic. (This may take 2-3 minutes.)")
st_callback_handler = demo_util.StreamlitCallbackHandler(status)
with status:
Expand All @@ -71,6 +67,7 @@ def create_new_article_page():
st.session_state["page3_write_article_state"] = "final_writing"
status.update(label="brain**STORM**ing complete!", state="complete")

def handle_final_writing():
if st.session_state["page3_write_article_state"] == "final_writing":
# polish final article
with st.status(
Expand All @@ -86,13 +83,16 @@ def create_new_article_page():
st.session_state["page3_write_article_state"] = "prepare_to_show_result"
status.update(label="information snythesis complete!", state="complete")

def handle_prepare_to_show_result():
if st.session_state["page3_write_article_state"] == "prepare_to_show_result":
_, show_result_col, _ = st.columns([4, 3, 4])
with show_result_col:
if st.button("show final article"):
st.session_state["page3_write_article_state"] = "completed"
st.rerun()

def handle_completed():

if st.session_state["page3_write_article_state"] == "completed":
# display polished article
current_working_dir_paths = DemoFileIOHelper.read_structure_to_dict(
Expand All @@ -101,3 +101,21 @@ def create_new_article_page():
demo_util.display_article_page(selected_article_name=st.session_state["page3_topic_name_cleaned"],
selected_article_file_path_dict=current_article_file_path_dict,
show_title=True, show_main_article=True)

def create_new_article_page():
demo_util.clear_other_page_session_state(page_index=3)

if "page3_write_article_state" not in st.session_state:
st.session_state["page3_write_article_state"] = "not started"

handle_not_started()

handle_initiated()

handle_pre_writing()

handle_final_writing()

handle_prepare_to_show_result()

handle_completed()
8 changes: 5 additions & 3 deletions frontend/demo_light/storm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ def main():
menu_container = st.container()
with menu_container:
pages = ["My Articles", "Create New Article"]
styles={
"container": {"padding": "0.2rem 0",
"background-color": "#22222200"},
}
menu_selection = option_menu(None, pages,
icons=['house', 'search'],
menu_icon="cast", default_index=0, orientation="horizontal",
manual_select=st.session_state.selected_page,
styles={
"container": {"padding": "0.2rem 0", "background-color": "#22222200"},
},
styles=styles,
key='menu_selection')
if st.session_state.get("manual_selection_override", False):
menu_selection = pages[st.session_state["selected_page"]]
Expand Down

0 comments on commit 735f547

Please sign in to comment.