Spaces:
Running on Zero
Running on Zero
try to fix files not in the same dir problem
Browse files- app.py +4 -4
- utils/pipelines.py +14 -3
app.py
CHANGED
|
@@ -109,20 +109,20 @@ with gr.Blocks(title="RFD3 Test") as demo:
|
|
| 109 |
display_state = gr.Textbox(label="Selected Batch and Design", visible=True)
|
| 110 |
display_state.value = "Please Select a Batch and Design number to show sequence"
|
| 111 |
|
| 112 |
-
def generate(config_ready, scaffold_ready,
|
| 113 |
if config_ready is None or scaffold_ready is None:
|
| 114 |
return None, None
|
| 115 |
if config_ready == "upload" and scaffold_ready == "no_input":
|
| 116 |
-
gen_directory, gen_results = generation_with_input_config(config_upload, num_batches, num_designs_per_batch, extra_args)
|
| 117 |
return gen_directory, gen_results
|
| 118 |
if config_ready=="upload" and scaffold_ready=="upload":
|
| 119 |
-
gen_directory, gen_results = generation_with_input_config(config_upload, num_batches, num_designs_per_batch, extra_args)
|
| 120 |
return gen_directory, gen_results
|
| 121 |
else:
|
| 122 |
return None, None
|
| 123 |
|
| 124 |
run_btn.click(give_run_status, inputs=[config_ready, scaffold_ready, num_batches, num_designs_per_batch, config_upload, scaffold_upload], outputs=runtextbox).then(
|
| 125 |
-
generate, inputs=[config_ready, scaffold_ready,
|
| 126 |
).then(
|
| 127 |
update_batch_choices,
|
| 128 |
inputs=gen_results,
|
|
|
|
| 109 |
display_state = gr.Textbox(label="Selected Batch and Design", visible=True)
|
| 110 |
display_state.value = "Please Select a Batch and Design number to show sequence"
|
| 111 |
|
| 112 |
+
def generate(config_ready, scaffold_ready, config_upload, scaffold_upload, num_batches, num_designs_per_batch, extra_args):
|
| 113 |
if config_ready is None or scaffold_ready is None:
|
| 114 |
return None, None
|
| 115 |
if config_ready == "upload" and scaffold_ready == "no_input":
|
| 116 |
+
gen_directory, gen_results = generation_with_input_config(config_upload, scaffold_upload num_batches, num_designs_per_batch, extra_args)
|
| 117 |
return gen_directory, gen_results
|
| 118 |
if config_ready=="upload" and scaffold_ready=="upload":
|
| 119 |
+
gen_directory, gen_results = generation_with_input_config(config_upload, scaffold_upload, num_batches, num_designs_per_batch, extra_args)
|
| 120 |
return gen_directory, gen_results
|
| 121 |
else:
|
| 122 |
return None, None
|
| 123 |
|
| 124 |
run_btn.click(give_run_status, inputs=[config_ready, scaffold_ready, num_batches, num_designs_per_batch, config_upload, scaffold_upload], outputs=runtextbox).then(
|
| 125 |
+
generate, inputs=[config_ready, scaffold_ready, config_upload, scaffold_upload, num_batches, num_designs_per_batch, extra_args], outputs=[gen_directory, gen_results]
|
| 126 |
).then(
|
| 127 |
update_batch_choices,
|
| 128 |
inputs=gen_results,
|
utils/pipelines.py
CHANGED
|
@@ -8,6 +8,7 @@ import subprocess
|
|
| 8 |
import gzip
|
| 9 |
from utils.handle_files import *
|
| 10 |
import sys
|
|
|
|
| 11 |
|
| 12 |
@spaces.GPU(duration=300)
|
| 13 |
def test_rfd3_from_notebook():
|
|
@@ -99,7 +100,7 @@ def unconditional_generation(num_batches, num_designs_per_batch, length):
|
|
| 99 |
raise RuntimeError(f"Error during generation: {str(e)}")
|
| 100 |
|
| 101 |
@spaces.GPU(duration=300)
|
| 102 |
-
def generation_with_input_config(input_file, num_batches, num_designs_per_batch, extra_args):
|
| 103 |
"""
|
| 104 |
Runs an unconditional generation with the specified input config file. Saves the generated structures to a timestamped directory in the outputs folder and returns the path to the directory along with a list of the generated structures' file paths.
|
| 105 |
|
|
@@ -107,6 +108,8 @@ def generation_with_input_config(input_file, num_batches, num_designs_per_batch,
|
|
| 107 |
----------
|
| 108 |
input_file: gr.File,
|
| 109 |
gr.File object containing the uploaded config file (yaml or json). input_file.name is the path to the uploaded file on the server.
|
|
|
|
|
|
|
| 110 |
|
| 111 |
Returns:
|
| 112 |
-------
|
|
@@ -123,8 +126,16 @@ def generation_with_input_config(input_file, num_batches, num_designs_per_batch,
|
|
| 123 |
os.makedirs(directory, exist_ok=False)
|
| 124 |
|
| 125 |
try:
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
if extra_args:
|
| 129 |
command += f" {extra_args}"
|
| 130 |
print(f"Running command: {command}")
|
|
|
|
| 8 |
import gzip
|
| 9 |
from utils.handle_files import *
|
| 10 |
import sys
|
| 11 |
+
import shutil
|
| 12 |
|
| 13 |
@spaces.GPU(duration=300)
|
| 14 |
def test_rfd3_from_notebook():
|
|
|
|
| 100 |
raise RuntimeError(f"Error during generation: {str(e)}")
|
| 101 |
|
| 102 |
@spaces.GPU(duration=300)
|
| 103 |
+
def generation_with_input_config(input_file, pdb_file, num_batches, num_designs_per_batch, extra_args):
|
| 104 |
"""
|
| 105 |
Runs an unconditional generation with the specified input config file. Saves the generated structures to a timestamped directory in the outputs folder and returns the path to the directory along with a list of the generated structures' file paths.
|
| 106 |
|
|
|
|
| 108 |
----------
|
| 109 |
input_file: gr.File,
|
| 110 |
gr.File object containing the uploaded config file (yaml or json). input_file.name is the path to the uploaded file on the server.
|
| 111 |
+
pdb_file: gr.File,
|
| 112 |
+
gr.File object containing the uploaded pdb file for conditioning the generation.
|
| 113 |
|
| 114 |
Returns:
|
| 115 |
-------
|
|
|
|
| 126 |
os.makedirs(directory, exist_ok=False)
|
| 127 |
|
| 128 |
try:
|
| 129 |
+
if pdb_file is not None:
|
| 130 |
+
# I need to do this because uploading files to a HF space stores each file in a separate temp directory so I need to copy them again to the same place.
|
| 131 |
+
shared_dir = os.mkdir(f"uploads/{time_stamp}_{session_hash}")
|
| 132 |
+
copied_config_file = os.path.join(shared_dir, os.path.basename(input_file))
|
| 133 |
+
shutil.copy2(input_file, copied_config_file)
|
| 134 |
+
copied_pdb_file = os.path.join(shared_dir, os.path.basename(pdb_file))
|
| 135 |
+
shutil.copy2(pdb_file, copied_pdb_file)
|
| 136 |
+
command = f"rfd3 design inputs={copied_config_file} out_dir={directory} n_batches={num_batches} diffusion_batch_size={num_designs_per_batch}"
|
| 137 |
+
else:
|
| 138 |
+
command = f"rfd3 design inputs={input_file} out_dir={directory} n_batches={num_batches} diffusion_batch_size={num_designs_per_batch}"
|
| 139 |
if extra_args:
|
| 140 |
command += f" {extra_args}"
|
| 141 |
print(f"Running command: {command}")
|