Samad14 commited on
Commit
583edb0
·
1 Parent(s): 32957ff

test: vimontest runs Vina with 10s timeout to diagnose hangs

Browse files
bioai-platform/backend/app/routers/docking.py CHANGED
@@ -151,10 +151,26 @@ async def vina_montest():
151
  lig_pdbqt = os.path.join(tdir, "lig.pdbqt")
152
  with open(lig_pdbqt, "w") as f: f.write(pdbqt_content)
153
 
154
- # step 3: test vina --version (binary works)
155
- r = subprocess.run([VINA_CMD, "--version"], capture_output=True, timeout=10)
156
- steps["vina_version"] = r.stdout.decode(errors="replace").strip()
157
- steps["rc"] = r.returncode
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  except Exception as e:
159
  steps["error"] = repr(e)
160
  finally:
 
151
  lig_pdbqt = os.path.join(tdir, "lig.pdbqt")
152
  with open(lig_pdbqt, "w") as f: f.write(pdbqt_content)
153
 
154
+ # step 3: test vina run with short timeout (should timeout)
155
+ rec_pdb = os.path.join(tdir, "rec.pdb")
156
+ with open(rec_pdb, "w") as f: f.write(cleaned)
157
+ out_pdbqt = os.path.join(tdir, "out.pdbqt")
158
+ start = time.time()
159
+ try:
160
+ r = subprocess.run(
161
+ [VINA_CMD, "--receptor", rec_pdb, "--ligand", lig_pdbqt,
162
+ "--out", out_pdbqt, "--center_x", "0", "--center_y", "0",
163
+ "--center_z", "0", "--size_x", "20", "--size_y", "20",
164
+ "--size_z", "20", "--exhaustiveness", "1", "--num_modes", "1"],
165
+ capture_output=True, timeout=10,
166
+ )
167
+ steps["vina_rc"] = r.returncode
168
+ steps["vina_out"] = r.stdout.decode(errors="replace")[:500]
169
+ steps["vina_err"] = r.stderr.decode(errors="replace")[:500]
170
+ except subprocess.TimeoutExpired:
171
+ steps["timeout_after"] = round(time.time() - start, 1)
172
+ steps["vina_rc"] = "TIMEOUT"
173
+ steps["elapsed"] = round(time.time() - start, 2)
174
  except Exception as e:
175
  steps["error"] = repr(e)
176
  finally: