Commit b9122c3e authored by Avi Vajpeyi's avatar Avi Vajpeyi 👽
Browse files

add notification

parent d27a5068
Pipeline #143232 passed with stage
in 8 minutes and 59 seconds
......@@ -18,7 +18,7 @@ class Node(object):
self.request_disk = None
self.online_pe = self.inputs.online_pe
self.getenv = True
self.notification = False
self.notification = inputs.notification
self.retry = None
self.verbose = 0
self.extra_lines = list(self.inputs.extra_lines)
......
......@@ -63,6 +63,7 @@ class MainInput(Input):
self.webdir = args.webdir
self.email = args.email
self.notification = args.notification
self.existing_dir = args.existing_dir
self.scheduler = args.scheduler
......@@ -143,6 +144,21 @@ class MainInput(Input):
raise FileNotFoundError("No ini file {} found".format(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
def initialdir(self):
return os.getcwd()
......
......@@ -648,6 +648,26 @@ def create_parser(top_level=True):
"--create-summary", action="store_true", help="Create a PESummary page"
)
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(
"--existing-dir",
type=nonestr,
......
......@@ -75,6 +75,16 @@ class TestMainInput(unittest.TestCase):
memory = "{} GB".format(self.args.request_memory_generation)
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):
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