Update app.py
Browse files
app.py
CHANGED
|
@@ -42,7 +42,7 @@ if OPENAI_AVAILABLE:
|
|
| 42 |
st.success(openai_status)
|
| 43 |
else:
|
| 44 |
st.error(openai_status)
|
| 45 |
-
st.info("
|
| 46 |
st.stop()
|
| 47 |
|
| 48 |
if not modules_loaded:
|
|
@@ -100,6 +100,7 @@ class FGIIDIAnalyzer:
|
|
| 100 |
# Queue dla komunikacji między wątkami
|
| 101 |
self.status_queue = queue.Queue()
|
| 102 |
self.processing_thread = None
|
|
|
|
| 103 |
|
| 104 |
def initialize_session_state(self):
|
| 105 |
"""Inicjalizacja session state"""
|
|
@@ -187,7 +188,16 @@ class FGIIDIAnalyzer:
|
|
| 187 |
if hasattr(self, 'local_final_report'):
|
| 188 |
st.session_state.final_report = self.local_final_report
|
| 189 |
st.session_state.processing_status = 'completed'
|
|
|
|
|
|
|
| 190 |
delattr(self, 'local_final_report')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
except Exception as e:
|
| 193 |
print(f"SYNC ERROR: {e}")
|
|
@@ -449,6 +459,21 @@ class FGIIDIAnalyzer:
|
|
| 449 |
|
| 450 |
# Auto-refresh podczas przetwarzania
|
| 451 |
if st.session_state.processing_status == 'running':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
time.sleep(2)
|
| 453 |
st.rerun()
|
| 454 |
|
|
@@ -543,9 +568,12 @@ class FGIIDIAnalyzer:
|
|
| 543 |
try:
|
| 544 |
st.session_state.final_report = final_report
|
| 545 |
st.session_state.processing_status = 'completed'
|
|
|
|
|
|
|
| 546 |
except:
|
| 547 |
-
# Fallback - zapisz lokalnie
|
| 548 |
self.local_final_report = final_report
|
|
|
|
| 549 |
print("REPORT: Generated and saved locally")
|
| 550 |
|
| 551 |
self.update_progress_safe(1.0, "✅ Zakończono!")
|
|
@@ -571,6 +599,11 @@ class FGIIDIAnalyzer:
|
|
| 571 |
st.session_state.processing_status = 'error'
|
| 572 |
except:
|
| 573 |
print(f"CRITICAL ERROR: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 574 |
|
| 575 |
def render_results(self):
|
| 576 |
"""Renderuj wyniki"""
|
|
|
|
| 42 |
st.success(openai_status)
|
| 43 |
else:
|
| 44 |
st.error(openai_status)
|
| 45 |
+
st.info("Installing dependencies... Refresh page in 30 seconds.")
|
| 46 |
st.stop()
|
| 47 |
|
| 48 |
if not modules_loaded:
|
|
|
|
| 100 |
# Queue dla komunikacji między wątkami
|
| 101 |
self.status_queue = queue.Queue()
|
| 102 |
self.processing_thread = None
|
| 103 |
+
self.processing_completed = False
|
| 104 |
|
| 105 |
def initialize_session_state(self):
|
| 106 |
"""Inicjalizacja session state"""
|
|
|
|
| 188 |
if hasattr(self, 'local_final_report'):
|
| 189 |
st.session_state.final_report = self.local_final_report
|
| 190 |
st.session_state.processing_status = 'completed'
|
| 191 |
+
st.session_state.overall_progress = 1.0
|
| 192 |
+
st.session_state.current_file_progress = "✅ Zakończono!"
|
| 193 |
delattr(self, 'local_final_report')
|
| 194 |
+
|
| 195 |
+
# Sprawdź flagę zakończenia
|
| 196 |
+
if hasattr(self, 'processing_completed') and self.processing_completed:
|
| 197 |
+
st.session_state.processing_status = 'completed'
|
| 198 |
+
st.session_state.overall_progress = 1.0
|
| 199 |
+
st.session_state.current_file_progress = "✅ Zakończono!"
|
| 200 |
+
self.processing_completed = False
|
| 201 |
|
| 202 |
except Exception as e:
|
| 203 |
print(f"SYNC ERROR: {e}")
|
|
|
|
| 459 |
|
| 460 |
# Auto-refresh podczas przetwarzania
|
| 461 |
if st.session_state.processing_status == 'running':
|
| 462 |
+
# Sprawdź czy wątek się zakończył
|
| 463 |
+
if hasattr(self, 'processing_thread') and not self.processing_thread.is_alive():
|
| 464 |
+
# Wątek się zakończył - sprawdź czy mamy raport
|
| 465 |
+
if hasattr(self, 'local_final_report'):
|
| 466 |
+
st.session_state.final_report = self.local_final_report
|
| 467 |
+
st.session_state.processing_status = 'completed'
|
| 468 |
+
st.session_state.overall_progress = 1.0
|
| 469 |
+
st.session_state.current_file_progress = "✅ Zakończono!"
|
| 470 |
+
delattr(self, 'local_final_report')
|
| 471 |
+
st.rerun()
|
| 472 |
+
elif len(st.session_state.transcriptions) > 0:
|
| 473 |
+
# Mamy transkrypcje ale brak raportu - możliwy błąd
|
| 474 |
+
st.session_state.processing_status = 'error'
|
| 475 |
+
st.rerun()
|
| 476 |
+
|
| 477 |
time.sleep(2)
|
| 478 |
st.rerun()
|
| 479 |
|
|
|
|
| 568 |
try:
|
| 569 |
st.session_state.final_report = final_report
|
| 570 |
st.session_state.processing_status = 'completed'
|
| 571 |
+
st.session_state.overall_progress = 1.0
|
| 572 |
+
st.session_state.current_file_progress = "✅ Zakończono!"
|
| 573 |
except:
|
| 574 |
+
# Fallback - zapisz lokalnie i oznacz flagę
|
| 575 |
self.local_final_report = final_report
|
| 576 |
+
self.processing_completed = True
|
| 577 |
print("REPORT: Generated and saved locally")
|
| 578 |
|
| 579 |
self.update_progress_safe(1.0, "✅ Zakończono!")
|
|
|
|
| 599 |
st.session_state.processing_status = 'error'
|
| 600 |
except:
|
| 601 |
print(f"CRITICAL ERROR: {e}")
|
| 602 |
+
|
| 603 |
+
finally:
|
| 604 |
+
# Oznacz zakończenie przetwarzania
|
| 605 |
+
self.processing_completed = True
|
| 606 |
+
print("THREAD: Processing completed - setting flag")
|
| 607 |
|
| 608 |
def render_results(self):
|
| 609 |
"""Renderuj wyniki"""
|