gabboud commited on
Commit
d848ff0
·
1 Parent(s): fb0e142

propagate rfd3 subprocess stderr to run status textbox

Browse files
Files changed (2) hide show
  1. app.py +5 -5
  2. utils/pipelines.py +5 -3
app.py CHANGED
@@ -141,13 +141,13 @@ with gr.Blocks(title="RFD3 Test") as demo:
141
 
142
  def generate(config_upload, scaffold_upload, num_batches, num_designs_per_batch, extra_args):
143
  if config_upload is None:
144
- return None, None
145
  else:
146
- gen_directory, gen_results = generation_with_input_config(config_upload, scaffold_upload, num_batches, num_designs_per_batch, extra_args)
147
- return gen_directory, gen_results
148
 
149
  run_btn.click(give_run_status, inputs=[num_batches, num_designs_per_batch, config_upload, scaffold_upload], outputs=runtextbox).then(
150
- generate, inputs=[config_upload, scaffold_upload, num_batches, num_designs_per_batch, extra_args], outputs=[gen_directory, gen_results]
151
  ).then(
152
  update_batch_choices,
153
  inputs=gen_results,
@@ -179,4 +179,4 @@ with gr.Blocks(title="RFD3 Test") as demo:
179
  #visualize_btn.click(load_viewer, inputs=[batch_dropdown, design_dropdown, gen_results], outputs=viewer)
180
 
181
  if __name__ == "__main__":
182
- demo.launch(show_error=True)
 
141
 
142
  def generate(config_upload, scaffold_upload, num_batches, num_designs_per_batch, extra_args):
143
  if config_upload is None:
144
+ return gr.update(), None, None
145
  else:
146
+ textbox_update, gen_directory, gen_results = generation_with_input_config(config_upload, scaffold_upload, num_batches, num_designs_per_batch, extra_args)
147
+ return textbox_update, gen_directory, gen_results
148
 
149
  run_btn.click(give_run_status, inputs=[num_batches, num_designs_per_batch, config_upload, scaffold_upload], outputs=runtextbox).then(
150
+ generate, inputs=[config_upload, scaffold_upload, num_batches, num_designs_per_batch, extra_args], outputs=[runtextbox, gen_directory, gen_results]
151
  ).then(
152
  update_batch_choices,
153
  inputs=gen_results,
 
179
  #visualize_btn.click(load_viewer, inputs=[batch_dropdown, design_dropdown, gen_results], outputs=viewer)
180
 
181
  if __name__ == "__main__":
182
+ demo.launch()
utils/pipelines.py CHANGED
@@ -115,6 +115,8 @@ def generation_with_input_config(input_file, pdb_file, num_batches, num_designs_
115
 
116
  Returns:
117
  -------
 
 
118
  directory: str,
119
  The path to the directory where the generated structures are saved.
120
  results: list of dicts,
@@ -143,7 +145,7 @@ def generation_with_input_config(input_file, pdb_file, num_batches, num_designs_
143
  command += f" {extra_args}"
144
  print(f"Running command: {command}")
145
  start = perf_counter()
146
- subprocess.run(command, shell=True, check=True, text=True)
147
  print("Command took", perf_counter() - start, "seconds to run.")
148
 
149
 
@@ -160,7 +162,7 @@ def generation_with_input_config(input_file, pdb_file, num_batches, num_designs_
160
  results.append({"batch": batch, "design": design, "cif_path": cif_path, "pdb_path": pdb_path})
161
 
162
  print(results)
163
- return directory, results
164
 
165
  except subprocess.CalledProcessError as e:
166
- raise RuntimeError(f"Subprocess error:\n{e.stderr}") from e
 
115
 
116
  Returns:
117
  -------
118
+ textbox_update: gr.update,
119
+ A gr.update object to update the textbox with the status of the generation. propagates subprocess errors to the textbox if the generation fails.
120
  directory: str,
121
  The path to the directory where the generated structures are saved.
122
  results: list of dicts,
 
145
  command += f" {extra_args}"
146
  print(f"Running command: {command}")
147
  start = perf_counter()
148
+ res = subprocess.run(command, shell=True, check=True, text=True, capture_output=True)
149
  print("Command took", perf_counter() - start, "seconds to run.")
150
 
151
 
 
162
  results.append({"batch": batch, "design": design, "cif_path": cif_path, "pdb_path": pdb_path})
163
 
164
  print(results)
165
+ return gr.update(value="Generation Successful"), directory, results
166
 
167
  except subprocess.CalledProcessError as e:
168
+ return gr.update(f"Subprocess error:\n{e.stderr}"), None, None