@@ -46,6 +46,7 @@ def _run_checks(
46
46
py_template_subdir : str = "" ,
47
47
scheduler_job_id : Optional [str ] = None ,
48
48
mailfrom : Optional [str ] = None ,
49
+ is_slideshow : bool = False ,
49
50
) -> NotebookResultComplete :
50
51
"""
51
52
This is the actual method which executes a notebook, whether running in the webapp or via the entrypoint.
@@ -77,7 +78,8 @@ def _run_checks(
77
78
If available, it will be part of the Error or Completed run report.
78
79
mailfrom : `Optional[str]`
79
80
If available, this will be the email used in the From header.
80
-
81
+ is_slideshow: bool
82
+ Whether or not the output of this should use the equivalent of nbconvert --to slides
81
83
82
84
Returns
83
85
-------
@@ -102,14 +104,18 @@ def _run_checks(
102
104
103
105
logger .info ("Executing notebook at {} using parameters {} --> {}" .format (ipynb_raw_path , overrides , output_ipynb ))
104
106
pm .execute_notebook (
105
- ipynb_raw_path , ipynb_executed_path , parameters = overrides , log_output = True , prepare_only = prepare_only
107
+ ipynb_raw_path ,
108
+ ipynb_executed_path ,
109
+ parameters = overrides ,
110
+ log_output = True ,
111
+ prepare_only = prepare_only ,
106
112
)
107
113
with open (ipynb_executed_path , "r" ) as f :
108
114
raw_executed_ipynb = f .read ()
109
115
110
116
logger .info ("Saving output notebook as HTML from {}" .format (ipynb_executed_path ))
111
- html , resources = ipython_to_html (ipynb_executed_path , job_id )
112
- email_html , _ = ipython_to_html (ipynb_executed_path , job_id , hide_code = hide_code )
117
+ html , resources = ipython_to_html (ipynb_executed_path , job_id , is_slideshow = is_slideshow )
118
+ email_html , _ = ipython_to_html (ipynb_executed_path , job_id , hide_code = hide_code , is_slideshow = is_slideshow )
113
119
pdf = ipython_to_pdf (raw_executed_ipynb , report_title , hide_code = hide_code ) if generate_pdf_output else ""
114
120
115
121
notebook_result = NotebookResultComplete (
@@ -129,6 +135,7 @@ def _run_checks(
129
135
overrides = overrides ,
130
136
scheduler_job_id = scheduler_job_id ,
131
137
mailfrom = mailfrom ,
138
+ is_slideshow = is_slideshow ,
132
139
)
133
140
return notebook_result
134
141
@@ -154,12 +161,17 @@ def run_report(
154
161
py_template_subdir = "" ,
155
162
scheduler_job_id = None ,
156
163
mailfrom = None ,
164
+ is_slideshow = False ,
157
165
):
158
166
159
167
job_id = job_id or str (uuid .uuid4 ())
160
168
stop_execution = os .getenv ("NOTEBOOKER_APP_STOPPING" )
161
169
if stop_execution :
162
- logger .info ("Aborting attempt to run %s, jobid=%s as app is shutting down." , report_name , job_id )
170
+ logger .info (
171
+ "Aborting attempt to run %s, jobid=%s as app is shutting down." ,
172
+ report_name ,
173
+ job_id ,
174
+ )
163
175
result_serializer .update_check_status (job_id , JobStatus .CANCELLED , error_info = CANCEL_MESSAGE )
164
176
return
165
177
try :
@@ -170,7 +182,10 @@ def run_report(
170
182
attempts_remaining ,
171
183
)
172
184
result_serializer .update_check_status (
173
- job_id , report_name = report_name , job_start_time = job_submit_time , status = JobStatus .PENDING
185
+ job_id ,
186
+ report_name = report_name ,
187
+ job_start_time = job_submit_time ,
188
+ status = JobStatus .PENDING ,
174
189
)
175
190
result = _run_checks (
176
191
job_id ,
@@ -190,6 +205,7 @@ def run_report(
190
205
py_template_subdir = py_template_subdir ,
191
206
scheduler_job_id = scheduler_job_id ,
192
207
mailfrom = mailfrom ,
208
+ is_slideshow = is_slideshow ,
193
209
)
194
210
logger .info ("Successfully got result." )
195
211
result_serializer .save_check_result (result )
@@ -208,6 +224,7 @@ def run_report(
208
224
generate_pdf_output = generate_pdf_output ,
209
225
scheduler_job_id = scheduler_job_id ,
210
226
mailfrom = mailfrom ,
227
+ is_slideshow = is_slideshow ,
211
228
)
212
229
logger .error (
213
230
"Report run failed. Saving error result to mongo library %s@%s..." ,
@@ -239,6 +256,7 @@ def run_report(
239
256
py_template_subdir = py_template_subdir ,
240
257
scheduler_job_id = scheduler_job_id ,
241
258
mailfrom = mailfrom ,
259
+ is_slideshow = is_slideshow ,
242
260
)
243
261
else :
244
262
logger .info ("Abandoning attempt to run report. It failed too many times." )
@@ -327,6 +345,7 @@ def execute_notebook_entrypoint(
327
345
prepare_notebook_only : bool ,
328
346
scheduler_job_id : Optional [str ],
329
347
mailfrom : Optional [str ],
348
+ is_slideshow : bool ,
330
349
):
331
350
report_title = report_title or report_name
332
351
output_dir , template_dir , _ = initialise_base_dirs (output_dir = config .OUTPUT_DIR , template_dir = config .TEMPLATE_DIR )
@@ -351,6 +370,7 @@ def execute_notebook_entrypoint(
351
370
logger .info ("mailfrom = %s" % mailfrom )
352
371
logger .info ("pdf_output = %s" , pdf_output )
353
372
logger .info ("hide_code = %s" , hide_code )
373
+ logger .info ("is_slideshow = %s" , is_slideshow )
354
374
logger .info ("prepare_notebook_only = %s" , prepare_notebook_only )
355
375
logger .info ("scheduler job id = %s" , scheduler_job_id )
356
376
logger .info ("notebooker_disable_git = %s" , notebooker_disable_git )
@@ -384,6 +404,7 @@ def execute_notebook_entrypoint(
384
404
py_template_subdir = py_template_subdir ,
385
405
scheduler_job_id = scheduler_job_id ,
386
406
mailfrom = mailfrom ,
407
+ is_slideshow = is_slideshow ,
387
408
)
388
409
if result .mailto :
389
410
send_result_email (result , config .DEFAULT_MAILFROM )
0 commit comments