Skip to content

Commit a8cf358

Browse files
authored
Merge pull request #9 from zph/issue-5/identifiers
Issue #5: Allow for custom suffix on planned runbook name with --iden…
2 parents bad6264 + 5dd230f commit a8cf358

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

runbook/cli/commands/plan.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@
2020
@click.option(
2121
"-p", "--params", default={}, type=click.UNPROCESSED, callback=validate_plan_params
2222
)
23+
@click.option(
24+
"-i", "--identifier", default="", type=click.STRING
25+
)
2326
@click.pass_context
24-
def plan(ctx, input, embed, params={}):
27+
def plan(ctx, input, embed, identifier="", params={}):
2528
"""Prepares the runbook for execution by injecting parameters. Doesn't run runbook."""
2629
import shutil
2730

2831
date = datetime.now().date()
2932
basename = path.basename(input)
3033
basename_without_ext = basename[0:-6]
34+
output_basename_without_ext = basename_without_ext + "-" + identifier
3135
output = "-".join([str(date), basename_without_ext])
3236
# Output to folder to allow for embedding other files in same folder
3337
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"
3539

3640
runbook_param_injection = {
3741
"__RUNBOOK_METADATA__": {
@@ -46,7 +50,7 @@ def plan(ctx, input, embed, params={}):
4650
injection_params = {**runbook_param_injection, **params}
4751

4852
if not Path(output_folder).exists():
49-
os.mkdir(path=output_folder)
53+
os.makedirs(output_folder, exist_ok=True)
5054

5155
# TODO: safety check if we already have one with this SHA in folder, in which case prompt
5256
# and offer to skip.
@@ -67,7 +71,6 @@ def plan(ctx, input, embed, params={}):
6771
full_output,
6872
]
6973

70-
# TODO: write customer parser to remove data
7174
# TODO: join the unified logic of create and plan
7275

7376
# TODO: hide the nbconvert verbose output?

0 commit comments

Comments
 (0)