inoki-giskard commited on
Commit
ea670d5
1 Parent(s): 34009a0

Separate validation and submit

Browse files
Files changed (1) hide show
  1. app.py +30 -10
app.py CHANGED
@@ -54,15 +54,15 @@ def check_dataset(dataset_id, dataset_config="default", dataset_split="test"):
54
  return dataset_id, dataset_config, dataset_split
55
 
56
 
57
- def try_submit(model_id, dataset_id, dataset_config, dataset_split, local):
58
  # Validate model
59
  m_id, ppl = check_model(model_id=model_id)
60
  if m_id is None:
61
  gr.Warning(f'Model "{model_id}" is not accessible. Please set your HF_TOKEN if it is a private model.')
62
- return dataset_config, dataset_split
63
  if isinstance(ppl, Exception):
64
  gr.Warning(f'Failed to load "{model_id} model": {ppl}')
65
- return dataset_config, dataset_split
66
 
67
  # Validate dataset
68
  d_id, config, split = check_dataset(dataset_id=dataset_id, dataset_config=dataset_config, dataset_split=dataset_split)
@@ -80,12 +80,18 @@ def try_submit(model_id, dataset_id, dataset_config, dataset_split, local):
80
  dataset_ok = True
81
 
82
  if not dataset_ok:
83
- return config, split
84
 
85
  # TODO: Validate column mapping by running once
86
 
87
  del ppl
88
 
 
 
 
 
 
 
89
  if local:
90
  if "cicd" not in sys.path:
91
  sys.path.append("cicd")
@@ -130,7 +136,6 @@ def try_submit(model_id, dataset_id, dataset_config, dataset_split, local):
130
 
131
  print(f"Finished local evaluation on {eval_str}: {time.time() - start:.2f}s")
132
 
133
- return config, split
134
 
135
  with gr.Blocks(theme=theme) as iface:
136
  with gr.Row():
@@ -176,19 +181,34 @@ with gr.Blocks(theme=theme) as iface:
176
  )
177
 
178
  with gr.Row():
179
- run_btn = gr.Button("Validate and submit evaluation task", variant="primary")
180
- run_btn.click(
181
- try_submit,
 
 
 
 
 
182
  inputs=[
183
  model_id_input,
184
  dataset_id_input,
185
  dataset_config_input,
186
  dataset_split_input,
187
- run_local,
188
  ],
189
  outputs=[
190
  dataset_config_input,
191
- dataset_split_input
 
 
 
 
 
 
 
 
 
 
 
192
  ],
193
  )
194
 
 
54
  return dataset_id, dataset_config, dataset_split
55
 
56
 
57
+ def try_validate(model_id, dataset_id, dataset_config, dataset_split):
58
  # Validate model
59
  m_id, ppl = check_model(model_id=model_id)
60
  if m_id is None:
61
  gr.Warning(f'Model "{model_id}" is not accessible. Please set your HF_TOKEN if it is a private model.')
62
+ return dataset_config, dataset_split, gr.update(interactive=False)
63
  if isinstance(ppl, Exception):
64
  gr.Warning(f'Failed to load "{model_id} model": {ppl}')
65
+ return dataset_config, dataset_split, gr.update(interactive=False)
66
 
67
  # Validate dataset
68
  d_id, config, split = check_dataset(dataset_id=dataset_id, dataset_config=dataset_config, dataset_split=dataset_split)
 
80
  dataset_ok = True
81
 
82
  if not dataset_ok:
83
+ return config, split, gr.update(interactive=False)
84
 
85
  # TODO: Validate column mapping by running once
86
 
87
  del ppl
88
 
89
+ gr.Info("Model and dataset validations passed. Your can submit the evaluation task.")
90
+
91
+ return config, split, gr.update(interactive=True)
92
+
93
+
94
+ def try_submit(m_id, d_id, config, split, local):
95
  if local:
96
  if "cicd" not in sys.path:
97
  sys.path.append("cicd")
 
136
 
137
  print(f"Finished local evaluation on {eval_str}: {time.time() - start:.2f}s")
138
 
 
139
 
140
  with gr.Blocks(theme=theme) as iface:
141
  with gr.Row():
 
181
  )
182
 
183
  with gr.Row():
184
+ validate_btn = gr.Button("Validate model and dataset", variant="primary")
185
+ run_btn = gr.Button(
186
+ "Submit evaluation task",
187
+ variant="primary",
188
+ interactive=False,
189
+ )
190
+ validate_btn.click(
191
+ try_validate,
192
  inputs=[
193
  model_id_input,
194
  dataset_id_input,
195
  dataset_config_input,
196
  dataset_split_input,
 
197
  ],
198
  outputs=[
199
  dataset_config_input,
200
+ dataset_split_input,
201
+ run_btn,
202
+ ],
203
+ )
204
+ run_btn.click(
205
+ try_submit,
206
+ inputs=[
207
+ model_id_input,
208
+ dataset_id_input,
209
+ dataset_config_input,
210
+ dataset_split_input,
211
+ run_local,
212
  ],
213
  )
214