Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -239,7 +239,7 @@ def phylogenetic_placement(sequence: str, mafft_cmd: str, iqtree_cmd: str):
|
|
| 239 |
logger.error(f"Phylogenetic placement failed: {e}", exc_info=True)
|
| 240 |
return False, f"Error: {str(e)}", None, None
|
| 241 |
finally:
|
| 242 |
-
#
|
| 243 |
if query_fasta and os.path.exists(query_fasta):
|
| 244 |
try:
|
| 245 |
os.unlink(query_fasta)
|
|
@@ -429,9 +429,8 @@ async def run_pipeline_from_file(fasta_file_obj, similarity_score, build_ml_tree
|
|
| 429 |
if temp_file_path and os.path.exists(temp_file_path):
|
| 430 |
try:
|
| 431 |
os.unlink(temp_file_path)
|
| 432 |
-
except Exception as
|
| 433 |
-
logger.warning(f"Failed to delete temp file {temp_file_path}: {
|
| 434 |
-
|
| 435 |
# --- Pydantic Models ---
|
| 436 |
class AnalysisRequest(BaseModel):
|
| 437 |
sequence: str
|
|
@@ -547,9 +546,9 @@ async def analyze_file(
|
|
| 547 |
if temp_file_path and os.path.exists(temp_file_path):
|
| 548 |
try:
|
| 549 |
os.unlink(temp_file_path)
|
| 550 |
-
except Exception as
|
| 551 |
-
logger.warning(f"Failed to clean up {temp_file_path}:
|
| 552 |
-
|
| 553 |
@app.get("/download/{file_type}/{query_id}")
|
| 554 |
async def download_file(file_type: str, query_id: str):
|
| 555 |
try:
|
|
@@ -759,7 +758,6 @@ def create_gradio_interface():
|
|
| 759 |
|
| 760 |
# --- Application Startup ---
|
| 761 |
def run_application():
|
| 762 |
-
main_gradio_app = None # Predefine for main app
|
| 763 |
try:
|
| 764 |
main_gradio_app = create_gradio_interface()
|
| 765 |
main_gradio_app = gr.mount_gradio_app(app, main_gradio_app, path="/gradio")
|
|
@@ -787,8 +785,7 @@ def run_application():
|
|
| 787 |
)
|
| 788 |
except Exception as fallback_error:
|
| 789 |
logger.error(f"Fallback failed: {fallback_error}", exc_info=True)
|
| 790 |
-
print("❌ Application failed to start. Check logs for details.")
|
| 791 |
-
if __name__ == "__main__":
|
| 792 |
print("🧬 Gene Analysis Pipeline Starting...")
|
| 793 |
print("=" * 50)
|
| 794 |
print("🔍 Checking system components...")
|
|
|
|
| 239 |
logger.error(f"Phylogenetic placement failed: {e}", exc_info=True)
|
| 240 |
return False, f"Error: {str(e)}", None, None
|
| 241 |
finally:
|
| 242 |
+
# FIXED: Properly handle cleanup with specific exception handling
|
| 243 |
if query_fasta and os.path.exists(query_fasta):
|
| 244 |
try:
|
| 245 |
os.unlink(query_fasta)
|
|
|
|
| 429 |
if temp_file_path and os.path.exists(temp_file_path):
|
| 430 |
try:
|
| 431 |
os.unlink(temp_file_path)
|
| 432 |
+
except Exception as cleanup_error: # FIXED: Use different variable name
|
| 433 |
+
logger.warning(f"Failed to delete temp file {temp_file_path}: {cleanup_error}")
|
|
|
|
| 434 |
# --- Pydantic Models ---
|
| 435 |
class AnalysisRequest(BaseModel):
|
| 436 |
sequence: str
|
|
|
|
| 546 |
if temp_file_path and os.path.exists(temp_file_path):
|
| 547 |
try:
|
| 548 |
os.unlink(temp_file_path)
|
| 549 |
+
except Exception as cleanup_error: # FIXED: Use different variable name
|
| 550 |
+
logger.warning(f"Failed to clean up {temp_file_path}: cleanup_error}")
|
| 551 |
+
|
| 552 |
@app.get("/download/{file_type}/{query_id}")
|
| 553 |
async def download_file(file_type: str, query_id: str):
|
| 554 |
try:
|
|
|
|
| 758 |
|
| 759 |
# --- Application Startup ---
|
| 760 |
def run_application():
|
|
|
|
| 761 |
try:
|
| 762 |
main_gradio_app = create_gradio_interface()
|
| 763 |
main_gradio_app = gr.mount_gradio_app(app, main_gradio_app, path="/gradio")
|
|
|
|
| 785 |
)
|
| 786 |
except Exception as fallback_error:
|
| 787 |
logger.error(f"Fallback failed: {fallback_error}", exc_info=True)
|
| 788 |
+
print("❌ Application failed to start. Check logs for details.")if __name__ == "__main__":
|
|
|
|
| 789 |
print("🧬 Gene Analysis Pipeline Starting...")
|
| 790 |
print("=" * 50)
|
| 791 |
print("🔍 Checking system components...")
|