forked from NSLS-II/lsdc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runFastDPH5.py
executable file
·57 lines (53 loc) · 1.96 KB
/
runFastDPH5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/opt/conda_envs/lsdc-server-2022-1-latest/bin/python
import os
import sys
import db_lib
from daq_utils import getBlConfig
import xmltodict
import logging
logger = logging.getLogger()
logging.getLogger().setLevel(logging.INFO)
handler1 = logging.FileHandler('fast_dp.txt')
myformat = logging.Formatter('%(asctime)s %(name)-8s %(levelname)-8s %(message)s')
handler1.setFormatter(myformat)
logger.addHandler(handler1)
try:
import ispybLib
except Exception as e:
logger.error("runFastDPH5: ISPYB import error, %s" % e)
baseDirectory = os.environ["PWD"]
directory = sys.argv[1]
runningDir = directory+"/fastDPOutput"
comm_s = "mkdir -p " + runningDir
os.system(comm_s)
os.chdir(runningDir) #maybe not needed
numstart = int(float(sys.argv[2]))
request_id = sys.argv[3]
request=db_lib.getRequestByID(request_id) #add another argument false to allow finished requests to be retrieved for testing
owner=request["owner"]
runFastEP = int(sys.argv[4])
node = sys.argv[5]
runDimple = int(sys.argv[6])
dimpleNode = sys.argv[7]
ispybDCID = int(sys.argv[8])
comm_s = f"ssh -q {node} \"{os.environ['MXPROCESSINGSCRIPTSDIR']}fast_dp.sh {request_id} {numstart}\""
logger.info(comm_s)
os.system(comm_s)
fastDPResultFile = runningDir+"/fast_dp.xml"
fd = open(fastDPResultFile)
resultObj = xmltodict.parse(fd.read())
logger.info("finished fast_dp")
resultID = db_lib.addResultforRequest("fastDP",request_id,owner,resultObj,beamline=os.environ["BEAMLINE_ID"])
newResult = db_lib.getResult(resultID)
visitName = getBlConfig("visitName")
try:
ispybLib.insertResult(newResult,"fastDP",request,visitName,ispybDCID,fastDPResultFile)
except Exception as e:
logger.error("runfastdph5 insert result ispyb error: %s" % e)
if (runFastEP):
os.system("fast_ep") #looks very bad! running on ca1!
if (runDimple):
dimpleComm = getBlConfig("dimpleComm")
comm_s = f"ssh -q {dimpleNode} \"{os.environ['MXPROCESSINGSCRIPTSDIR']}dimple.sh {request_id} {numstart}\""
logger.info(f"running dimple: {comm_s}")
os.system(comm_s)