@@ -48,6 +48,7 @@ def _run_checks(
4848 email_subject : Optional [str ] = "" ,
4949 prepare_only : Optional [bool ] = False ,
5050 notebooker_disable_git : bool = False ,
51+ execute_at_origin : bool = False ,
5152 py_template_base_dir : str = "" ,
5253 py_template_subdir : str = "" ,
5354 scheduler_job_id : Optional [str ] = None ,
@@ -82,6 +83,10 @@ def _run_checks(
8283 Comma-separated email addresses to send on error.
8384 prepare_only : `Optional[bool]`
8485 Internal usage. Whether we want to do everything apart from executing the notebook.
86+ notebooker_disable_git : `bool`
87+ Whether to disable git pulling of the notebook templates.
88+ execute_at_origin : `bool`
89+ Whether to execute the notebook at the original path of the template notebook.
8590 scheduler_job_id : `Optional[str]`
8691 If available, it will be part of the Error or Completed run report.
8792 mailfrom : `Optional[str]`
@@ -111,8 +116,18 @@ def _run_checks(
111116 ipynb_executed_path = os .path .join (output_dir , output_ipynb )
112117
113118 logger .info ("Executing notebook at {} using parameters {} --> {}" .format (ipynb_raw_path , overrides , output_ipynb ))
119+ working_dir = None
120+ if execute_at_origin :
121+ working_dir = os .path .dirname (os .path .join (py_template_dir , template_name ))
122+ logger .info ("Setting working directory for execution {}" .format (working_dir ))
123+
114124 pm .execute_notebook (
115- ipynb_raw_path , ipynb_executed_path , parameters = overrides , log_output = True , prepare_only = prepare_only
125+ ipynb_raw_path ,
126+ ipynb_executed_path ,
127+ parameters = overrides ,
128+ log_output = True ,
129+ prepare_only = prepare_only ,
130+ cwd = working_dir ,
116131 )
117132 with open (ipynb_executed_path , "r" ) as f :
118133 raw_executed_ipynb = f .read ()
@@ -163,6 +178,7 @@ def run_report(
163178 hide_code = False ,
164179 prepare_only = False ,
165180 notebooker_disable_git = False ,
181+ execute_at_origin = False ,
166182 py_template_base_dir = "" ,
167183 py_template_subdir = "" ,
168184 scheduler_job_id = None ,
@@ -200,6 +216,7 @@ def run_report(
200216 hide_code = hide_code ,
201217 prepare_only = prepare_only ,
202218 notebooker_disable_git = notebooker_disable_git ,
219+ execute_at_origin = execute_at_origin ,
203220 py_template_base_dir = py_template_base_dir ,
204221 py_template_subdir = py_template_subdir ,
205222 scheduler_job_id = scheduler_job_id ,
@@ -353,6 +370,7 @@ def execute_notebook_entrypoint(
353370 output_dir , template_dir , _ = initialise_base_dirs (output_dir = config .OUTPUT_DIR , template_dir = config .TEMPLATE_DIR )
354371 all_overrides = _get_overrides (overrides_as_json , iterate_override_values_of )
355372 notebooker_disable_git = config .NOTEBOOKER_DISABLE_GIT
373+ execute_at_origin = config .EXECUTE_AT_ORIGIN
356374 py_template_base_dir = config .PY_TEMPLATE_BASE_DIR
357375 py_template_subdir = config .PY_TEMPLATE_SUBDIR
358376
@@ -376,6 +394,7 @@ def execute_notebook_entrypoint(
376394 logger .info ("prepare_notebook_only = %s" , prepare_notebook_only )
377395 logger .info ("scheduler job id = %s" , scheduler_job_id )
378396 logger .info ("notebooker_disable_git = %s" , notebooker_disable_git )
397+ logger .info ("execute_at_origin = %s" , execute_at_origin )
379398 logger .info ("py_template_base_dir = %s" , py_template_base_dir )
380399 logger .info ("py_template_subdir = %s" , py_template_subdir )
381400 logger .info ("serializer_cls = %s" , config .SERIALIZER_CLS )
@@ -402,6 +421,7 @@ def execute_notebook_entrypoint(
402421 hide_code = hide_code ,
403422 prepare_only = prepare_notebook_only ,
404423 notebooker_disable_git = notebooker_disable_git ,
424+ execute_at_origin = execute_at_origin ,
405425 py_template_base_dir = py_template_base_dir ,
406426 py_template_subdir = py_template_subdir ,
407427 scheduler_job_id = scheduler_job_id ,
@@ -532,6 +552,7 @@ def run_report_in_subprocess(
532552 base_config .DEFAULT_MAILFROM ,
533553 ]
534554 + (["--notebooker-disable-git" ] if base_config .NOTEBOOKER_DISABLE_GIT else [])
555+ + (["--execute-at-origin" ] if base_config .EXECUTE_AT_ORIGIN else [])
535556 + ["--serializer-cls" , result_serializer .__class__ .__name__ ]
536557 + result_serializer .serializer_args_to_cmdline_args ()
537558 + [
0 commit comments