@@ -37,7 +37,10 @@ def _run_checks(
3737 template_base_dir : str ,
3838 overrides : Dict [AnyStr , Any ],
3939 generate_pdf_output : Optional [bool ] = True ,
40+ hide_code : Optional [bool ] = False ,
4041 mailto : Optional [str ] = "" ,
42+ error_mailto : Optional [str ] = "" ,
43+ email_subject : Optional [str ] = "" ,
4144 prepare_only : Optional [bool ] = False ,
4245 notebooker_disable_git : bool = False ,
4346 py_template_base_dir : str = "" ,
@@ -101,7 +104,8 @@ def _run_checks(
101104
102105 logger .info ("Saving output notebook as HTML from {}" .format (ipynb_executed_path ))
103106 html , resources = ipython_to_html (ipynb_executed_path , job_id )
104- pdf = ipython_to_pdf (raw_executed_ipynb , report_title ) if generate_pdf_output else ""
107+ email_html , resources = ipython_to_html (ipynb_executed_path , job_id , hide_code = hide_code )
108+ pdf = ipython_to_pdf (raw_executed_ipynb , report_title , hide_code = hide_code ) if generate_pdf_output else ""
105109
106110 notebook_result = NotebookResultComplete (
107111 job_id = job_id ,
@@ -110,7 +114,9 @@ def _run_checks(
110114 raw_html_resources = resources ,
111115 raw_ipynb_json = raw_executed_ipynb ,
112116 raw_html = html ,
117+ email_html = email_html ,
113118 mailto = mailto ,
119+ email_subject = email_subject ,
114120 pdf = pdf ,
115121 generate_pdf_output = generate_pdf_output ,
116122 report_name = template_name ,
@@ -131,7 +137,10 @@ def run_report(
131137 template_base_dir = None ,
132138 attempts_remaining = 2 ,
133139 mailto = "" ,
140+ error_mailto = "" ,
141+ email_subject = "" ,
134142 generate_pdf_output = True ,
143+ hide_code = False ,
135144 prepare_only = False ,
136145 notebooker_disable_git = False ,
137146 py_template_base_dir = "" ,
@@ -163,7 +172,9 @@ def run_report(
163172 template_base_dir ,
164173 overrides ,
165174 mailto = mailto ,
175+ email_subject = email_subject ,
166176 generate_pdf_output = generate_pdf_output ,
177+ hide_code = hide_code ,
167178 prepare_only = prepare_only ,
168179 notebooker_disable_git = notebooker_disable_git ,
169180 py_template_base_dir = py_template_base_dir ,
@@ -182,7 +193,7 @@ def run_report(
182193 report_title = report_title ,
183194 error_info = error_info ,
184195 overrides = overrides ,
185- mailto = mailto ,
196+ mailto = error_mailto or mailto ,
186197 generate_pdf_output = generate_pdf_output ,
187198 )
188199 logger .error (
@@ -205,7 +216,10 @@ def run_report(
205216 template_base_dir = template_base_dir ,
206217 attempts_remaining = attempts_remaining - 1 ,
207218 mailto = mailto ,
219+ error_mailto = error_mailto ,
220+ email_subject = email_subject ,
208221 generate_pdf_output = generate_pdf_output ,
222+ hide_code = hide_code ,
209223 prepare_only = prepare_only ,
210224 notebooker_disable_git = notebooker_disable_git ,
211225 py_template_base_dir = py_template_base_dir ,
@@ -291,7 +305,10 @@ def execute_notebook_entrypoint(
291305 n_retries : int ,
292306 job_id : str ,
293307 mailto : str ,
308+ error_mailto : str ,
309+ email_subject : str ,
294310 pdf_output : bool ,
311+ hide_code : bool ,
295312 prepare_notebook_only : bool ,
296313):
297314 report_title = report_title or report_name
@@ -312,7 +329,10 @@ def execute_notebook_entrypoint(
312329 logger .info ("output_dir = %s" , output_dir )
313330 logger .info ("template_dir = %s" , template_dir )
314331 logger .info ("mailto = %s" , mailto )
332+ logger .info ("error_mailto = %s" , error_mailto )
333+ logger .info ("email_subject = %s" , email_subject )
315334 logger .info ("pdf_output = %s" , pdf_output )
335+ logger .info ("hide_code = %s" , hide_code )
316336 logger .info ("prepare_notebook_only = %s" , prepare_notebook_only )
317337 logger .info ("notebooker_disable_git = %s" , notebooker_disable_git )
318338 logger .info ("py_template_base_dir = %s" , py_template_base_dir )
@@ -335,13 +355,16 @@ def execute_notebook_entrypoint(
335355 template_base_dir = template_dir ,
336356 attempts_remaining = n_retries - 1 ,
337357 mailto = mailto ,
358+ error_mailto = error_mailto ,
359+ email_subject = email_subject ,
338360 generate_pdf_output = pdf_output ,
361+ hide_code = hide_code ,
339362 prepare_only = prepare_notebook_only ,
340363 notebooker_disable_git = notebooker_disable_git ,
341364 py_template_base_dir = py_template_base_dir ,
342365 py_template_subdir = py_template_subdir ,
343366 )
344- if mailto :
367+ if result . mailto :
345368 send_result_email (result , mailto )
346369 if isinstance (result , NotebookResultError ):
347370 logger .warning ("Notebook execution failed! Output was:" )
0 commit comments