@@ -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,7 +220,8 @@ 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 ,
@@ -402,8 +408,7 @@ def execute_notebook_entrypoint(
402408 mailfrom = mailfrom ,
403409 is_slideshow = is_slideshow ,
404410 )
405- if result .mailto :
406- send_result_email (result , config .DEFAULT_MAILFROM )
411+ send_result_email (result , config .DEFAULT_MAILFROM )
407412 logger .info (f"Here is the result!{ result } " )
408413 if isinstance (result , NotebookResultError ):
409414 logger .warning ("Notebook execution failed! Output was:" )
@@ -458,6 +463,7 @@ def run_report_in_subprocess(
458463 report_name ,
459464 report_title ,
460465 mailto ,
466+ error_mailto ,
461467 overrides ,
462468 * ,
463469 hide_code = False ,
@@ -476,6 +482,7 @@ def run_report_in_subprocess(
476482 :param report_name: `str` The report which we are executing
477483 :param report_title: `str` The user-specified title of the report
478484 :param mailto: `Optional[str]` Who the results will be emailed to
485+ :param error_mailto: `Optional[str]` Who the errors will be emailed to
479486 :param overrides: `Optional[Dict[str, Any]]` The parameters to be passed into the report
480487 :param generate_pdf_output: `bool` Whether we're generating a PDF. Defaults to False.
481488 :param prepare_only: `bool` Whether to do everything except execute the notebook. Useful for testing.
@@ -486,6 +493,8 @@ def run_report_in_subprocess(
486493 :param is_slideshow: Whether the notebook is a reveal.js slideshow or not.
487494 :return: The unique job_id.
488495 """
496+ if error_mailto is None :
497+ error_mailto = ""
489498 job_id = str (uuid .uuid4 ())
490499 job_start_time = datetime .datetime .now ()
491500 result_serializer = initialize_serializer_from_config (base_config )
@@ -497,6 +506,7 @@ def run_report_in_subprocess(
497506 status = JobStatus .SUBMITTED ,
498507 overrides = overrides ,
499508 mailto = mailto ,
509+ error_mailto = error_mailto ,
500510 generate_pdf_output = generate_pdf_output ,
501511 hide_code = hide_code ,
502512 scheduler_job_id = scheduler_job_id ,
@@ -530,6 +540,8 @@ def run_report_in_subprocess(
530540 report_title ,
531541 "--mailto" ,
532542 mailto ,
543+ "--error-mailto" ,
544+ error_mailto ,
533545 "--overrides-as-json" ,
534546 json .dumps (overrides ),
535547 "--pdf-output" if generate_pdf_output else "--no-pdf-output" ,
0 commit comments