26 from __future__
import print_function, division
28 from lalpulsar
import knope_utils
as knope
30 from six.moves.configparser
import ConfigParser
34 description =
"""Setup a Condor DAG file to run the known pulsar search pipeline based on information given in config.ini.
35 The user must specify the configuration file for the script to run.
38 parser = argparse.ArgumentParser(description=description)
41 "inifile", help=
"The configuation (.ini) file"
47 help=
"Automatically submit the Condor DAG",
54 help=
"Set the directory to run the pipeline in (overwrites any value in the config.ini file)",
62 help=
"A pulsar name to search for rather than all pulsars given in a parameter file directory (this can be specified multiple times to search for more than one pulsar).",
65 opts = parser.parse_args()
68 inifile = opts.inifile
74 cp.readfp(open(inifile))
76 print(
"Error... problem parsing '%s' configuration file" % inifile, file=sys.stderr)
79 if opts.runpath
is not None:
80 cp.set(
"analysis",
"run_dir", opts.runpath)
84 automated = cp.getboolean(
"analysis",
"autonomous")
89 submitdag = opts.condor_submit
92 submitdag = cp.getboolean(
"analysis",
"submit_dag")
97 dag = knope.knopeDAG(cp, inifile, pulsarlist=opts.pulsarlist)
98 if dag.error_code != 0:
99 if dag.error_code
in knope.KNOPE_ERROR.keys():
100 print(knope.KNOPE_ERROR[dag.error_code], file=sys.stderr)
102 print(
"Error... unrecognised error code!", file=sys.stderr)
105 if not automated
or dag.error_code != knope.KNOPE_ERROR_NO_SEGMENTS:
106 sys.exit(dag.error_code)
109 if not automated
or dag.error_code != knope.KNOPE_ERROR_NO_SEGMENTS:
110 dag.write_sub_files()
113 print(
"Successfully created DAG file: '%s'" % dag.get_dag_file())
116 from subprocess
import Popen
118 x = Popen([
"condor_submit_dag", dag.get_dag_file()])
120 if x.returncode == 0:
121 print(
"Submitted DAG file")
123 print(
"Unable to submit DAG file")
125 print(
"Run 'condor_submit_dag %s' to submit DAG file" % dag.get_dag_file())
128 if cp.has_option(
"analysis",
"pickle_file"):
130 pfile = cp.get(
"analysis",
"pickle_file")
131 fp = open(pfile,
"wb")
135 print(
"Warning... could not output analysis class to pickle file")
137 print(
"No new science segments found in current time frame")