@@ -44,6 +44,7 @@ def _run_checks(
4444 generate_pdf_output : Optional [bool ] = True ,
4545 hide_code : Optional [bool ] = False ,
4646 mailto : Optional [str ] = "" ,
47+ error_mailto : Optional [str ] = "" ,
4748 email_subject : Optional [str ] = "" ,
4849 prepare_only : Optional [bool ] = False ,
4950 notebooker_disable_git : bool = False ,
@@ -76,7 +77,9 @@ def _run_checks(
7677 generate_pdf_output : `Optional[bool]`
7778 Whether to generate PDF output or not. NB this requires xelatex to be installed on the executor.
7879 mailto : `Optional[str]`
79- Comma-separated email addresses to send on completion (or error).
80+ Comma-separated email addresses to send on completion.
81+ error_mailto : `Optional[str]`
82+ Comma-separated email addresses to send on error.
8083 prepare_only : `Optional[bool]`
8184 Internal usage. Whether we want to do everything apart from executing the notebook.
8285 scheduler_job_id : `Optional[str]`
@@ -128,6 +131,7 @@ def _run_checks(
128131 raw_html = html ,
129132 email_html = email_html ,
130133 mailto = mailto ,
134+ error_mailto = error_mailto ,
131135 email_subject = email_subject ,
132136 pdf = pdf ,
133137 generate_pdf_output = generate_pdf_output ,
@@ -191,6 +195,7 @@ def run_report(
191195 template_base_dir ,
192196 overrides ,
193197 mailto = mailto ,
198+ error_mailto = error_mailto ,
194199 email_subject = email_subject ,
195200 generate_pdf_output = generate_pdf_output ,
196201 hide_code = hide_code ,
@@ -215,12 +220,14 @@ def run_report(
215220 report_title = report_title ,
216221 error_info = error_info ,
217222 overrides = overrides ,
218- mailto = error_mailto or mailto ,
223+ mailto = mailto ,
224+ error_mailto = error_mailto ,
219225 generate_pdf_output = generate_pdf_output ,
220226 scheduler_job_id = scheduler_job_id ,
221227 mailfrom = mailfrom ,
222228 hide_code = hide_code ,
223229 is_slideshow = is_slideshow ,
230+ email_subject = email_subject ,
224231 )
225232 logger .error (
226233 "Report run failed. Saving error result to mongo library %s@%s..." ,
@@ -402,8 +409,7 @@ def execute_notebook_entrypoint(
402409 mailfrom = mailfrom ,
403410 is_slideshow = is_slideshow ,
404411 )
405- if result .mailto :
406- send_result_email (result , config .DEFAULT_MAILFROM )
412+ send_result_email (result , config .DEFAULT_MAILFROM )
407413 logger .info (f"Here is the result!{ result } " )
408414 if isinstance (result , NotebookResultError ):
409415 logger .warning ("Notebook execution failed! Output was:" )
@@ -458,6 +464,7 @@ def run_report_in_subprocess(
458464 report_name ,
459465 report_title ,
460466 mailto ,
467+ error_mailto ,
461468 overrides ,
462469 * ,
463470 hide_code = False ,
@@ -466,6 +473,7 @@ def run_report_in_subprocess(
466473 scheduler_job_id = None ,
467474 run_synchronously = False ,
468475 mailfrom = None ,
476+ email_subject = None ,
469477 n_retries = 3 ,
470478 is_slideshow = False ,
471479) -> str :
@@ -476,16 +484,20 @@ def run_report_in_subprocess(
476484 :param report_name: `str` The report which we are executing
477485 :param report_title: `str` The user-specified title of the report
478486 :param mailto: `Optional[str]` Who the results will be emailed to
487+ :param error_mailto: `Optional[str]` Who the errors will be emailed to
479488 :param overrides: `Optional[Dict[str, Any]]` The parameters to be passed into the report
480489 :param generate_pdf_output: `bool` Whether we're generating a PDF. Defaults to False.
481490 :param prepare_only: `bool` Whether to do everything except execute the notebook. Useful for testing.
482491 :param scheduler_job_id: `Optional[str]` if the job was triggered from the scheduler, this is the scheduler's job id
483492 :param run_synchronously: `bool` If True, then we will join the stderr monitoring thread until the job has completed
484493 :param mailfrom: `str` if passed, then this string will be used in the from field
494+ :param email_subject: `str` if passed, then this string will be used in the email subject
485495 :param n_retries: The number of retries to attempt.
486496 :param is_slideshow: Whether the notebook is a reveal.js slideshow or not.
487497 :return: The unique job_id.
488498 """
499+ if error_mailto is None :
500+ error_mailto = ""
489501 job_id = str (uuid .uuid4 ())
490502 job_start_time = datetime .datetime .now ()
491503 result_serializer = initialize_serializer_from_config (base_config )
@@ -497,10 +509,12 @@ def run_report_in_subprocess(
497509 status = JobStatus .SUBMITTED ,
498510 overrides = overrides ,
499511 mailto = mailto ,
512+ error_mailto = error_mailto ,
500513 generate_pdf_output = generate_pdf_output ,
501514 hide_code = hide_code ,
502515 scheduler_job_id = scheduler_job_id ,
503516 is_slideshow = is_slideshow ,
517+ email_subject = email_subject ,
504518 )
505519
506520 command = (
@@ -530,6 +544,8 @@ def run_report_in_subprocess(
530544 report_title ,
531545 "--mailto" ,
532546 mailto ,
547+ "--error-mailto" ,
548+ error_mailto ,
533549 "--overrides-as-json" ,
534550 json .dumps (overrides ),
535551 "--pdf-output" if generate_pdf_output else "--no-pdf-output" ,
@@ -541,6 +557,7 @@ def run_report_in_subprocess(
541557 + (["--is-slideshow" ] if is_slideshow else [])
542558 + ([f"--scheduler-job-id={ scheduler_job_id } " ] if scheduler_job_id is not None else [])
543559 + ([f"--mailfrom={ mailfrom } " ] if mailfrom is not None else [])
560+ + ([f"--email-subject={ email_subject } " ] if email_subject else [])
544561 )
545562 p = subprocess .Popen (command , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
546563
0 commit comments