Skip to content
Snippets Groups Projects
Commit 5840d266 authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #7352: Moved self.parset,usage(),go() to control

parent 2f84ba8d
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,18 @@ class control(StatefulRecipe):
"""
inputs = {}
def __init__(self):
self.parset = parameterset()
self.momID = 0
self.sasID = 0
def usage(self):
"""
Display usage information
"""
print >> sys.stderr, "Usage: %s <parset-file> [options]" % sys.argv[0]
return 1
def send_feedback_processing(self, feedback):
"""
Send processing feedback information back to LOFAR.
......@@ -46,8 +58,8 @@ class control(StatefulRecipe):
"lofarpipe.support.control",
"",
"Processing feedback from the pipeline framework",
momID,
sasID,
self.momID,
self.sasID,
feedback)
bus.sendmsg(msg.qpidMsg())
......@@ -64,13 +76,13 @@ class control(StatefulRecipe):
"lofarpipe.support.control",
"",
"Dataproduct feedback from the pipeline framework",
momID,
sasID,
self.momID,
self.sasID,
feedback)
bus.sendmsg(msg.qpidMsg())
def _send_feedback_status(self, status):
def _send_feedback_status(self, momID, sasID, status):
"""
Send status information back to LOFAR.
......@@ -83,8 +95,8 @@ class control(StatefulRecipe):
"lofarpipe.support.control",
"",
"Status feedback from the pipeline framework",
momID,
sasID,
self.momID,
self.sasID,
status == 0)
bus.sendmsg(msg.qpidMsg())
......@@ -97,6 +109,25 @@ class control(StatefulRecipe):
def go(self):
super(control, self).go()
# Read the parset-file that was given as input argument
try:
parset_file = os.path.abspath(self.inputs['args'][0])
except IndexError:
return self.usage()
self.parset.adoptFile(parset_file)
# Set job-name to basename of parset-file w/o extension, if it's not
# set on the command-line with '-j' or '--job-name'
if not 'job_name' in self.inputs:
self.inputs['job_name'] = (
os.path.splitext(os.path.basename(parset_file))[0]
)
# Pull several parameters from the parset
self.momID = self.parset.getString("Observation.momID", "")
self.sasID = self.parset.getString("Observation.ObsID", "")
# Start the pipeline
self.logger.info("LOFAR Pipeline (%s) starting." % self.name)
try:
self.pipeline_logic()
......
......@@ -36,19 +36,10 @@ class calibration_pipeline(control):
def __init__(self):
super(calibration_pipeline, self).__init__()
self.parset = parameterset()
self.input_data = {}
self.output_data = {}
def usage(self):
"""
Display usage
"""
print >> sys.stderr, "Usage: %s [options] <parset-file>" % sys.argv[0]
return 1
def _get_io_product_specs(self):
"""
Get input- and output-data product specifications from the
......@@ -97,27 +88,6 @@ class calibration_pipeline(control):
)
def go(self):
"""
Read the parset-file that was given as input argument, and set the
jobname before calling the base-class's `go()` method.
"""
try:
parset_file = os.path.abspath(self.inputs['args'][0])
except IndexError:
return self.usage()
self.parset.adoptFile(parset_file)
# Set job-name to basename of parset-file w/o extension, if it's not
# set on the command-line with '-j' or '--job-name'
if not self.inputs.has_key('job_name'):
self.inputs['job_name'] = (
os.path.splitext(os.path.basename(parset_file))[0])
# Call the base-class's `go()` method.
return super(calibration_pipeline, self).go()
@mail_log_on_exception
def pipeline_logic(self):
"""
......
......@@ -97,7 +97,6 @@ class imaging_pipeline(control):
Initialize member variables and call superclass init function
"""
control.__init__(self)
self.parset = parameterset()
self.input_data = DataMap()
self.target_data = DataMap()
self.output_data = DataMap()
......@@ -105,31 +104,6 @@ class imaging_pipeline(control):
self.parset_dir = None
self.mapfile_dir = None
def usage(self):
"""
Display usage information
"""
print >> sys.stderr, "Usage: %s <parset-file> [options]" % sys.argv[0]
return 1
def go(self):
"""
Read the parset-file that was given as input argument, and set the
jobname before calling the base-class's `go()` method.
"""
try:
parset_file = os.path.abspath(self.inputs['args'][0])
except IndexError:
return self.usage()
self.parset.adoptFile(parset_file)
# Set job-name to basename of parset-file w/o extension, if it's not
# set on the command-line with '-j' or '--job-name'
if not 'job_name' in self.inputs:
self.inputs['job_name'] = (
os.path.splitext(os.path.basename(parset_file))[0]
)
return super(imaging_pipeline, self).go()
@mail_log_on_exception
def pipeline_logic(self):
"""
......
......@@ -64,7 +64,6 @@ class msss_imager_pipeline(control):
Initialize member variables and call superclass init function
"""
control.__init__(self)
self.parset = parameterset()
self.input_data = DataMap()
self.target_data = DataMap()
self.output_data = DataMap()
......@@ -72,30 +71,6 @@ class msss_imager_pipeline(control):
self.parset_dir = None
self.mapfile_dir = None
def usage(self):
"""
Display usage information
"""
print >> sys.stderr, "Usage: %s <parset-file> [options]" % sys.argv[0]
return 1
def go(self):
"""
Read the parset-file that was given as input argument, and set the
jobname before calling the base-class's `go()` method.
"""
try:
parset_file = os.path.abspath(self.inputs['args'][0])
except IndexError:
return self.usage()
self.parset.adoptFile(parset_file)
# Set job-name to basename of parset-file w/o extension, if it's not
# set on the command-line with '-j' or '--job-name'
if not 'job_name' in self.inputs:
self.inputs['job_name'] = (
os.path.splitext(os.path.basename(parset_file))[0]
)
return super(msss_imager_pipeline, self).go()
@mail_log_on_exception
def pipeline_logic(self):
......
......@@ -48,19 +48,10 @@ class msss_calibrator_pipeline(control):
def __init__(self):
control.__init__(self)
self.parset = parameterset()
self.input_data = {}
self.output_data = {}
def usage(self):
"""
Display usage
"""
print >> sys.stderr, "Usage: %s [options] <parset-file>" % sys.argv[0]
return 1
def _get_io_product_specs(self):
"""
Get input- and output-data product specifications from the
......@@ -109,27 +100,6 @@ class msss_calibrator_pipeline(control):
)
def go(self):
"""
Read the parset-file that was given as input argument, and set the
jobname before calling the base-class's `go()` method.
"""
try:
parset_file = os.path.abspath(self.inputs['args'][0])
except IndexError:
return self.usage()
self.parset.adoptFile(parset_file)
# Set job-name to basename of parset-file w/o extension, if it's not
# set on the command-line with '-j' or '--job-name'
if not self.inputs.has_key('job_name'):
self.inputs['job_name'] = (
os.path.splitext(os.path.basename(parset_file))[0])
# Call the base-class's `go()` method.
return super(msss_calibrator_pipeline, self).go()
@mail_log_on_exception
def pipeline_logic(self):
"""
......
......@@ -93,7 +93,6 @@ class msss_imager_pipeline(control):
Initialize member variables and call superclass init function
"""
control.__init__(self)
self.parset = parameterset()
self.input_data = DataMap()
self.target_data = DataMap()
self.output_data = DataMap()
......@@ -101,30 +100,6 @@ class msss_imager_pipeline(control):
self.parset_dir = None
self.mapfile_dir = None
def usage(self):
"""
Display usage information
"""
print >> sys.stderr, "Usage: %s <parset-file> [options]" % sys.argv[0]
return 1
def go(self):
"""
Read the parset-file that was given as input argument, and set the
jobname before calling the base-class's `go()` method.
"""
try:
parset_file = os.path.abspath(self.inputs['args'][0])
except IndexError:
return self.usage()
self.parset.adoptFile(parset_file)
# Set job-name to basename of parset-file w/o extension, if it's not
# set on the command-line with '-j' or '--job-name'
if not 'job_name' in self.inputs:
self.inputs['job_name'] = (
os.path.splitext(os.path.basename(parset_file))[0]
)
return super(msss_imager_pipeline, self).go()
@mail_log_on_exception
def pipeline_logic(self):
......
......@@ -48,19 +48,10 @@ class msss_target_pipeline(control):
def __init__(self):
control.__init__(self)
self.parset = parameterset()
self.input_data = {}
self.output_data = {}
def usage(self):
"""
Display usage information
"""
print >> sys.stderr, "Usage: %s [options] <parset-file>" % sys.argv[0]
return 1
def _get_io_product_specs(self):
"""
Get input- and output-data product specifications from the
......@@ -170,28 +161,6 @@ class msss_target_pipeline(control):
)
def go(self):
"""
Read the parset-file that was given as input argument, and set the
jobname before calling the base-class's `go()` method.
"""
try:
parset_file = os.path.abspath(self.inputs['args'][0])
except IndexError:
return self.usage()
self.parset.adoptFile(parset_file)
# Set job-name to basename of parset-file w/o extension, if it's not
# set on the command-line with '-j' or '--job-name'
if not self.inputs.has_key('job_name'):
self.inputs['job_name'] = (
os.path.splitext(os.path.basename(parset_file))[0]
)
# Call the base-class's `go()` method.
return super(msss_target_pipeline, self).go()
@mail_log_on_exception
def pipeline_logic(self):
"""
......
......@@ -30,20 +30,11 @@ class preprocessing_pipeline(control):
def __init__(self):
super(preprocessing_pipeline, self).__init__()
self.parset = parameterset()
self.input_data = []
self.output_data = []
self.io_data_mask = []
def usage(self):
"""
Display usage
"""
print >> sys.stderr, "Usage: %s [options] <parset-file>" % sys.argv[0]
return 1
def _get_io_product_specs(self):
"""
Get input- and output-data product specifications from the
......@@ -108,27 +99,6 @@ class preprocessing_pipeline(control):
# )
# )
def go(self):
"""
Read the parset-file that was given as input argument;
set jobname, and input/output data products before calling the
base-class's `go()` method.
"""
try:
parset_file = os.path.abspath(self.inputs['args'][0])
except IndexError:
return self.usage()
self.parset.adoptFile(parset_file)
# Set job-name to basename of parset-file w/o extension, if it's not
# set on the command-line with '-j' or '--job-name'
if not self.inputs.has_key('job_name'):
self.inputs['job_name'] = (
os.path.splitext(os.path.basename(parset_file))[0])
# Call the base-class's `go()` method.
return super(preprocessing_pipeline, self).go()
@mail_log_on_exception
def pipeline_logic(self):
......
......@@ -34,31 +34,8 @@ class pulsar_pipeline(control):
def __init__(self):
super(pulsar_pipeline, self).__init__()
self.parset = parameterset()
self.input_data = {}
self.output_data = {}
def go(self):
"""
Read the parset-file that was given as input argument;
set jobname, and input/output data products before calling the
base-class's `go()` method.
"""
try:
parset_file = os.path.abspath(self.inputs['args'][0])
except IndexError:
return self.usage()
self.parset.adoptFile(parset_file)
# Set job-name to basename of parset-file w/o extension, if it's not
# set on the command-line with '-j' or '--job-name'
if not self.inputs.has_key('job_name'):
self.inputs['job_name'] = (
os.path.splitext(os.path.basename(parset_file))[0])
# Call the base-class's `go()` method.
return super(pulsar_pipeline, self).go()
def _get_io_product_specs(self):
......
......@@ -27,8 +27,7 @@ logFile=/opt/lofar/var/log/startPython.log
usage()
{
echo "Usage: $0 <pythonProgram> <parsetname> <MAC-Python-control-host> \\"
echo " <MAC-Python-control-listener> <MAC-Python-control-server>"
echo "Usage: $0 <pythonProgram> <parsetname>"
exit 1
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment