Spaces:
Running on Zero
Running on Zero
change layout for number of batches and designs
Browse files- app.py +21 -18
- utils/handle_events.py +5 -11
app.py
CHANGED
|
@@ -48,6 +48,19 @@ with gr.Blocks(title="RFD3 Test") as demo:
|
|
| 48 |
with gr.Column(scale=1): # Left half
|
| 49 |
gr.Markdown("Set up the configuration for your run through a valid yaml file. Choose the number of batches and designs per batch for your run.")
|
| 50 |
config_upload = gr.File(label="Config file: .yaml or .json", file_types=[".pdb", ".yaml", ".json"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
num_designs_per_batch = gr.Number(
|
| 52 |
value=2,
|
| 53 |
label="Number of Designs per Batch",
|
|
@@ -63,30 +76,20 @@ with gr.Blocks(title="RFD3 Test") as demo:
|
|
| 63 |
maximum=10
|
| 64 |
)
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
lines=3,
|
| 74 |
-
info="Add extra RFD3 CLI arguments here (optional)"
|
| 75 |
-
)
|
| 76 |
|
| 77 |
-
with gr.Column(scale=1): # Right half
|
| 78 |
-
gr.Markdown("Upload your target/scaffold structure as a PDB file to condition the generation. Press 'No Scaffold/Target' if you want to run an unconditional generation.")
|
| 79 |
-
scaffold_upload = gr.File(label="Target/Scaffold PDB", file_types=[".pdb"])
|
| 80 |
-
with gr.Row():
|
| 81 |
-
scaffold_validation_btn = gr.Button("Validate Scaffold")
|
| 82 |
-
no_input_btn = gr.Button("No Scaffold/Target")
|
| 83 |
-
scaffold_textbox = gr.Textbox(label="Scaffold/Target status", value ="Waiting for scaffold validation...")
|
| 84 |
run_btn = gr.Button("Run Generation", variant="primary")
|
| 85 |
runtextbox = gr.Textbox(label="Run status", value="Waiting for generation run...")
|
| 86 |
|
| 87 |
|
| 88 |
# validate the configuration
|
| 89 |
-
config_validation_btn.click(validate_config_ready, inputs=
|
| 90 |
scaffold_validation_btn.click(validate_scaffold_ready_with_file, inputs=scaffold_upload, outputs=[scaffold_textbox, scaffold_ready])
|
| 91 |
no_input_btn.click(lambda: ("No scaffold/target will be used. Ready for unconditional generation!", "no_input"), outputs=[scaffold_textbox, scaffold_ready])
|
| 92 |
|
|
|
|
| 48 |
with gr.Column(scale=1): # Left half
|
| 49 |
gr.Markdown("Set up the configuration for your run through a valid yaml file. Choose the number of batches and designs per batch for your run.")
|
| 50 |
config_upload = gr.File(label="Config file: .yaml or .json", file_types=[".pdb", ".yaml", ".json"])
|
| 51 |
+
config_validation_btn = gr.Button("Validate Config")
|
| 52 |
+
config_textbox = gr.Textbox(label="Configuration status", value ="Waiting for config validation...")
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
with gr.Column(scale=1): # Right half
|
| 56 |
+
gr.Markdown("Upload your target/scaffold structure as a PDB file to condition the generation. Press 'No Scaffold/Target' if you want to run an unconditional generation.")
|
| 57 |
+
scaffold_upload = gr.File(label="Target/Scaffold PDB", file_types=[".pdb"])
|
| 58 |
+
with gr.Row():
|
| 59 |
+
scaffold_validation_btn = gr.Button("Validate Scaffold")
|
| 60 |
+
no_input_btn = gr.Button("No Scaffold/Target")
|
| 61 |
+
scaffold_textbox = gr.Textbox(label="Scaffold/Target status", value ="Waiting for scaffold validation...")
|
| 62 |
+
|
| 63 |
+
with gr.Row():
|
| 64 |
num_designs_per_batch = gr.Number(
|
| 65 |
value=2,
|
| 66 |
label="Number of Designs per Batch",
|
|
|
|
| 76 |
maximum=10
|
| 77 |
)
|
| 78 |
|
| 79 |
+
with gr.Accordion(label="Advanced Options", open=False):
|
| 80 |
+
extra_args = gr.Textbox(
|
| 81 |
+
label="Additional CLI Arguments",
|
| 82 |
+
placeholder="e.g., inference_sampler.step_scale=3 inference_sampler.gamma_0=0.2",
|
| 83 |
+
lines=3,
|
| 84 |
+
info="Add extra RFD3 CLI arguments here (optional)"
|
| 85 |
+
)
|
|
|
|
|
|
|
|
|
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
run_btn = gr.Button("Run Generation", variant="primary")
|
| 88 |
runtextbox = gr.Textbox(label="Run status", value="Waiting for generation run...")
|
| 89 |
|
| 90 |
|
| 91 |
# validate the configuration
|
| 92 |
+
config_validation_btn.click(validate_config_ready, inputs=config_upload, outputs=[config_textbox, config_ready])
|
| 93 |
scaffold_validation_btn.click(validate_scaffold_ready_with_file, inputs=scaffold_upload, outputs=[scaffold_textbox, scaffold_ready])
|
| 94 |
no_input_btn.click(lambda: ("No scaffold/target will be used. Ready for unconditional generation!", "no_input"), outputs=[scaffold_textbox, scaffold_ready])
|
| 95 |
|
utils/handle_events.py
CHANGED
|
@@ -59,32 +59,26 @@ def show_pdb(batch, design, result):
|
|
| 59 |
print(pdb_str)
|
| 60 |
return gr.update(value=f"Selected Batch: {batch}, Design: {design}, saved at {pdb_path}:\n {pdb_str}", visible=True)
|
| 61 |
|
| 62 |
-
def validate_config_ready(config_upload
|
| 63 |
"""
|
| 64 |
Once the user presses on the Validate Config button, this function checks whether the config is really ready to go.
|
| 65 |
-
It is ready if the config file is uploaded
|
| 66 |
|
| 67 |
Parameters:
|
| 68 |
----------
|
| 69 |
|
| 70 |
config_upload: gr.File
|
| 71 |
uploaded config file, is None if no file is uploaded
|
| 72 |
-
|
| 73 |
-
number of designs per batch input by the user in the manual config.
|
| 74 |
-
num_batches: gr.Number
|
| 75 |
-
number of batches input by the user in the manual config.
|
| 76 |
|
| 77 |
Returns:
|
| 78 |
-------
|
| 79 |
str: message to the user about the status of the config validation
|
| 80 |
-
str:
|
| 81 |
"""
|
| 82 |
-
for num in [num_designs_per_batch, num_batches]:
|
| 83 |
-
if num is None:
|
| 84 |
-
return "Please fill in all the parameters for manual config to be ready for generation.", None
|
| 85 |
if config_upload is None:
|
| 86 |
return "Please upload a config file for the generation to be ready.", None
|
| 87 |
-
return "Config file uploaded
|
| 88 |
|
| 89 |
|
| 90 |
def validate_scaffold_ready_with_file(scaffold_upload):
|
|
|
|
| 59 |
print(pdb_str)
|
| 60 |
return gr.update(value=f"Selected Batch: {batch}, Design: {design}, saved at {pdb_path}:\n {pdb_str}", visible=True)
|
| 61 |
|
| 62 |
+
def validate_config_ready(config_upload):
|
| 63 |
"""
|
| 64 |
Once the user presses on the Validate Config button, this function checks whether the config is really ready to go.
|
| 65 |
+
It is ready if the config file is uploaded.
|
| 66 |
|
| 67 |
Parameters:
|
| 68 |
----------
|
| 69 |
|
| 70 |
config_upload: gr.File
|
| 71 |
uploaded config file, is None if no file is uploaded
|
| 72 |
+
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
Returns:
|
| 75 |
-------
|
| 76 |
str: message to the user about the status of the config validation
|
| 77 |
+
str: "upload" if upload, and None if config is not ready for generation.
|
| 78 |
"""
|
|
|
|
|
|
|
|
|
|
| 79 |
if config_upload is None:
|
| 80 |
return "Please upload a config file for the generation to be ready.", None
|
| 81 |
+
return "Config file uploaded!", "upload"
|
| 82 |
|
| 83 |
|
| 84 |
def validate_scaffold_ready_with_file(scaffold_upload):
|