Commit 006c8866 authored by Gregory Ashton's avatar Gregory Ashton

Merge branch 'condor_notification' into 'master'

add notification setting

Closes #178

See merge request !346
parents e6223dea b9122c3e
Pipeline #143677 passed with stages
in 4 minutes and 16 seconds
...@@ -18,7 +18,7 @@ class Node(object): ...@@ -18,7 +18,7 @@ class Node(object):
self.request_disk = None self.request_disk = None
self.online_pe = self.inputs.online_pe self.online_pe = self.inputs.online_pe
self.getenv = True self.getenv = True
self.notification = False self.notification = inputs.notification
self.retry = None self.retry = None
self.verbose = 0 self.verbose = 0
self.extra_lines = list(self.inputs.extra_lines) self.extra_lines = list(self.inputs.extra_lines)
......
...@@ -63,6 +63,7 @@ class MainInput(Input): ...@@ -63,6 +63,7 @@ class MainInput(Input):
self.webdir = args.webdir self.webdir = args.webdir
self.email = args.email self.email = args.email
self.notification = args.notification
self.existing_dir = args.existing_dir self.existing_dir = args.existing_dir
self.scheduler = args.scheduler self.scheduler = args.scheduler
...@@ -143,6 +144,21 @@ class MainInput(Input): ...@@ -143,6 +144,21 @@ class MainInput(Input):
raise FileNotFoundError("No ini file {} found".format(ini)) raise FileNotFoundError("No ini file {} found".format(ini))
self._ini = os.path.relpath(ini) self._ini = os.path.relpath(ini)
@property
def notification(self):
return self._notification
@notification.setter
def notification(self, notification):
valid_settings = ["Always", "Complete", "Error", "Never"]
if notification in valid_settings:
self._notification = notification
else:
raise BilbyPipeError(
"'{}' is not a valid notification setting. "
"Valid settings are {}.".format(notification, valid_settings)
)
@property @property
def initialdir(self): def initialdir(self):
return os.getcwd() return os.getcwd()
......
...@@ -648,6 +648,26 @@ def create_parser(top_level=True): ...@@ -648,6 +648,26 @@ def create_parser(top_level=True):
"--create-summary", action="store_true", help="Create a PESummary page" "--create-summary", action="store_true", help="Create a PESummary page"
) )
output_parser.add("--email", type=nonestr, help="Email for notifications") output_parser.add("--email", type=nonestr, help="Email for notifications")
output_parser.add(
"--notification",
type=nonestr,
default="Never",
help=(
"Notification setting for HTCondor jobs. "
"One of 'Always','Complete','Error','Never'. "
"If defined by 'Always', "
"the owner will be notified whenever the job "
"produces a checkpoint, as well as when the job completes. "
"If defined by 'Complete', "
"the owner will be notified when the job terminates. "
"If defined by 'Error', "
"the owner will only be notified if the job terminates abnormally, "
"or if the job is placed on hold because of a failure, "
"and not by user request. "
"If defined by 'Never' (the default), "
"the owner will not receive e-mail, regardless to what happens to the job. "
),
)
output_parser.add( output_parser.add(
"--existing-dir", "--existing-dir",
type=nonestr, type=nonestr,
......
...@@ -75,6 +75,16 @@ class TestMainInput(unittest.TestCase): ...@@ -75,6 +75,16 @@ class TestMainInput(unittest.TestCase):
memory = "{} GB".format(self.args.request_memory_generation) memory = "{} GB".format(self.args.request_memory_generation)
self.assertEqual(inputs.request_memory_generation, memory) self.assertEqual(inputs.request_memory_generation, memory)
def test_notification_set(self):
self.args.notification = "Always"
inputs = bilby_pipe.main.MainInput(self.args, [])
self.assertEqual(inputs.notification, "Always")
def test_notification_error_riased_set(self):
self.args.notification = "Sometimes"
with self.assertRaises(BilbyPipeError):
bilby_pipe.main.MainInput(self.args, [])
def test_label(self): def test_label(self):
self.assertEqual(self.inputs.label, self.args.label) self.assertEqual(self.inputs.label, self.args.label)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment