Skip to content

Commit d8e40a3

Browse files
committed
Add non-interactive runbook executions as experimental
1 parent 7e34e7d commit d8e40a3

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

runbook/cli/commands/run.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
type=click.Path(file_okay=True),
99
callback=validate_planned_runbook_file_path,
1010
)
11-
@click.option("--interactive/--no-interactive", default=True)
11+
@click.option("--output", type=click.Path(file_okay=True), default=None)
12+
@click.option(
13+
"--interactive/--no-interactive",
14+
default=True,
15+
help="Run the notebook in interactive mode or EXPERIMENTAL non-interactive mode",
16+
)
1217
@click.pass_context
13-
def run(ctx, filename, interactive):
18+
def run(ctx, filename, output, interactive):
1419
"""Run a notebook"""
1520
if interactive:
1621
argv = [filename]
@@ -20,4 +25,14 @@ def run(ctx, filename, interactive):
2025

2126
JupyterNotebookApp.launch_instance(argv=argv)
2227
else:
23-
raise RuntimeError("Not Implemented but will do with papermill")
28+
if not output:
29+
raise click.BadOptionUsage(
30+
"--output", "--output is required when --interactive is false"
31+
)
32+
import papermill as pm
33+
34+
pm.execute_notebook(
35+
input_path=filename,
36+
output_path=output,
37+
)
38+
print(f"Output written to {output}")

0 commit comments

Comments
 (0)