-
Notifications
You must be signed in to change notification settings - Fork 15
Auto autoproc #409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Auto autoproc #409
Changes from all commits
618323f
e0f1aef
fc50737
bbbbb33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,9 +2,11 @@ | |
| import os | ||
| import sys | ||
| import db_lib | ||
| from daq_utils import getBlConfig | ||
| from daq_utils import getBlConfig, setBlConfig | ||
| import xmltodict | ||
| import json | ||
| import logging | ||
| import subprocess | ||
| logger = logging.getLogger() | ||
| logging.getLogger().setLevel(logging.INFO) | ||
| handler1 = logging.FileHandler('fast_dp.txt') | ||
|
|
@@ -32,26 +34,59 @@ | |
| runDimple = int(sys.argv[6]) | ||
| dimpleNode = sys.argv[7] | ||
| ispybDCID = 1 #int(sys.argv[8]) | ||
| runAutoProc = int(sys.argv[9]) | ||
| # runAutoProc = 0 | ||
|
|
||
| comm_s = f"ssh -q {node} \"{os.environ['MXPROCESSINGSCRIPTSDIR']}fast_dp.sh {request_id} {numstart}\"" | ||
| logger.info(comm_s) | ||
| os.system(comm_s) | ||
| try: | ||
| 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(f"finished fast_dp {request_id}") | ||
| resultID = db_lib.addResultforRequest("fastDP",request_id,owner,resultObj,beamline=os.environ["BEAMLINE_ID"]) | ||
| newResult = db_lib.getResult(resultID) | ||
| visitName = getBlConfig("visitName") | ||
| except Exception as e: | ||
| logger.error("runfastdph5 error running fastdp: %s" % e) | ||
|
|
||
| fastDPResultFile = runningDir+"/fast_dp.xml" | ||
| fd = open(fastDPResultFile) | ||
| resultObj = xmltodict.parse(fd.read()) | ||
| logger.info(f"finished fast_dp {request_id}") | ||
| 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) | ||
| try: | ||
| 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) | ||
| subprocess.Popen(comm_s, shell=True) | ||
| except Exception as e: | ||
| logger.error("runfastdph5 error running dimple: %s" % e) | ||
|
|
||
| if runAutoProc: | ||
| logger.info("Running AUTO-AUTOPROC...") | ||
| setBlConfig("auto_proc_lock", True) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you find that this locking was necessary to prevent breaking the queue? |
||
| try: | ||
| queue = getBlConfig("auto_proc_queue") | ||
| queue.append((directory, request_id)) | ||
| setBlConfig("auto_proc_queue", queue) | ||
| except Exception as e: | ||
| logger.exception("Could not add request to autoproc queue") | ||
| finally: | ||
| setBlConfig("auto_proc_lock", False) | ||
| start_in_proc = None | ||
| autoproc_processor_list = json.loads(getBlConfig("autoprocNodes")) | ||
| for proc_num in autoproc_processor_list: | ||
| if not getBlConfig(proc_num): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the BlConfig flag for All the more reason to make sure the changes related to autoproc are put into a PR for lsdc_processing! |
||
| start_in_proc = proc_num | ||
| break | ||
| if start_in_proc: | ||
| comm_s = f"ssh {start_in_proc} \"nohup {os.environ['MXPROCESSINGSCRIPTSDIR']}autoproc.sh {start_in_proc} {os.environ['BEAMLINE_ID']} & \" " | ||
| logger.info(f"Initializing AUTO-AUTOPROC {comm_s} \n In ({directory}, {request_id})") | ||
| subprocess.Popen(comm_s, shell=True) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be moved somewhere so that the file does not have to be json.loaded every time the check is performed?