22
33import json
44import os
5- import shutil
65import sqlite3
76import subprocess
87from pathlib import Path
@@ -95,7 +94,7 @@ def run(self):
9594 )
9695 self .log .info (e .stdout )
9796 self .log .error (e .stderr )
98- self .send_attachments_to_ispyb (attachments , final_directory )
97+ self .send_attachments_to_ispyb (attachments )
9998 return False
10099
101100 restraints = compound_dir / f"{ CompoundCode } .restraints.cif"
@@ -152,7 +151,7 @@ def run(self):
152151 stderr .write (e .stderr )
153152
154153 attachments .extend ([out_dir / "stderr.out" ])
155- self .send_attachments_to_ispyb (attachments , final_directory )
154+ self .send_attachments_to_ispyb (attachments )
156155 return False
157156
158157 self .log .info (f"Pipedream finished successfully for dtag { dtag } " )
@@ -194,7 +193,7 @@ def run(self):
194193 )
195194 except Exception as e :
196195 self .log .info (f"Can't continue with pipedream postprocessing: { e } " )
197- self .send_attachments_to_ispyb (attachments , final_directory )
196+ self .send_attachments_to_ispyb (attachments )
198197 return True
199198
200199 # Post-processing: Generate maps and run edstats
@@ -206,7 +205,7 @@ def run(self):
206205 os .system (f"gemmi sf2map --sample 5 { str (refine_mtz )} { map_fofc } 2>&1" )
207206 except Exception as e :
208207 self .log .debug (f"Cannot continue with pipedream postprocessing: { e } " )
209- self .send_attachments_to_ispyb (attachments , final_directory )
208+ self .send_attachments_to_ispyb (attachments )
210209 return True
211210
212211 try :
@@ -229,15 +228,15 @@ def run(self):
229228 self .log .debug (
230229 "Can't continue with pipedream postprocessing: resolution range None"
231230 )
232- self .send_attachments_to_ispyb (attachments , final_directory )
231+ self .send_attachments_to_ispyb (attachments )
233232 return True
234233
235234 # Run edstats if both maps exist and resolution range is found
236235 if not map_2fofc .exists () or not map_fofc .exists ():
237236 self .log .debug (
238237 "Can't continue with pipedream postprocessing: maps not found"
239238 )
240- self .send_attachments_to_ispyb (attachments , final_directory )
239+ self .send_attachments_to_ispyb (attachments )
241240 return True
242241
243242 edstats_out = postrefine_dir / "edstats.out"
@@ -258,13 +257,13 @@ def run(self):
258257 self .log .error (f"Edstats command: '{ edstats_command } ' failed" )
259258 self .log .info (e .stdout )
260259 self .log .error (e .stderr )
261- self .send_attachments_to_ispyb (attachments , final_directory )
260+ self .send_attachments_to_ispyb (attachments )
262261 return True
263262
264263 self .log .info (f"Pipedream postprocessing finished successfully for dtag { dtag } " )
265264
266265 attachments .extend ([edstats_out ])
267- self .send_attachments_to_ispyb (attachments , final_directory )
266+ self .send_attachments_to_ispyb (attachments )
268267 return True
269268
270269 def process_pdb_file (self , dimple_pdb : Path ):
@@ -355,7 +354,7 @@ def save_dataset_metadata(
355354 with open (json_file , "w" , encoding = "utf-8" ) as f :
356355 json .dump (data , f , indent = 2 )
357356
358- def send_attachments_to_ispyb (self , attachments , final_directory ):
357+ def send_attachments_to_ispyb (self , attachments ):
359358 for f in attachments :
360359 if f .exists ():
361360 if f .suffix == ".html" :
@@ -382,9 +381,8 @@ def send_attachments_to_ispyb(self, attachments, final_directory):
382381 else :
383382 continue
384383 try :
385- shutil .copy (f , final_directory )
386384 result_dict = {
387- "file_path" : str (final_directory ),
385+ "file_path" : str (f . parents [ 0 ] ),
388386 "file_name" : f .name ,
389387 "file_type" : file_type ,
390388 "importance_rank" : importance_rank ,
0 commit comments