Skip to content

Commit d892e87

Browse files
committed
Smarter timeouts for trigger_xchem
1 parent 8aec5ed commit d892e87

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/dlstbx/services/trigger_xchem.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class PanDDAParameters(pydantic.BaseModel):
5656
timeout: float = pydantic.Field(default=60, alias="timeout-minutes")
5757
backoff_delay: float = pydantic.Field(default=45, alias="backoff-delay")
5858
backoff_max_try: int = pydantic.Field(default=30, alias="backoff-max-try")
59-
backoff_multiplier: float = pydantic.Field(default=1.0, alias="backoff-multiplier")
59+
backoff_multiplier: float = pydantic.Field(default=1.1, alias="backoff-multiplier")
6060

6161

6262
class PanDDA_PostParameters(pydantic.BaseModel):
@@ -259,7 +259,9 @@ def trigger_pandda_xchem(
259259
db_path = str(
260260
subdir / "processing/database" / "soakDBDataFile.sqlite"
261261
)
262-
con = sqlite3.connect(db_path)
262+
con = sqlite3.connect(
263+
f"file:{db_path}?mode=ro", uri=True, timeout=20
264+
)
263265
cur = con.cursor()
264266
cur.execute("SELECT Protein FROM soakDB")
265267
name = cur.fetchone()[0]
@@ -282,8 +284,8 @@ def trigger_pandda_xchem(
282284
match_dir = subdir
283285
# match_yaml = expt_yaml
284286

285-
except Exception:
286-
print(f"Unable to read .sqlite database for {subdir}")
287+
except Exception as e:
288+
print(f"Problem reading .sqlite database for {subdir}: {e}")
287289

288290
xchem_visit_dir = match_dir
289291
# user_settings = match_yaml["autoprocessing"]
@@ -336,7 +338,7 @@ def trigger_pandda_xchem(
336338
return {"success": True}
337339

338340
# If other dimple/PanDDA2 job is running, quit, dimple set to trigger even if it fails
339-
min_start_time = datetime.now() - timedelta(hours=12)
341+
min_start_time = datetime.now() - timedelta(hours=6)
340342

341343
query = (
342344
(
@@ -364,7 +366,7 @@ def trigger_pandda_xchem(
364366
return {"success": True}
365367

366368
# Stop-gap
367-
min_start_time = datetime.now() - timedelta(minutes=20)
369+
min_start_time = datetime.now() - timedelta(minutes=30)
368370

369371
query = (
370372
(
@@ -386,6 +388,7 @@ def trigger_pandda_xchem(
386388
return {"success": True}
387389

388390
# Now check if other upstream pipeline is running and if so, checkpoint (it might fail)
391+
min_start_time = datetime.now() - timedelta(hours=3)
389392
query = (
390393
(
391394
session.query(AutoProcProgram, ProcessingJob.dataCollectionId).join(
@@ -550,7 +553,9 @@ def trigger_pandda_xchem(
550553
return {"success": True}
551554

552555
chosen_dataset_path = df3["filePath"][0]
553-
self.log.debug(f"Chosen dataset to take forward: {chosen_dataset_path}")
556+
self.log.debug(
557+
f"Chosen dataset to take forward: {chosen_dataset_path} for dcid {dcid}"
558+
)
554559
scaling_id = int(df3["autoProcScalingId"][0])
555560
pdb = chosen_dataset_path + "/final.pdb"
556561
mtz = chosen_dataset_path + "/final.mtz"
@@ -573,13 +578,13 @@ def trigger_pandda_xchem(
573578

574579
# Read XChem SQLite for ligand info
575580
try:
576-
conn = sqlite3.connect(f"file:{db}?mode=ro", uri=True)
581+
conn = sqlite3.connect(f"file:{db}?mode=ro", uri=True, timeout=20)
577582
df = pd.read_sql_query(
578583
f"SELECT * from mainTable WHERE Puck = '{code}' AND PuckPosition = {location} AND CrystalName = '{dtag}'",
579584
conn,
580585
)
581586

582-
except sqlite3.OperationalError as e:
587+
except Exception as e:
583588
self.log.info(
584589
f"Exception whilst reading ligand information from {db} for dtag {dtag}: {e}"
585590
)

0 commit comments

Comments
 (0)