Skip to content

Commit c6c1bb5

Browse files
fix push invocation in deploy checkpoint (#1650)
1 parent 5dbf006 commit c6c1bb5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

truss/cli/cli.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ def _get_required_option(ctx: click.Context, name: str) -> object:
152152
return value
153153

154154

155+
def _prepare_click_context(f: click.Command, params: dict) -> click.Context:
156+
"""create new click context for invoking a command via f.invoke(ctx)"""
157+
current_ctx = click.get_current_context()
158+
current_obj = current_ctx.find_root().obj
159+
160+
ctx = click.Context(f, obj=current_obj)
161+
ctx.params = params
162+
return ctx
163+
164+
155165
def _log_level_option(f: Callable[..., object]) -> Callable[..., object]:
156166
return click.option(
157167
"--log",
@@ -1720,19 +1730,18 @@ def deploy_checkpoints(
17201730
),
17211731
)
17221732

1723-
ctx = click.Context(push, obj={})
1724-
ctx.params = {
1733+
params = {
17251734
"target_directory": prepare_checkpoint_result.truss_directory,
17261735
"remote": remote,
17271736
"model_name": prepare_checkpoint_result.checkpoint_deploy_config.model_name,
17281737
"publish": True,
17291738
"deployment_name": prepare_checkpoint_result.checkpoint_deploy_config.deployment_name,
17301739
}
1740+
ctx = _prepare_click_context(push, params)
17311741
if dry_run:
17321742
console.print("--dry-run flag provided, not deploying", style="yellow")
17331743
else:
17341744
push.invoke(ctx)
1735-
17361745
train_cli.print_deploy_checkpoints_success_message(prepare_checkpoint_result)
17371746

17381747

0 commit comments

Comments
 (0)