20
20
@click .option (
21
21
"-p" , "--params" , default = {}, type = click .UNPROCESSED , callback = validate_plan_params
22
22
)
23
+ @click .option (
24
+ "-i" , "--identifier" , default = "" , type = click .STRING
25
+ )
23
26
@click .pass_context
24
- def plan (ctx , input , embed , params = {}):
27
+ def plan (ctx , input , embed , identifier = "" , params = {}):
25
28
"""Prepares the runbook for execution by injecting parameters. Doesn't run runbook."""
26
29
import shutil
27
30
28
31
date = datetime .now ().date ()
29
32
basename = path .basename (input )
30
33
basename_without_ext = basename [0 :- 6 ]
34
+ output_basename_without_ext = basename_without_ext + "-" + identifier
31
35
output = "-" .join ([str (date ), basename_without_ext ])
32
36
# Output to folder to allow for embedding other files in same folder
33
37
output_folder = f"./runbooks/runs/{ output } "
34
- full_output = f"{ output_folder } /{ basename_without_ext } .ipynb"
38
+ full_output = f"{ output_folder } /{ output_basename_without_ext } .ipynb"
35
39
36
40
runbook_param_injection = {
37
41
"__RUNBOOK_METADATA__" : {
@@ -46,7 +50,7 @@ def plan(ctx, input, embed, params={}):
46
50
injection_params = {** runbook_param_injection , ** params }
47
51
48
52
if not Path (output_folder ).exists ():
49
- os .mkdir ( path = output_folder )
53
+ os .makedirs ( output_folder , exist_ok = True )
50
54
51
55
# TODO: safety check if we already have one with this SHA in folder, in which case prompt
52
56
# and offer to skip.
@@ -67,7 +71,6 @@ def plan(ctx, input, embed, params={}):
67
71
full_output ,
68
72
]
69
73
70
- # TODO: write customer parser to remove data
71
74
# TODO: join the unified logic of create and plan
72
75
73
76
# TODO: hide the nbconvert verbose output?
0 commit comments