audrey06100 commited on
Commit
c01b1d9
·
1 Parent(s): 856ccf3
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -212,7 +212,7 @@ update_js = """
212
  """
213
 
214
  with gr.Blocks() as demo:
215
- stage1_json = gr.JSON(visible=False)
216
  stage2_json = gr.JSON(visible=False)
217
  channel_json = gr.JSON(visible=False)
218
 
@@ -289,6 +289,11 @@ with gr.Blocks() as demo:
289
  # | Stage1: channel mapping |
290
  # +========================================================================================+
291
  def reset_all(stage1_info, stage2_info, in_loc):
 
 
 
 
 
292
  # stop Stage2
293
  if stage2_info!=None and stage2_info["state"]=="running":
294
  utils.dataDelete(stage2_info["filePath"])
@@ -314,6 +319,7 @@ with gr.Blocks() as demo:
314
  "outputResult" : rootpath+'/'+stage1_id+'/'+outputname
315
  },
316
  "state" : "step1-initializing",
 
317
  "step2" : {
318
  "count" : None,
319
  "totalNum" : None
@@ -365,10 +371,13 @@ with gr.Blocks() as demo:
365
  # | step transition |
366
  # +========================================================================================+
367
  def init_next_step(stage1_info, channel_info, fillmode, sel_radio, sel_chkbox):
 
 
 
368
 
369
  # ========================================step0=========================================
370
  # step0 to step1
371
- if stage1_info["state"] == "step1-initializing":
372
  yield {desc_md : gr.Markdown("Mapping...", visible=True)}
373
 
374
  # match the names
 
212
  """
213
 
214
  with gr.Blocks() as demo:
215
+ stage1_json = gr.JSON({}, visible=False)
216
  stage2_json = gr.JSON(visible=False)
217
  channel_json = gr.JSON(visible=False)
218
 
 
289
  # | Stage1: channel mapping |
290
  # +========================================================================================+
291
  def reset_all(stage1_info, stage2_info, in_loc):
292
+ if in_loc == None:
293
+ gr.Warning("Please upload a file.")
294
+ stage1_info["errorFlag"] = True
295
+ return {stage1_json : stage1_info}
296
+
297
  # stop Stage2
298
  if stage2_info!=None and stage2_info["state"]=="running":
299
  utils.dataDelete(stage2_info["filePath"])
 
319
  "outputResult" : rootpath+'/'+stage1_id+'/'+outputname
320
  },
321
  "state" : "step1-initializing",
322
+ "errorFlag" : False,
323
  "step2" : {
324
  "count" : None,
325
  "totalNum" : None
 
371
  # | step transition |
372
  # +========================================================================================+
373
  def init_next_step(stage1_info, channel_info, fillmode, sel_radio, sel_chkbox):
374
+ if stage1_info["errorFlag"] == True:
375
+ stage1_info["errorFlag"] = False
376
+ yield {stage1_json : stage1_info}
377
 
378
  # ========================================step0=========================================
379
  # step0 to step1
380
+ elif stage1_info["state"] == "step1-initializing":
381
  yield {desc_md : gr.Markdown("Mapping...", visible=True)}
382
 
383
  # match the names