simonduerr
commited on
Update inference_app.py
Browse files- inference_app.py +37 -12
inference_app.py
CHANGED
@@ -104,6 +104,30 @@ def get_metrics(
|
|
104 |
columns=mapping,
|
105 |
inplace=True,
|
106 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
end_time = time.time()
|
108 |
run_time = end_time - start_time
|
109 |
return gr.DataFrame(metrics, visible=True), run_time
|
@@ -138,23 +162,24 @@ def get_metrics_pinder(
|
|
138 |
metrics = pd.DataFrame([failed_metrics])
|
139 |
metrics["system"] = native.stem
|
140 |
gr.Error(f"Failed to evaluate prediction [{prediction}]:\n{e}")
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
API.upload_file(
|
145 |
-
path_or_fileobj=
|
146 |
path_in_repo=f"{dataset}/{methodname}/{system_id}/",
|
147 |
repo_id=QUEUE_REPO,
|
148 |
repo_type="dataset",
|
149 |
commit_message=f"Add {model_name} to eval queue",
|
150 |
)
|
151 |
-
API.upload_file(
|
152 |
-
path_or_fileobj=complex_file.name,
|
153 |
-
path_in_repo=f"{dataset}/{methodname}/{system_id}/",
|
154 |
-
repo_id=QUEUE_REPO,
|
155 |
-
repo_type="dataset",
|
156 |
-
commit_message=f"Add {model_name} to eval queue",
|
157 |
-
)
|
158 |
end_time = time.time()
|
159 |
run_time = end_time - start_time
|
160 |
return gr.DataFrame(metrics, visible=True), run_time
|
@@ -220,7 +245,7 @@ with gr.Blocks() as app:
|
|
220 |
|
221 |
eval_btn.click(
|
222 |
get_metrics,
|
223 |
-
inputs=[input_system_id, input_receptor_file, input_ligand_file, flexible, posebusters],
|
224 |
outputs=[metric_table, eval_run_time],
|
225 |
)
|
226 |
eval_btn_pinder.click(
|
|
|
104 |
columns=mapping,
|
105 |
inplace=True,
|
106 |
)
|
107 |
+
if store:
|
108 |
+
with tempfile.NamedTemporaryFile as temp:
|
109 |
+
metrics.to_csv(temp.name)
|
110 |
+
API.upload_file(
|
111 |
+
path_or_fileobj=temp.name,
|
112 |
+
path_in_repo=f"{dataset}/{methodname}/{system_id}/",
|
113 |
+
repo_id=QUEUE_REPO,
|
114 |
+
repo_type="dataset",
|
115 |
+
commit_message=f"Add {model_name} to eval queue",
|
116 |
+
)
|
117 |
+
API.upload_file(
|
118 |
+
path_or_fileobj=receptor_file.name,
|
119 |
+
path_in_repo=f"{dataset}/{methodname}/{system_id}/",
|
120 |
+
repo_id=QUEUE_REPO,
|
121 |
+
repo_type="dataset",
|
122 |
+
commit_message=f"Add {model_name} to eval queue",
|
123 |
+
)
|
124 |
+
API.upload_file(
|
125 |
+
path_or_fileobj=ligand_file.name,
|
126 |
+
path_in_repo=f"{dataset}/{methodname}/{system_id}/",
|
127 |
+
repo_id=QUEUE_REPO,
|
128 |
+
repo_type="dataset",
|
129 |
+
commit_message=f"Add {model_name} to eval queue",
|
130 |
+
)
|
131 |
end_time = time.time()
|
132 |
run_time = end_time - start_time
|
133 |
return gr.DataFrame(metrics, visible=True), run_time
|
|
|
162 |
metrics = pd.DataFrame([failed_metrics])
|
163 |
metrics["system"] = native.stem
|
164 |
gr.Error(f"Failed to evaluate prediction [{prediction}]:\n{e}")
|
165 |
+
if store:
|
166 |
+
# Upload to hub
|
167 |
+
with tempfile.NamedTemporaryFile as temp:
|
168 |
+
metrics.to_csv(temp.name)
|
169 |
+
API.upload_file(
|
170 |
+
path_or_fileobj=temp.name,
|
171 |
+
path_in_repo=f"{dataset}/{methodname}/{system_id}/",
|
172 |
+
repo_id=QUEUE_REPO,
|
173 |
+
repo_type="dataset",
|
174 |
+
commit_message=f"Add {model_name} to eval queue",
|
175 |
+
)
|
176 |
API.upload_file(
|
177 |
+
path_or_fileobj=complex_file.name,
|
178 |
path_in_repo=f"{dataset}/{methodname}/{system_id}/",
|
179 |
repo_id=QUEUE_REPO,
|
180 |
repo_type="dataset",
|
181 |
commit_message=f"Add {model_name} to eval queue",
|
182 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
end_time = time.time()
|
184 |
run_time = end_time - start_time
|
185 |
return gr.DataFrame(metrics, visible=True), run_time
|
|
|
245 |
|
246 |
eval_btn.click(
|
247 |
get_metrics,
|
248 |
+
inputs=[input_system_id, input_receptor_file, input_ligand_file, flexible, posebusters, methodname, store],
|
249 |
outputs=[metric_table, eval_run_time],
|
250 |
)
|
251 |
eval_btn_pinder.click(
|