99from centml .sdk import auth
1010from centml .sdk .api import get_centml_client
1111from centml .sdk .config import settings
12- from centml .sdk .shell import PodNotFoundError , ShellError , build_ws_url , exec_session , get_running_pods , interactive_session
12+ from centml .sdk .shell import (
13+ PodNotFoundError ,
14+ ShellError ,
15+ build_ws_url ,
16+ exec_session ,
17+ get_running_pods ,
18+ interactive_session ,
19+ )
1320
1421
1522def _resolve_pod (running_pods : list [str ], pod_name : str ) -> str :
@@ -20,16 +27,13 @@ def _resolve_pod(running_pods: list[str], pod_name: str) -> str:
2027 return pod_name
2128
2229
23-
2430def _select_pod (running_pods , deployment_id ):
2531 click .echo (f"Multiple running pods found for deployment { deployment_id } :" )
2632 for i , name in enumerate (running_pods , 1 ):
2733 click .echo (f" [{ i } ] { name } " )
2834
2935 choice = click .prompt (
30- "Select a pod" ,
31- type = click .IntRange (1 , len (running_pods )),
32- prompt_suffix = f" [1-{ len (running_pods )} ]: " ,
36+ "Select a pod" , type = click .IntRange (1 , len (running_pods )), prompt_suffix = f" [1-{ len (running_pods )} ]: "
3337 )
3438 return running_pods [choice - 1 ]
3539
@@ -60,7 +64,9 @@ def _connect_args(deployment_id, pod, shell_type, first_pod=False):
6064@click .argument ("deployment_id" , type = int )
6165@click .option ("--pod" , default = None , help = "Specify a pod name" )
6266@click .option ("--shell" , "shell_type" , default = None , type = click .Choice (["bash" , "sh" , "zsh" ]), help = "Shell type" )
63- @click .option ("--first-pod" , is_flag = True , default = False , help = "Auto-select the first running pod (skip interactive selection)" )
67+ @click .option (
68+ "--first-pod" , is_flag = True , default = False , help = "Auto-select the first running pod (skip interactive selection)"
69+ )
6470@handle_exception
6571def shell (deployment_id , pod , shell_type , first_pod ):
6672 if not sys .stdin .isatty ():
@@ -76,7 +82,9 @@ def shell(deployment_id, pod, shell_type, first_pod):
7682@click .argument ("command" , nargs = - 1 , required = True , type = click .UNPROCESSED )
7783@click .option ("--pod" , default = None , help = "Specific pod name" )
7884@click .option ("--shell" , "shell_type" , default = None , type = click .Choice (["bash" , "sh" , "zsh" ]), help = "Shell type" )
79- @click .option ("--first-pod" , is_flag = True , default = False , help = "Auto-select the first running pod (skip interactive selection)" )
85+ @click .option (
86+ "--first-pod" , is_flag = True , default = False , help = "Auto-select the first running pod (skip interactive selection)"
87+ )
8088@handle_exception
8189def exec_cmd (deployment_id , command , pod , shell_type , first_pod ):
8290 ws_url , token = _connect_args (deployment_id , pod , shell_type , first_pod )
0 commit comments