Nuzz23 commited on
Commit
06e5c32
·
1 Parent(s): 28c9320

si spera ultimo commit

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -12,11 +12,12 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
12
 
13
  OUT_PATH ="./savedPredictions/results.csv"
14
 
15
- def dataProcessing(file, timestamp_column:str=None):
16
  global chronos2
17
  if os.path.exists(OUT_PATH):
18
  os.remove(OUT_PATH)
19
 
 
20
  yield (
21
  gr.update(visible=True, value="⏳ Processing file, please wait..."), # processing_msg
22
  gr.update(visible=False), # plot_output
@@ -35,14 +36,21 @@ def dataProcessing(file, timestamp_column:str=None):
35
 
36
  df.to_csv(OUT_PATH, index=False)
37
 
38
- if fig is not None:
39
- yield (gr.update(visible=False), fig, OUT_PATH, gr.update(visible=False, value=""))
40
-
41
- yield gr.update(visible=False),gr.update(visible=False), OUT_PATH, gr.update(visible=False, value="")
42
-
 
 
43
  except Exception as e:
44
- yield gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True, value=f"Error: {e}")
45
-
 
 
 
 
 
46
 
47
  if os.path.exists(OUT_PATH):
48
  os.remove(OUT_PATH)
 
12
 
13
  OUT_PATH ="./savedPredictions/results.csv"
14
 
15
+ def dataProcessing(file, timestamp_column: str = None):
16
  global chronos2
17
  if os.path.exists(OUT_PATH):
18
  os.remove(OUT_PATH)
19
 
20
+ # Mostra messaggio di processing
21
  yield (
22
  gr.update(visible=True, value="⏳ Processing file, please wait..."), # processing_msg
23
  gr.update(visible=False), # plot_output
 
36
 
37
  df.to_csv(OUT_PATH, index=False)
38
 
39
+ # Nascondi processing, mostra risultati
40
+ yield (
41
+ gr.update(visible=False), # processing_msg
42
+ gr.update(visible=True, value=fig) if fig is not None else gr.update(visible=False), # plot_output
43
+ gr.update(visible=True, value=OUT_PATH), # download_output
44
+ gr.update(visible=False, value="") # errorHandler
45
+ )
46
  except Exception as e:
47
+ # Mostra errore
48
+ yield (
49
+ gr.update(visible=False), # processing_msg
50
+ gr.update(visible=False), # plot_output
51
+ gr.update(visible=False), # download_output
52
+ gr.update(visible=True, value=f"Error: {e}") # errorHandler
53
+ )
54
 
55
  if os.path.exists(OUT_PATH):
56
  os.remove(OUT_PATH)