Spaces:
Sleeping
Sleeping
Fix the problem of re-analyzing previous file when a new file is uploaded
Browse files
state.py
CHANGED
|
@@ -409,13 +409,28 @@ def run_analysis_loop(file_names, file_paths_dict, pipeline,
|
|
| 409 |
enable_denoise, early_cleanup,
|
| 410 |
gain_window, minimum_gain, maximum_gain,
|
| 411 |
df_model, df_state, atten_lim_db):
|
| 412 |
-
"""Process
|
| 413 |
import time
|
| 414 |
import utils as _utils
|
| 415 |
start_time = time.time()
|
| 416 |
-
totalFiles = len(file_names)
|
| 417 |
|
| 418 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
fpath = file_paths_dict.get(fname, "")
|
| 420 |
ext = fpath.lower()
|
| 421 |
|
|
@@ -440,8 +455,10 @@ def run_analysis_loop(file_names, file_paths_dict, pipeline,
|
|
| 440 |
with st.spinner(f"Analyzing {i+1}/{totalFiles}"):
|
| 441 |
analyze(fname)
|
| 442 |
|
| 443 |
-
st.success(f"Analyzed {totalFiles} file(s) in {time.time() - start_time:.1f}s")
|
| 444 |
st.session_state.analyzeAllToggle = False
|
|
|
|
|
|
|
| 445 |
|
| 446 |
|
| 447 |
def build_table_df(displayDF):
|
|
|
|
| 409 |
enable_denoise, early_cleanup,
|
| 410 |
gain_window, minimum_gain, maximum_gain,
|
| 411 |
df_model, df_state, atten_lim_db):
|
| 412 |
+
"""Process only new (not yet analyzed) files and populate session state."""
|
| 413 |
import time
|
| 414 |
import utils as _utils
|
| 415 |
start_time = time.time()
|
|
|
|
| 416 |
|
| 417 |
+
# Only process files that haven't been analyzed yet
|
| 418 |
+
pending = [
|
| 419 |
+
fname for fname in file_names
|
| 420 |
+
if not (
|
| 421 |
+
fname in st.session_state.results
|
| 422 |
+
and len(st.session_state.results[fname]) == 2
|
| 423 |
+
)
|
| 424 |
+
]
|
| 425 |
+
|
| 426 |
+
if not pending:
|
| 427 |
+
st.info("All files have already been analyzed.")
|
| 428 |
+
st.session_state.analyzeAllToggle = False
|
| 429 |
+
return
|
| 430 |
+
|
| 431 |
+
totalFiles = len(pending)
|
| 432 |
+
|
| 433 |
+
for i, fname in enumerate(pending):
|
| 434 |
fpath = file_paths_dict.get(fname, "")
|
| 435 |
ext = fpath.lower()
|
| 436 |
|
|
|
|
| 455 |
with st.spinner(f"Analyzing {i+1}/{totalFiles}"):
|
| 456 |
analyze(fname)
|
| 457 |
|
| 458 |
+
st.success(f"Analyzed {totalFiles} new file(s) in {time.time() - start_time:.1f}s")
|
| 459 |
st.session_state.analyzeAllToggle = False
|
| 460 |
+
# Rotate uploader key to clear the file uploader widget
|
| 461 |
+
st.session_state.uploader_key = st.session_state.get("uploader_key", 0) + 1
|
| 462 |
|
| 463 |
|
| 464 |
def build_table_df(displayDF):
|