Sigrid De los Santos commited on
Commit
7a4bde2
Β·
1 Parent(s): 373f148

Add matplotlib to requirements

Browse files
Files changed (2) hide show
  1. app.py +53 -42
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,9 +1,13 @@
 
1
  import os
2
  import sys
3
  import tempfile
 
 
4
  import streamlit as st
5
  import pandas as pd
6
  from io import StringIO
 
7
 
8
  # Add 'src' to Python path so we can import main.py
9
  sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
@@ -48,12 +52,25 @@ if submitted:
48
  csv_path = tmp_csv.name
49
 
50
  progress_box = st.empty()
 
 
 
 
 
 
 
 
 
 
 
51
 
52
- def show_progress(msg):
53
- progress_box.markdown(f"⏳ {msg}")
54
 
55
  try:
56
- output_path = run_pipeline(csv_path, tavily_api_key, progress_callback=show_progress)
 
 
57
  progress_box.success("βœ… Analysis complete!")
58
 
59
  if output_path and isinstance(output_path, list):
@@ -72,17 +89,21 @@ if submitted:
72
  st.components.v1.html(html_content, height=600, scrolling=True)
73
  else:
74
  st.error("❌ No reports were generated.")
 
75
  except Exception as e:
 
 
76
  progress_box.error(f"❌ Error: {e}")
77
 
78
 
 
 
79
  # import os
80
  # import sys
81
  # import tempfile
82
  # import streamlit as st
83
  # import pandas as pd
84
  # from io import StringIO
85
- # import contextlib
86
 
87
  # # Add 'src' to Python path so we can import main.py
88
  # sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
@@ -102,7 +123,7 @@ if submitted:
102
 
103
  # with st.form("topics_form"):
104
  # topic_count = st.number_input("How many topics?", min_value=1, max_value=10, value=1, step=1)
105
-
106
  # for i in range(topic_count):
107
  # col1, col2 = st.columns(2)
108
  # with col1:
@@ -126,42 +147,32 @@ if submitted:
126
  # df.to_csv(tmp_csv.name, index=False)
127
  # csv_path = tmp_csv.name
128
 
129
- # progress_placeholder = st.empty()
130
- # log_output = st.empty()
131
- # string_buffer = StringIO()
132
-
133
- # def write_log(msg):
134
- # print(msg) # Will go to final log
135
- # progress_placeholder.markdown(f"πŸ”„ {msg}")
136
-
137
- # with contextlib.redirect_stdout(string_buffer):
138
- # write_log("πŸš€ Starting analysis...")
139
- # output_path = run_pipeline(csv_path, tavily_api_key)
140
- # write_log("βœ… Finished analysis.")
141
-
142
- # logs = string_buffer.getvalue()
143
- # progress_placeholder.empty() # Clear ephemeral log
144
- # log_output.code(logs) # Show final full log
145
-
146
-
147
- # if output_path and isinstance(output_path, list):
148
- # st.success("βœ… Analysis complete!")
149
-
150
- # for path in output_path:
151
- # if os.path.exists(path):
152
- # with open(path, 'r', encoding='utf-8') as file:
153
- # html_content = file.read()
154
- # filename = os.path.basename(path)
155
-
156
- # st.download_button(
157
- # label=f"πŸ“₯ Download {filename}",
158
- # data=html_content,
159
- # file_name=filename,
160
- # mime="text/html"
161
- # )
162
- # st.components.v1.html(html_content, height=600, scrolling=True)
163
- # else:
164
- # st.error("❌ No reports were generated.")
165
-
166
 
167
 
 
1
+
2
  import os
3
  import sys
4
  import tempfile
5
+ import time
6
+ import itertools
7
  import streamlit as st
8
  import pandas as pd
9
  from io import StringIO
10
+ from threading import Thread
11
 
12
  # Add 'src' to Python path so we can import main.py
13
  sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
 
52
  csv_path = tmp_csv.name
53
 
54
  progress_box = st.empty()
55
+ rotating = True
56
+
57
+ def rotating_messages():
58
+ messages = itertools.cycle([
59
+ "πŸ” Searching financial news sources...",
60
+ "🧠 Running language model analysis...",
61
+ "πŸ“Š Generating investment reports..."
62
+ ])
63
+ while rotating:
64
+ progress_box.markdown(f"⏳ {next(messages)}")
65
+ time.sleep(1.5)
66
 
67
+ rotator_thread = Thread(target=rotating_messages)
68
+ rotator_thread.start()
69
 
70
  try:
71
+ output_path = run_pipeline(csv_path, tavily_api_key)
72
+ rotating = False
73
+ rotator_thread.join()
74
  progress_box.success("βœ… Analysis complete!")
75
 
76
  if output_path and isinstance(output_path, list):
 
89
  st.components.v1.html(html_content, height=600, scrolling=True)
90
  else:
91
  st.error("❌ No reports were generated.")
92
+
93
  except Exception as e:
94
+ rotating = False
95
+ rotator_thread.join()
96
  progress_box.error(f"❌ Error: {e}")
97
 
98
 
99
+ ##################################################################################################
100
+ ##################################################################################################
101
  # import os
102
  # import sys
103
  # import tempfile
104
  # import streamlit as st
105
  # import pandas as pd
106
  # from io import StringIO
 
107
 
108
  # # Add 'src' to Python path so we can import main.py
109
  # sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
 
123
 
124
  # with st.form("topics_form"):
125
  # topic_count = st.number_input("How many topics?", min_value=1, max_value=10, value=1, step=1)
126
+
127
  # for i in range(topic_count):
128
  # col1, col2 = st.columns(2)
129
  # with col1:
 
147
  # df.to_csv(tmp_csv.name, index=False)
148
  # csv_path = tmp_csv.name
149
 
150
+ # progress_box = st.empty()
151
+
152
+ # def show_progress(msg):
153
+ # progress_box.markdown(f"⏳ {msg}")
154
+
155
+ # try:
156
+ # output_path = run_pipeline(csv_path, tavily_api_key, progress_callback=show_progress)
157
+ # progress_box.success("βœ… Analysis complete!")
158
+
159
+ # if output_path and isinstance(output_path, list):
160
+ # for path in output_path:
161
+ # if os.path.exists(path):
162
+ # with open(path, 'r', encoding='utf-8') as file:
163
+ # html_content = file.read()
164
+ # filename = os.path.basename(path)
165
+
166
+ # st.download_button(
167
+ # label=f"πŸ“₯ Download {filename}",
168
+ # data=html_content,
169
+ # file_name=filename,
170
+ # mime="text/html"
171
+ # )
172
+ # st.components.v1.html(html_content, height=600, scrolling=True)
173
+ # else:
174
+ # st.error("❌ No reports were generated.")
175
+ # except Exception as e:
176
+ # progress_box.error(f"❌ Error: {e}")
 
 
 
 
 
 
 
 
 
 
177
 
178
 
requirements.txt CHANGED
@@ -86,4 +86,4 @@ tzdata==2025.2
86
  urllib3==2.5.0
87
  zipp==3.23.0
88
  zstandard==0.23.0
89
- matplotlib
 
86
  urllib3==2.5.0
87
  zipp==3.23.0
88
  zstandard==0.23.0
89
+