@@ -36,112 +36,147 @@ def print_papermill_version(ctx, param, value):
3636 ctx .exit ()
3737
3838
39- @click .command (context_settings = dict (help_option_names = ['-h' , ' --help' ]))
39+ @click .command (context_settings = dict (help_option_names = ["-h" , " --help" ]))
4040@click .pass_context
41- @click .argument (' notebook_path' , required = not INPUT_PIPED )
42- @click .argument (' output_path' , default = "" )
41+ @click .argument (" notebook_path" , required = not INPUT_PIPED )
42+ @click .argument (" output_path" , default = "" )
4343@click .option (
44- ' --help-notebook' ,
44+ " --help-notebook" ,
4545 is_flag = True ,
4646 default = False ,
47- help = ' Display parameters information for the given notebook path.' ,
47+ help = " Display parameters information for the given notebook path." ,
4848)
49- @click .option ('--parameters' , '-p' , nargs = 2 , multiple = True , help = 'Parameters to pass to the parameters cell.' )
50- @click .option ('--parameters_raw' , '-r' , nargs = 2 , multiple = True , help = 'Parameters to be read as raw string.' )
51- @click .option ('--parameters_file' , '-f' , multiple = True , help = 'Path to YAML file containing parameters.' )
52- @click .option ('--parameters_yaml' , '-y' , multiple = True , help = 'YAML string to be used as parameters.' )
53- @click .option ('--parameters_base64' , '-b' , multiple = True , help = 'Base64 encoded YAML string as parameters.' )
5449@click .option (
55- '--inject-input-path' ,
50+ "--parameters" ,
51+ "-p" ,
52+ nargs = 2 ,
53+ multiple = True ,
54+ help = "Parameters to pass to the parameters cell." ,
55+ )
56+ @click .option (
57+ "--parameters_raw" ,
58+ "-r" ,
59+ nargs = 2 ,
60+ multiple = True ,
61+ help = "Parameters to be read as raw string." ,
62+ )
63+ @click .option (
64+ "--parameters_file" ,
65+ "-f" ,
66+ multiple = True ,
67+ help = "Path to YAML file containing parameters." ,
68+ )
69+ @click .option (
70+ "--parameters_yaml" ,
71+ "-y" ,
72+ multiple = True ,
73+ help = "YAML string to be used as parameters." ,
74+ )
75+ @click .option (
76+ "--parameters_base64" ,
77+ "-b" ,
78+ multiple = True ,
79+ help = "Base64 encoded YAML string as parameters." ,
80+ )
81+ @click .option (
82+ "--inject-input-path" ,
5683 is_flag = True ,
5784 default = False ,
5885 help = "Insert the path of the input notebook as PAPERMILL_INPUT_PATH as a notebook parameter." ,
5986)
6087@click .option (
61- ' --inject-output-path' ,
88+ " --inject-output-path" ,
6289 is_flag = True ,
6390 default = False ,
6491 help = "Insert the path of the output notebook as PAPERMILL_OUTPUT_PATH as a notebook parameter." ,
6592)
6693@click .option (
67- ' --inject-paths' ,
94+ " --inject-paths" ,
6895 is_flag = True ,
6996 default = False ,
7097 help = (
7198 "Insert the paths of input/output notebooks as PAPERMILL_INPUT_PATH/PAPERMILL_OUTPUT_PATH"
7299 " as notebook parameters."
73100 ),
74101)
75- @click .option ('--engine' , help = 'The execution engine name to use in evaluating the notebook.' )
76102@click .option (
77- '--request-save-on-cell-execute/--no-request-save-on-cell-execute' ,
103+ "--engine" , help = "The execution engine name to use in evaluating the notebook."
104+ )
105+ @click .option (
106+ "--request-save-on-cell-execute/--no-request-save-on-cell-execute" ,
78107 default = True ,
79- help = ' Request save notebook after each cell execution' ,
108+ help = " Request save notebook after each cell execution" ,
80109)
81110@click .option (
82- ' --autosave-cell-every' ,
111+ " --autosave-cell-every" ,
83112 default = 30 ,
84113 type = int ,
85- help = ' How often in seconds to autosave the notebook during long cell executions (0 to disable)' ,
114+ help = " How often in seconds to autosave the notebook during long cell executions (0 to disable)" ,
86115)
87116@click .option (
88- ' --prepare-only/--prepare-execute' ,
117+ " --prepare-only/--prepare-execute" ,
89118 default = False ,
90119 help = "Flag for outputting the notebook without execution, but with parameters applied." ,
91120)
92121@click .option (
93- '--kernel' ,
94- '-k' ,
95- help = 'Name of kernel to run. Ignores kernel name in the notebook document metadata.' ,
122+ "--kernel" ,
123+ "-k" ,
124+ help = "Name of kernel to run. Ignores kernel name in the notebook document metadata." ,
125+ )
126+ @click .option (
127+ "--language" ,
128+ "-l" ,
129+ help = "Language for notebook execution. Ignores language in the notebook document metadata." ,
96130)
131+ @click .option ("--cwd" , default = None , help = "Working directory to run notebook in." )
97132@click .option (
98- '--language' ,
99- '-l' ,
100- help = 'Language for notebook execution. Ignores language in the notebook document metadata.' ,
133+ "--progress-bar/--no-progress-bar" ,
134+ default = None ,
135+ help = "Flag for turning on the progress bar." ,
101136)
102- @click .option ('--cwd' , default = None , help = 'Working directory to run notebook in.' )
103- @click .option ('--progress-bar/--no-progress-bar' , default = None , help = "Flag for turning on the progress bar." )
104137@click .option (
105- ' --log-output/--no-log-output' ,
138+ " --log-output/--no-log-output" ,
106139 default = False ,
107140 help = "Flag for writing notebook output to the configured logger." ,
108141)
109142@click .option (
110- ' --stdout-file' ,
111- type = click .File (mode = 'w' , encoding = ' utf-8' ),
143+ " --stdout-file" ,
144+ type = click .File (mode = "w" , encoding = " utf-8" ),
112145 help = "File to write notebook stdout output to." ,
113146)
114147@click .option (
115- ' --stderr-file' ,
116- type = click .File (mode = 'w' , encoding = ' utf-8' ),
148+ " --stderr-file" ,
149+ type = click .File (mode = "w" , encoding = " utf-8" ),
117150 help = "File to write notebook stderr output to." ,
118151)
119152@click .option (
120- ' --log-level' ,
121- type = click .Choice ([' NOTSET' , ' DEBUG' , ' INFO' , ' WARNING' , ' ERROR' , ' CRITICAL' ]),
122- default = ' INFO' ,
123- help = ' Set log level' ,
153+ " --log-level" ,
154+ type = click .Choice ([" NOTSET" , " DEBUG" , " INFO" , " WARNING" , " ERROR" , " CRITICAL" ]),
155+ default = " INFO" ,
156+ help = " Set log level" ,
124157)
125158@click .option (
126- ' --start-timeout' ,
127- ' --start_timeout' , # Backwards compatible naming
159+ " --start-timeout" ,
160+ " --start_timeout" , # Backwards compatible naming
128161 type = int ,
129162 default = 60 ,
130163 help = "Time in seconds to wait for kernel to start." ,
131164)
132165@click .option (
133- ' --execution-timeout' ,
166+ " --execution-timeout" ,
134167 type = int ,
135168 help = "Time in seconds to wait for each cell before failing execution (default: forever)" ,
136169)
137- @click .option ('--report-mode/--no-report-mode' , default = False , help = "Flag for hiding input." )
138170@click .option (
139- '--version' ,
171+ "--report-mode/--no-report-mode" , default = False , help = "Flag for hiding input."
172+ )
173+ @click .option (
174+ "--version" ,
140175 is_flag = True ,
141176 callback = print_papermill_version ,
142177 expose_value = False ,
143178 is_eager = True ,
144- help = ' Flag for displaying the version.' ,
179+ help = " Flag for displaying the version." ,
145180)
146181def papermill (
147182 click_ctx ,
@@ -189,28 +224,28 @@ def papermill(
189224
190225 """
191226 # Jupyter deps use frozen modules, so we disable the python 3.11+ warning about debugger if running the CLI
192- if ' PYDEVD_DISABLE_FILE_VALIDATION' not in os .environ :
193- os .environ [' PYDEVD_DISABLE_FILE_VALIDATION' ] = '1'
227+ if " PYDEVD_DISABLE_FILE_VALIDATION" not in os .environ :
228+ os .environ [" PYDEVD_DISABLE_FILE_VALIDATION" ] = "1"
194229
195230 if not help_notebook :
196231 required_output_path = not (INPUT_PIPED or OUTPUT_PIPED )
197232 if required_output_path and not output_path :
198233 raise click .UsageError ("Missing argument 'OUTPUT_PATH'" )
199234
200235 if INPUT_PIPED and notebook_path and not output_path :
201- input_path = '-'
236+ input_path = "-"
202237 output_path = notebook_path
203238 else :
204- input_path = notebook_path or '-'
205- output_path = output_path or '-'
239+ input_path = notebook_path or "-"
240+ output_path = output_path or "-"
206241
207- if output_path == '-' :
242+ if output_path == "-" :
208243 # Save notebook to stdout just once
209244 request_save_on_cell_execute = False
210245
211246 # Reduce default log level if we pipe to stdout
212- if log_level == ' INFO' :
213- log_level = ' ERROR'
247+ if log_level == " INFO" :
248+ log_level = " ERROR"
214249
215250 elif progress_bar is None :
216251 progress_bar = not log_output
@@ -220,11 +255,13 @@ def papermill(
220255 # Read in Parameters
221256 parameters_final = {}
222257 if inject_input_path or inject_paths :
223- parameters_final [' PAPERMILL_INPUT_PATH' ] = input_path
258+ parameters_final [" PAPERMILL_INPUT_PATH" ] = input_path
224259 if inject_output_path or inject_paths :
225- parameters_final [' PAPERMILL_OUTPUT_PATH' ] = output_path
260+ parameters_final [" PAPERMILL_OUTPUT_PATH" ] = output_path
226261 for params in parameters_base64 or []:
227- parameters_final .update (yaml .load (base64 .b64decode (params ), Loader = NoDatesSafeLoader ) or {})
262+ parameters_final .update (
263+ yaml .load (base64 .b64decode (params ), Loader = NoDatesSafeLoader ) or {}
264+ )
228265 for files in parameters_file or []:
229266 parameters_final .update (read_yaml_file (files ) or {})
230267 for params in parameters_yaml or []:
0 commit comments