|
2 | 2 | from typing import Optional |
3 | 3 | from .command_registry import get_registry |
4 | 4 |
|
| 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 | + |
5 | 21 | # Custom CLI group that delays command registration until needed |
6 | 22 | class LazyGroup(click.Group): |
7 | 23 | def __init__(self, *args, **kwargs): |
@@ -43,25 +59,9 @@ def format_help(self, ctx, formatter): |
43 | 59 |
|
44 | 60 | def format_commands(self, ctx, formatter): |
45 | 61 | """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 | | - |
62 | 62 | commands = [] |
63 | 63 | 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.') |
65 | 65 | commands.append((name, help_text)) |
66 | 66 |
|
67 | 67 | if commands: |
@@ -158,50 +158,50 @@ class CLICommand(click.Group): |
158 | 158 | # Create subgroups, lightweight and don't trigger imports |
159 | 159 | @cli.group(cls=CLICommand) |
160 | 160 | def create(): |
161 | | - """Create endpoints or pytorch jobs.""" |
162 | 161 | pass |
| 162 | +create.__doc__ = CLI_HELP_TEXT['create'] |
163 | 163 |
|
164 | 164 |
|
165 | 165 | @cli.group(cls=CLICommand) |
166 | 166 | def list(): |
167 | | - """List endpoints or pytorch jobs.""" |
168 | 167 | pass |
| 168 | +list.__doc__ = CLI_HELP_TEXT['list'] |
169 | 169 |
|
170 | 170 |
|
171 | 171 | @cli.group(cls=CLICommand) |
172 | 172 | def describe(): |
173 | | - """Describe endpoints or pytorch jobs.""" |
174 | 173 | pass |
| 174 | +describe.__doc__ = CLI_HELP_TEXT['describe'] |
175 | 175 |
|
176 | 176 |
|
177 | 177 | @cli.group(cls=CLICommand) |
178 | 178 | def delete(): |
179 | | - """Delete endpoints or pytorch jobs.""" |
180 | 179 | pass |
| 180 | +delete.__doc__ = CLI_HELP_TEXT['delete'] |
181 | 181 |
|
182 | 182 |
|
183 | 183 | @cli.group(cls=CLICommand) |
184 | 184 | def list_pods(): |
185 | | - """List pods for endpoints or pytorch jobs.""" |
186 | 185 | pass |
| 186 | +list_pods.__doc__ = CLI_HELP_TEXT['list-pods'] |
187 | 187 |
|
188 | 188 |
|
189 | 189 | @cli.group(cls=CLICommand) |
190 | 190 | def get_logs(): |
191 | | - """Get pod logs for endpoints or pytorch jobs.""" |
192 | 191 | pass |
| 192 | +get_logs.__doc__ = CLI_HELP_TEXT['get-logs'] |
193 | 193 |
|
194 | 194 |
|
195 | 195 | @cli.group(cls=CLICommand) |
196 | 196 | def invoke(): |
197 | | - """Invoke model endpoints.""" |
198 | 197 | pass |
| 198 | +invoke.__doc__ = CLI_HELP_TEXT['invoke'] |
199 | 199 |
|
200 | 200 |
|
201 | 201 | @cli.group(cls=CLICommand) |
202 | 202 | def get_operator_logs(): |
203 | | - """Get operator logs for endpoints.""" |
204 | 203 | pass |
| 204 | +get_operator_logs.__doc__ = CLI_HELP_TEXT['get-operator-logs'] |
205 | 205 |
|
206 | 206 |
|
207 | 207 | if __name__ == "__main__": |
|
0 commit comments