Ronio Jerico Roque commited on
Commit
52412d3
·
1 Parent(s): 7814011

Add marketplace analysis functionality and integrate into concurrent execution

Browse files
Files changed (1) hide show
  1. pages/analyzing_page.py +16 -2
pages/analyzing_page.py CHANGED
@@ -11,6 +11,7 @@ from classes.response_lld_pm_ln import LLD_PM_LN
11
  from classes.response_pull_through_offers import PullThroughOffers
12
  from classes.response_content import Content
13
  from classes.response_sem_ppc import Sem_PPC
 
14
 
15
  def run_analysis():
16
  # Placeholders for status updates
@@ -23,6 +24,7 @@ def run_analysis():
23
  pull_through_offers_status = st.empty()
24
  content_status = st.empty()
25
  sem_ppc = st.empty()
 
26
 
27
  def run_off_page_analysis():
28
  try:
@@ -113,6 +115,16 @@ def run_analysis():
113
  except Exception as e:
114
  sem_ppc.error(f"SEM/PPC Analysis failed: {e}")
115
  return None
 
 
 
 
 
 
 
 
 
 
116
 
117
  # Create threads for concurrent execution
118
  off_page_thread = threading.Thread(target=run_off_page_analysis)
@@ -124,6 +136,7 @@ def run_analysis():
124
  pull_through_offers_thread = threading.Thread(target=run_pull_through_offers)
125
  content_thread = threading.Thread(target=run_content)
126
  content_sem_ppc_thread = threading.Thread(target=run_sem_ppc_analysis)
 
127
 
128
  # Attach Streamlit context to threads
129
  add_script_run_ctx(off_page_thread)
@@ -135,6 +148,7 @@ def run_analysis():
135
  add_script_run_ctx(pull_through_offers_thread)
136
  add_script_run_ctx(content_thread)
137
  add_script_run_ctx(content_sem_ppc_thread)
 
138
 
139
  # Start threads
140
  off_page_thread.start()
@@ -146,7 +160,7 @@ def run_analysis():
146
  pull_through_offers_thread.start()
147
  content_thread.start()
148
  content_sem_ppc_thread.start()
149
-
150
 
151
  # Wait for threads to complete
152
  off_page_thread.join()
@@ -158,13 +172,13 @@ def run_analysis():
158
  pull_through_offers_thread.join()
159
  content_thread.join()
160
  content_sem_ppc_thread.join()
 
161
 
162
  st.success("🎉 All analyses completed!") # Final success message
163
  # --- Display Button After Completion ---
164
  if st.button("View Results"):
165
  st.switch_page("pages/output.py")
166
 
167
-
168
  # Execute the analysis
169
  if st.button("Back"):
170
  st.switch_page("pages/home.py")
 
11
  from classes.response_pull_through_offers import PullThroughOffers
12
  from classes.response_content import Content
13
  from classes.response_sem_ppc import Sem_PPC
14
+ from classes.response_marketplace import Marketplace
15
 
16
  def run_analysis():
17
  # Placeholders for status updates
 
24
  pull_through_offers_status = st.empty()
25
  content_status = st.empty()
26
  sem_ppc = st.empty()
27
+ marketplace = st.empty()
28
 
29
  def run_off_page_analysis():
30
  try:
 
115
  except Exception as e:
116
  sem_ppc.error(f"SEM/PPC Analysis failed: {e}")
117
  return None
118
+
119
+ def run_marketplace_analysis():
120
+ try:
121
+ marketplace.info("Starting Marketplace Analysis...")
122
+ result = Marketplace(os.getenv('Model_SEM_PPC_Analyst'))
123
+ marketplace.success("Marketplace Analysis completed successfully.")
124
+ return result
125
+ except Exception as e:
126
+ marketplace.error(f"Marketplace Analysis failed: {e}")
127
+ return None
128
 
129
  # Create threads for concurrent execution
130
  off_page_thread = threading.Thread(target=run_off_page_analysis)
 
136
  pull_through_offers_thread = threading.Thread(target=run_pull_through_offers)
137
  content_thread = threading.Thread(target=run_content)
138
  content_sem_ppc_thread = threading.Thread(target=run_sem_ppc_analysis)
139
+ marketplace_thread = threading.Thread(target=run_marketplace_analysis)
140
 
141
  # Attach Streamlit context to threads
142
  add_script_run_ctx(off_page_thread)
 
148
  add_script_run_ctx(pull_through_offers_thread)
149
  add_script_run_ctx(content_thread)
150
  add_script_run_ctx(content_sem_ppc_thread)
151
+ add_script_run_ctx(marketplace_thread)
152
 
153
  # Start threads
154
  off_page_thread.start()
 
160
  pull_through_offers_thread.start()
161
  content_thread.start()
162
  content_sem_ppc_thread.start()
163
+ marketplace_thread.start()
164
 
165
  # Wait for threads to complete
166
  off_page_thread.join()
 
172
  pull_through_offers_thread.join()
173
  content_thread.join()
174
  content_sem_ppc_thread.join()
175
+ marketplace_thread.join()
176
 
177
  st.success("🎉 All analyses completed!") # Final success message
178
  # --- Display Button After Completion ---
179
  if st.button("View Results"):
180
  st.switch_page("pages/output.py")
181
 
 
182
  # Execute the analysis
183
  if st.button("Back"):
184
  st.switch_page("pages/home.py")