Skip to content
Snippets Groups Projects
Commit df112dc4 authored by aknecht2's avatar aknecht2
Browse files

Added email argument, removed all references to config file.

parent c98640e1
No related branches found
No related tags found
No related merge requests found
......@@ -60,13 +60,14 @@ class Workflow(object):
def __init__(self, job_home, run_file, param_file, properties_file,
chip_bin, idr_bin, execute_site="local", output_site="local",
host="localhost", username=None, password=None, save_db=True,
rewrite=False, debug=False):
email=None, rewrite=False, debug=False):
# debug mode, print out additional information
self.debug = debug
# Job site information
self.execute_site = execute_site
self.output_site = output_site
self.save_db = save_db
self.email = email
# DB information
self.username = username
......@@ -84,6 +85,11 @@ class Workflow(object):
self.run_file = os.path.abspath(run_file)
self.param_file = os.path.abspath(param_file)
self.properties_file = os.path.abspath(properties_file)
# Validate the existance of but not the contents of the
# pegasus properties file
if not os.path.isfile(self.properties_file):
self.errors.append("Provided pegasus properties file '%s' does not exist." % (self.properties_file,))
self.chip_bin = chip_bin
self.idr_bin = idr_bin
......@@ -162,28 +168,6 @@ class Workflow(object):
self.dax.addFile(gen_file_obj["file"])
return
def _load_config(self):
# Validate input config.yaml file
# required & optional keys can be found in conf.py
try:
with open(self.config_file, "r") as rh:
self.config = yaml.load(rh)
for key in chipathlon.conf.config_file["required_keys"]:
if key not in self.config:
self.errors.append("Config file '%s' does not have required key '%s'." % (config_file, key))
all_keys = chipathlon.conf.config_file["optional_keys"] + chipathlon.conf.config_file["required_keys"]
for key in self.config:
if key not in all_keys:
self.errors.append("Config file '%s' has invalid key '%s' specified, should be one of: %s." % (config_file, key, all_keys))
except yaml.YAMLError as ye:
self.errors.append("Error reading config file '%s': %s" % (config_file, ye))
# Validate the existance of but not the contents of the
# pegasus properties file
if not os.path.isfile(self.properties_file):
self.errors.append("Provided pegasus properties file '%s' does not exist." % (self.properties_file,))
return
def _add_executable(self, name, path, os_type="linux", arch="x86_64", site="local", installed=True):
self.executables[name] = Executable(name=name, os=os_type.lower(), arch=arch, installed=installed)
self.executables[name].addPFN(PFN(os.path.join("file://", path), site))
......@@ -199,8 +183,8 @@ class Workflow(object):
executable,
os.path.join(self.idr_bin if executable == "idr" else self.chip_bin, executable),
site=self.execute_site,
arch=self.config.get("arch", "x86_64"),
os_type=self.config.get("os", "linux")
arch=arch,
os_type=os_type
)
# Load actual scripts
for root, dirs, files in os.walk("%s/%s" % (os.path.dirname(os.path.realpath(__file__)), chipathlon.conf.job_scripts)):
......@@ -210,8 +194,8 @@ class Workflow(object):
f,
os.path.join(self.chip_bin, f),
site=self.execute_site,
arch=self.config.get("arch", "x86_64"),
os_type=self.config.get("os", "linux")
arch=arch,
os_type=os_type,
)
break
# Handle necessary installed scripts
......@@ -220,8 +204,8 @@ class Workflow(object):
cmd,
os.path.join(chipathlon.conf.system_path, cmd),
site=self.execute_site,
arch=self.config.get("arch", "x86_64"),
os_type=self.config.get("os", "linux")
arch=arch,
os_type=os_type
)
return
......@@ -344,15 +328,16 @@ class Workflow(object):
"""
Add the script to email when the workflow is finished.
"""
notify_path = os.path.join(self.base_path, "input/notify.sh")
with open(notify_path, "w") as wh:
notify = textwrap.dedent("""\
#!/bin/bash
pegasus-email -t %s --report=pegasus-analyzer
""" % (self.config["email"],))
wh.write(notify)
os.chmod(notify_path, 0755)
self.dax.invoke(When.AT_END, notify_path)
if self.email is not None:
notify_path = os.path.join(self.base_path, "input/notify.sh")
with open(notify_path, "w") as wh:
notify = textwrap.dedent("""\
#!/bin/bash
pegasus-email -t %s --report=pegasus-analyzer
""" % (self.email,))
wh.write(notify)
os.chmod(notify_path, 0755)
self.dax.invoke(When.AT_END, notify_path)
return
def _create_pegasus_files(self):
......
......@@ -16,6 +16,7 @@ parser.add_argument("--output-site", dest="output_site", required=True, default=
parser.add_argument("--chip-bin", dest="chip_bin", required=True, help="Path to chipathlon conda environment bin.")
parser.add_argumnet("--idr-bin", dest="idr_bin", required=True, help="Path to idr conda enviornment bin.")
parser.add_argument("--email", dest="email", help="An email address to notify when the workflow is finished.")
parser.add_argument("--no-save-db", dest="save_db", default=True, action="store_false", help="Whether or not to save results to the database. Default: True")
parser.add_argument("--rewrite", dest="rewrite", default=False, action="store_true", help="If specified, don't load from the database, rewrite files.")
parser.add_argument("--debug", dest="debug", default=False, action="store_true", help="Print out more information while generating.")
......@@ -16,6 +16,7 @@ parser.add_argument("--output-site", dest="output_site", required=True, default=
parser.add_argument("--chip-bin", dest="chip_bin", required=True, help="Path to chipathlon conda environment bin.")
parser.add_argumnet("--idr-bin", dest="idr_bin", required=True, help="Path to idr conda enviornment bin.")
parser.add_argument("--email", dest="email", help="An email address to notify when the workflow is finished.")
parser.add_argument("--no-save-db", dest="save_db", default=True, action="store_false", help="Whether or not to save results to the database. Default: True")
parser.add_argument("--rewrite", dest="rewrite", default=False, action="store_true", help="If specified, don't load from the database, rewrite files.")
parser.add_argument("--debug", dest="debug", default=False, action="store_true", help="Print out more information while generating.")
......@@ -33,6 +34,7 @@ workflow = Workflow(
password=args.password,
execute_site=args.execute_site,
output_site=args.output_site,
email=email,
save_db=args.save_db,
rewrite=args.rewrite,
debug=args.debug
......
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