Update app.py
Browse files
app.py
CHANGED
|
@@ -389,10 +389,14 @@ class FGIIDIAnalyzer:
|
|
| 389 |
st.session_state.current_file_progress = ""
|
| 390 |
st.session_state.overall_progress = 0
|
| 391 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
# Uruchom przetwarzanie w osobnym w膮tku
|
| 393 |
self.processing_thread = threading.Thread(
|
| 394 |
target=self.process_files_async,
|
| 395 |
-
args=(settings,)
|
| 396 |
)
|
| 397 |
self.processing_thread.start()
|
| 398 |
st.rerun()
|
|
@@ -448,24 +452,23 @@ class FGIIDIAnalyzer:
|
|
| 448 |
time.sleep(2)
|
| 449 |
st.rerun()
|
| 450 |
|
| 451 |
-
def process_files_async(self, settings):
|
| 452 |
-
"""Asynchroniczne przetwarzanie plik贸w - thread-safe"""
|
| 453 |
try:
|
| 454 |
self.log_message("馃殌 Rozpoczynam przetwarzanie plik贸w", force_local=True)
|
| 455 |
|
| 456 |
-
total_files = len(
|
| 457 |
|
| 458 |
# ETAP 1: Transkrypcja plik贸w
|
| 459 |
-
for i, file_info in enumerate(
|
| 460 |
# Sprawd藕 status w bezpieczny spos贸b
|
| 461 |
try:
|
| 462 |
if st.session_state.processing_status != 'running':
|
| 463 |
self.log_message("鈴癸笍 Przetwarzanie zatrzymane przez u偶ytkownika", force_local=True)
|
| 464 |
return
|
| 465 |
except:
|
| 466 |
-
# Je艣li nie mo偶na sprawdzi膰 statusu,
|
| 467 |
-
|
| 468 |
-
return
|
| 469 |
|
| 470 |
try:
|
| 471 |
# Update progress
|
|
@@ -531,15 +534,9 @@ class FGIIDIAnalyzer:
|
|
| 531 |
self.update_progress_safe(0.9, "馃搫 Generuj臋 raport badawczy...")
|
| 532 |
self.log_message("馃搫 Rozpoczynam generowanie raportu", force_local=True)
|
| 533 |
|
| 534 |
-
# Pobierz brief z session_state
|
| 535 |
-
try:
|
| 536 |
-
brief = st.session_state.research_brief
|
| 537 |
-
except:
|
| 538 |
-
brief = ""
|
| 539 |
-
|
| 540 |
final_report = self.report_generator.generate_comprehensive_report(
|
| 541 |
transcriptions_to_use,
|
| 542 |
-
|
| 543 |
)
|
| 544 |
|
| 545 |
# Zapisz raport
|
|
|
|
| 389 |
st.session_state.current_file_progress = ""
|
| 390 |
st.session_state.overall_progress = 0
|
| 391 |
|
| 392 |
+
# Przeka偶 dane do w膮tku (kopiuj dane z session_state)
|
| 393 |
+
files_copy = st.session_state.uploaded_files.copy()
|
| 394 |
+
brief_copy = st.session_state.research_brief
|
| 395 |
+
|
| 396 |
# Uruchom przetwarzanie w osobnym w膮tku
|
| 397 |
self.processing_thread = threading.Thread(
|
| 398 |
target=self.process_files_async,
|
| 399 |
+
args=(settings, files_copy, brief_copy)
|
| 400 |
)
|
| 401 |
self.processing_thread.start()
|
| 402 |
st.rerun()
|
|
|
|
| 452 |
time.sleep(2)
|
| 453 |
st.rerun()
|
| 454 |
|
| 455 |
+
def process_files_async(self, settings, uploaded_files, research_brief):
|
| 456 |
+
"""Asynchroniczne przetwarzanie plik贸w - thread-safe z przekazanymi danymi"""
|
| 457 |
try:
|
| 458 |
self.log_message("馃殌 Rozpoczynam przetwarzanie plik贸w", force_local=True)
|
| 459 |
|
| 460 |
+
total_files = len(uploaded_files)
|
| 461 |
|
| 462 |
# ETAP 1: Transkrypcja plik贸w
|
| 463 |
+
for i, file_info in enumerate(uploaded_files):
|
| 464 |
# Sprawd藕 status w bezpieczny spos贸b
|
| 465 |
try:
|
| 466 |
if st.session_state.processing_status != 'running':
|
| 467 |
self.log_message("鈴癸笍 Przetwarzanie zatrzymane przez u偶ytkownika", force_local=True)
|
| 468 |
return
|
| 469 |
except:
|
| 470 |
+
# Je艣li nie mo偶na sprawdzi膰 statusu, kontynuuj (mo偶e by膰 w middle of processing)
|
| 471 |
+
pass
|
|
|
|
| 472 |
|
| 473 |
try:
|
| 474 |
# Update progress
|
|
|
|
| 534 |
self.update_progress_safe(0.9, "馃搫 Generuj臋 raport badawczy...")
|
| 535 |
self.log_message("馃搫 Rozpoczynam generowanie raportu", force_local=True)
|
| 536 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 537 |
final_report = self.report_generator.generate_comprehensive_report(
|
| 538 |
transcriptions_to_use,
|
| 539 |
+
research_brief
|
| 540 |
)
|
| 541 |
|
| 542 |
# Zapisz raport
|