C2MV commited on
Commit
09fa6fe
verified
1 Parent(s): c1976c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -3
app.py CHANGED
@@ -524,6 +524,8 @@ def load_data(x1_name, x2_name, x3_name, y_name, x1_levels_str, x2_levels_str, x
524
 
525
  except Exception as e:
526
  # Mostrar mensaje de error
 
 
527
  return None, "", "", "", "", [], [], [], gr.update(visible=False)
528
 
529
  def fit_and_optimize_model():
@@ -594,7 +596,13 @@ def download_current_plot(all_figures, current_index):
594
  fig = all_figures[current_index]
595
  img_bytes = rsm.save_fig_to_bytes(fig)
596
  filename = f"Grafico_RSM_{current_index + 1}.png"
597
- return (img_bytes, filename)
 
 
 
 
 
 
598
 
599
  def download_all_plots_zip(all_figures):
600
  """
@@ -604,7 +612,13 @@ def download_all_plots_zip(all_figures):
604
  if zip_bytes:
605
  timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
606
  zip_filename = f"Graficos_RSM_{timestamp}.zip"
607
- return (zip_bytes, zip_filename)
 
 
 
 
 
 
608
  return (None, "Graficos_RSM.zip") # Nombre por defecto
609
 
610
  def download_all_tables_excel():
@@ -625,7 +639,12 @@ def download_all_tables_excel():
625
  timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
626
  excel_filename = f"Tablas_RSM_{timestamp}.xlsx"
627
 
628
- return (excel_bytes, excel_filename)
 
 
 
 
 
629
 
630
  # --- Crear la interfaz de Gradio ---
631
 
 
524
 
525
  except Exception as e:
526
  # Mostrar mensaje de error
527
+ error_message = f"Error al cargar los datos: {str(e)}"
528
+ print(error_message)
529
  return None, "", "", "", "", [], [], [], gr.update(visible=False)
530
 
531
  def fit_and_optimize_model():
 
596
  fig = all_figures[current_index]
597
  img_bytes = rsm.save_fig_to_bytes(fig)
598
  filename = f"Grafico_RSM_{current_index + 1}.png"
599
+
600
+ # Crear un archivo temporal
601
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
602
+ temp_file.write(img_bytes)
603
+ temp_path = temp_file.name
604
+
605
+ return (temp_path, filename)
606
 
607
  def download_all_plots_zip(all_figures):
608
  """
 
612
  if zip_bytes:
613
  timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
614
  zip_filename = f"Graficos_RSM_{timestamp}.zip"
615
+
616
+ # Crear un archivo temporal para el ZIP
617
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".zip") as temp_file:
618
+ temp_file.write(zip_bytes)
619
+ temp_path = temp_file.name
620
+
621
+ return (temp_path, zip_filename)
622
  return (None, "Graficos_RSM.zip") # Nombre por defecto
623
 
624
  def download_all_tables_excel():
 
639
  timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
640
  excel_filename = f"Tablas_RSM_{timestamp}.xlsx"
641
 
642
+ # Crear un archivo temporal para el Excel
643
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as temp_file:
644
+ temp_file.write(excel_bytes)
645
+ temp_path = temp_file.name
646
+
647
+ return (temp_path, excel_filename)
648
 
649
  # --- Crear la interfaz de Gradio ---
650