Skip to content

Commit ae5610f

Browse files
author
Mohamed Zeidan
committed
before standard changes
1 parent 204f092 commit ae5610f

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/sagemaker/hyperpod/cli/hyp_cli.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
from typing import Optional
33
from .command_registry import get_registry
44

5+
# Single source of truth for CLI help text
6+
CLI_HELP_TEXT = {
7+
'create': 'Create endpoints or pytorch jobs.',
8+
'list': 'List endpoints or pytorch jobs.',
9+
'describe': 'Describe endpoints or pytorch jobs.',
10+
'delete': 'Delete endpoints or pytorch jobs.',
11+
'list-pods': 'List pods for endpoints or pytorch jobs.',
12+
'get-logs': 'Get pod logs for endpoints or pytorch jobs.',
13+
'invoke': 'Invoke model endpoints.',
14+
'get-operator-logs': 'Get operator logs for endpoints.',
15+
'list-cluster': 'List SageMaker Hyperpod Clusters with metadata.',
16+
'set-cluster-context': 'Connect to a HyperPod EKS cluster.',
17+
'get-cluster-context': 'Get context related to the current set cluster.',
18+
'get-monitoring': 'Get monitoring configurations for Hyperpod cluster.'
19+
}
20+
521
# Custom CLI group that delays command registration until needed
622
class LazyGroup(click.Group):
723
def __init__(self, *args, **kwargs):
@@ -43,25 +59,9 @@ def format_help(self, ctx, formatter):
4359

4460
def format_commands(self, ctx, formatter):
4561
"""Format commands section without loading modules"""
46-
# Static help text mapping for fast help generation (no registry queries)
47-
static_help = {
48-
'create': 'Create endpoints or pytorch jobs.',
49-
'list': 'List endpoints or pytorch jobs.',
50-
'describe': 'Describe endpoints or pytorch jobs.',
51-
'delete': 'Delete endpoints or pytorch jobs.',
52-
'list-pods': 'List pods for endpoints or pytorch jobs.',
53-
'get-logs': 'Get pod logs for endpoints or pytorch jobs.',
54-
'invoke': 'Invoke model endpoints.',
55-
'get-operator-logs': 'Get operator logs for endpoints.',
56-
'list-cluster': 'List SageMaker Hyperpod Clusters with metadata.',
57-
'set-cluster-context': 'Connect to a HyperPod EKS cluster.',
58-
'get-cluster-context': 'Get context related to the current set cluster.',
59-
'get-monitoring': 'Get monitoring configurations for Hyperpod cluster.'
60-
}
61-
6262
commands = []
6363
for name in self.list_commands(ctx):
64-
help_text = static_help.get(name, f'{name.replace("-", " ").title()} operations.')
64+
help_text = CLI_HELP_TEXT.get(name, f'{name.replace("-", " ").title()} operations.')
6565
commands.append((name, help_text))
6666

6767
if commands:
@@ -158,50 +158,50 @@ class CLICommand(click.Group):
158158
# Create subgroups, lightweight and don't trigger imports
159159
@cli.group(cls=CLICommand)
160160
def create():
161-
"""Create endpoints or pytorch jobs."""
162161
pass
162+
create.__doc__ = CLI_HELP_TEXT['create']
163163

164164

165165
@cli.group(cls=CLICommand)
166166
def list():
167-
"""List endpoints or pytorch jobs."""
168167
pass
168+
list.__doc__ = CLI_HELP_TEXT['list']
169169

170170

171171
@cli.group(cls=CLICommand)
172172
def describe():
173-
"""Describe endpoints or pytorch jobs."""
174173
pass
174+
describe.__doc__ = CLI_HELP_TEXT['describe']
175175

176176

177177
@cli.group(cls=CLICommand)
178178
def delete():
179-
"""Delete endpoints or pytorch jobs."""
180179
pass
180+
delete.__doc__ = CLI_HELP_TEXT['delete']
181181

182182

183183
@cli.group(cls=CLICommand)
184184
def list_pods():
185-
"""List pods for endpoints or pytorch jobs."""
186185
pass
186+
list_pods.__doc__ = CLI_HELP_TEXT['list-pods']
187187

188188

189189
@cli.group(cls=CLICommand)
190190
def get_logs():
191-
"""Get pod logs for endpoints or pytorch jobs."""
192191
pass
192+
get_logs.__doc__ = CLI_HELP_TEXT['get-logs']
193193

194194

195195
@cli.group(cls=CLICommand)
196196
def invoke():
197-
"""Invoke model endpoints."""
198197
pass
198+
invoke.__doc__ = CLI_HELP_TEXT['invoke']
199199

200200

201201
@cli.group(cls=CLICommand)
202202
def get_operator_logs():
203-
"""Get operator logs for endpoints."""
204203
pass
204+
get_operator_logs.__doc__ = CLI_HELP_TEXT['get-operator-logs']
205205

206206

207207
if __name__ == "__main__":

0 commit comments

Comments
 (0)