5 from lalinference
import lalinference_pipe_utils
as pipe_utils
6 from six.moves
import configparser
7 from optparse
import OptionParser
10 usage=
""" %prog [options] config1.ini config2.ini ... configN.ini
11 Setup a Condor DAG file to run the LALInference pipeline based on
14 The user must specify either an injection file to analyse, with the --inj option,
15 a list of SnglInspiralTable or CoincInspiralTable triggers with the --<x>-triggers options,
16 or an ASCII list of GPS times with the --gps-time-file option.
18 The user must also specify and ini file which will contain the main analysis config.
32 for arg
in parser.rargs:
34 if arg[:2] ==
"--" and len(arg) > 2:
37 if arg[:1] ==
"-" and len(arg) > 1
and not floatable(arg):
40 del parser.rargs[:len(value)]
41 setattr(parser.values, option.dest, value)
43 parser=OptionParser(usage)
44 parser.add_option(
"-r",
"--run-path",default=
None,action=
"store",type=
"string",help=
"Directory to run pipeline in (default: $PWD)",metavar=
"RUNDIR")
45 parser.add_option(
"-p",
"--daglog-path",default=
None,action=
"store",type=
"string",help=
"Path to directory to contain DAG log file. SHOULD BE LOCAL TO SUBMIT NODE",metavar=
"LOGDIR")
46 parser.add_option(
"-g",
"--gps-time-file",action=
"store",type=
"string",default=
None,help=
"Text file containing list of GPS times to analyse",metavar=
"TIMES.txt")
47 parser.add_option(
"-t",
"--single-triggers",action=
"store",type=
"string",default=
None,help=
"SnglInspiralTable trigger list",metavar=
"SNGL_FILE.xml")
48 parser.add_option(
"-C",
"--coinc-triggers",action=
"store",type=
"string",default=
None,help=
"CoinInspiralTable trigger list",metavar=
"COINC_FILE.xml")
49 parser.add_option(
"-L",
"--lvalert",action=
"store",type=
"string",default=
None,help=
"LVAlert coinc file",metavar=
"coinc_G0000.xml")
50 parser.add_option(
"--gid",action=
"store",type=
"string",default=
None,help=
"Optional GraceDB ID for submitting results")
51 parser.add_option(
"-I",
"--injections",action=
"store",type=
"string",default=
None,help=
"List of injections to perform and analyse",metavar=
"INJFILE.xml")
52 parser.add_option(
"-P",
"--pipedown-db",action=
"store",type=
"string",default=
None,help=
"Pipedown database to read and analyse",metavar=
"pipedown.sqlite")
53 parser.add_option(
"-F",
"--folder-names",dest=
"fnames",action=
"callback", callback=vararg_callback,help=
"Space separated list of folders that will be created, corresponding to the TIGER parameters that are being tested or GR. The order has to be the same used with the ini files!",default=
None,metavar=
"GR phi1")
54 parser.add_option(
"--condor-submit",action=
"store_true",default=
False,help=
"Automatically submit the condor dag")
56 (opts,args)=parser.parse_args()
59 print(
'Using %s ini files\n'%len(args))
68 if not ninits==nfnames:
69 print(
"You seem to be using %d parser files and %d foldernames. These two numbers must be the same. Exiting...\n"%(ninits,nfnames))
74 fnames_dic[fnames.index(fname)]=
str(fname)
82 cp=configparser.ConfigParser()
86 common_path=opts.run_path
90 cp.read_file(open(inifile))
91 except AttributeError:
92 cp.readfp(open(inifile))
93 if opts.run_path
is not None:
94 cp.set(
'paths',
'basedir',opts.run_path)
95 if opts.daglog_path
is not None:
96 cp.set(
'paths',
'daglogdir',opts.daglog_path)
98 cp.set(
'paths',
'daglogdir',opts.run_path)
99 if opts.gps_time_file
is not None:
100 cp.set(
'input',
'gps-time-file',opts.gps_time_file)
101 if opts.single_triggers
is not None:
102 cp.set(
'input',
'sngl-inspiral-file',opts.single_triggers)
103 if opts.injections
is not None:
104 cp.set(
'input',
'injection-file',opts.injections)
105 if opts.coinc_triggers
is not None:
106 cp.set(
'input',
'coinc-inspiral-file',opts.coinc_triggers)
107 if opts.lvalert
is not None:
108 cp.set(
'input',
'lvalert-file',opts.lvalert)
109 if opts.gid
is not None:
110 cp.set(
'input',
'gid',opts.gid)
111 if opts.pipedown_db
is not None:
112 cp.set(
'input',
'pipedown-db',opts.pipedown_db)
114 if opts.run_path
is not None:
115 cp.set(
'paths',
'basedir',os.path.join(
str(common_path),
str(fnames_dic[inits.index(inifile)])))
118 dag=pipe_utils.LALInferencePipelineDAG(cp)
120 dag.write_sub_files()
123 dag2=pipe_utils.LALInferencePipelineDAG(cp,first_dag=
False,previous_dag=dag)
124 dag2.write_sub_files()
128 dag2.set_dag_file(os.path.join(common_path,
'common_dag'))
132 print(
'Successfully created DAG file.')
133 print(
'Now run condor_submit_dag %s\n'%(dag2.get_dag_file()))
135 if opts.condor_submit:
138 x = subprocess.Popen([
'condor_submit_dag',dag.get_dag_file()])
141 print(
'Submitted DAG file')
143 print(
'Unable to submit DAG file')
def vararg_callback(option, opt_str, value, parser)