Skip to content

Commit f51b5e8

Browse files
authored
chore: Add examples to the CLI help output for endpoint commands (#354)
1 parent 789d9a4 commit f51b5e8

4 files changed

Lines changed: 101 additions & 11 deletions

File tree

src/together/lib/cli/__init__.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
from together.lib.cli.utils._console import console
2727
from together.lib.cli.utils._api_error import try_handle_server_error_message
2828
from together.lib.cli.utils._completion import install_completion
29+
from together.lib.cli.utils._help_examples import (
30+
ENDPOINTS_HELP_EXAMPLES,
31+
TOP_LEVEL_HELP_EXAMPLES,
32+
ENDPOINTS_CREATE_HELP_EXAMPLES,
33+
ENDPOINTS_UPDATE_HELP_EXAMPLES,
34+
ENDPOINTS_HARDWARE_HELP_EXAMPLES,
35+
)
2936
from together.lib.cli.utils._help_formatter import help_formatter
3037
from together.lib.cli.utils._preparse_tokens import preparse_tokens
3138

@@ -326,17 +333,28 @@ async def run_command() -> None:
326333
## Endpoints API commands
327334
endpoints_app = app.command(App(name="endpoints", help="Deploy and manage dedicated endpoints"))
328335
endpoints_app.command(
329-
(f"{_CLI}.endpoints.hardware:hardware"), help="List available hardware configurations for deploying models"
336+
(f"{_CLI}.endpoints.hardware:hardware"),
337+
help="List available hardware configurations for deploying models",
338+
help_epilogue=ENDPOINTS_HARDWARE_HELP_EXAMPLES,
339+
)
340+
endpoints_app.command(
341+
(f"{_CLI}.endpoints.create:create"),
342+
alias="-c",
343+
help="Create a new endpoint",
344+
help_epilogue=ENDPOINTS_CREATE_HELP_EXAMPLES,
330345
)
331-
endpoints_app.command((f"{_CLI}.endpoints.create:create"), alias="-c", help="Create a new endpoint")
332-
endpoints_app.command((f"{_CLI}.endpoints.retrieve:retrieve"), help="Get endpoint details")
333-
endpoints_app.command((f"{_CLI}.endpoints.stop:stop"), help="Stop an endpoint")
334-
endpoints_app.command((f"{_CLI}.endpoints.start:start"), help="Start an endpoint")
335-
endpoints_app.command((f"{_CLI}.endpoints.delete:delete"), alias="-d", help="Delete an endpoint")
336-
endpoints_app.command((f"{_CLI}.endpoints.list:list"), alias="ls", help="List your endpoints")
337-
endpoints_app.command((f"{_CLI}.endpoints.update:update"), help="Update an endpoint")
346+
endpoints_app.command((f"{_CLI}.endpoints.retrieve:retrieve"), help="Get endpoint details", help_epilogue="")
347+
endpoints_app.command((f"{_CLI}.endpoints.stop:stop"), help="Stop an endpoint", help_epilogue="")
348+
endpoints_app.command((f"{_CLI}.endpoints.start:start"), help="Start an endpoint", help_epilogue="")
349+
endpoints_app.command((f"{_CLI}.endpoints.delete:delete"), alias="-d", help="Delete an endpoint", help_epilogue="")
350+
endpoints_app.command((f"{_CLI}.endpoints.list:list"), alias="ls", help="List your endpoints", help_epilogue="")
338351
endpoints_app.command(
339-
(f"{_CLI}.endpoints.availability_zones:availability_zones"), help="List availability zones for deploying models"
352+
(f"{_CLI}.endpoints.update:update"), help="Update an endpoint", help_epilogue=ENDPOINTS_UPDATE_HELP_EXAMPLES
353+
)
354+
endpoints_app.command(
355+
(f"{_CLI}.endpoints.availability_zones:availability_zones"),
356+
help="List availability zones for deploying models",
357+
help_epilogue="",
340358
)
341359

342360
## Evals API commands
@@ -435,6 +453,9 @@ async def run_command() -> None:
435453
(f"{_CLI}.beta.jig.jig:jig_volumes_list"), name="list", alias="ls", help="List volumes for a Jig deployment"
436454
)
437455

456+
app.help_epilogue = TOP_LEVEL_HELP_EXAMPLES
457+
endpoints_app.help_epilogue = ENDPOINTS_HELP_EXAMPLES
458+
438459

439460
def main() -> None:
440461
install_completion(app)

src/together/lib/cli/api/endpoints/hardware.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
async def hardware(
1616
model: Annotated[Optional[str], Parameter(help="Show only hardware compatible with the given model")] = None,
17-
available: Annotated[bool, Parameter(help="Show only available hardware for the given model")] = False,
17+
available: Annotated[
18+
bool, Parameter(help="Show only available hardware for the given model", negative=False)
19+
] = False,
1820
*,
1921
config: CLIConfigParameter,
2022
) -> None:
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
## Top-level commands
2+
3+
TOP_LEVEL_HELP_EXAMPLES = """[dim]Examples:[/dim]
4+
[dim]-[/dim] Fine tune a model for your dataset:
5+
[primary]tg ft create --model Qwen/Qwen2-1.5B --training-file ./my-dataset.jsonl --lora[/primary]
6+
7+
[dim]-[/dim] Deploy a model to a dedicated endpoint:
8+
[primary]tg endpoints create --model Qwen/Qwen2.5-7B --hardware 2x_nvidia_h100_80gb_sxm --wait[/primary]
9+
10+
[dim]-[/dim] Upload an external model to Together:
11+
[primary]tg models upload --model-name my-org/my-model --model-source s3-or-hugging-face[/primary]
12+
"""
13+
14+
## Endpoints API commands
15+
16+
ENDPOINTS_HELP_EXAMPLES = """[dim]Examples:[/dim]
17+
[dim]-[/dim] Create a new endpoint:
18+
[primary]tg endpoints create --model Qwen/Qwen2.5-7B --hardware 2x_nvidia_h100_80gb_sxm --wait[/primary]
19+
20+
[dim]-[/dim] Lookup available hardware for a model:
21+
[primary]tg endpoints hardware --model Qwen/Qwen2.5-7B --available[/primary]
22+
23+
[dim]-[/dim] List your endpoints:
24+
[primary]tg endpoints list[/primary]
25+
26+
[dim]-[/dim] Get details of an endpoint:
27+
[primary]tg endpoints retrieve <endpoint-id>[/primary]
28+
29+
[dim]-[/dim] Stop an endpoint:
30+
[primary]tg endpoints stop <endpoint-id>[/primary]
31+
32+
[dim]-[/dim] Change the autoscaling configuration for an endpoint:
33+
[primary]tg endpoints update <endpoint-id> --min-replicas 4 --max-replicas 8[/primary]
34+
"""
35+
36+
ENDPOINTS_HARDWARE_HELP_EXAMPLES = """[dim]Examples:[/dim]
37+
[dim]-[/dim] List all hardware configurations:
38+
[primary]tg endpoints hardware[/primary]
39+
40+
[dim]-[/dim] List all hardware configurations for a model:
41+
[primary]tg endpoints hardware --model Qwen/Qwen2.5-7B[/primary]
42+
43+
[dim]-[/dim] List all available hardware configurations for a model:
44+
[primary]tg endpoints hardware --model Qwen/Qwen2.5-7B --available[/primary]
45+
46+
[dim]-[/dim] Grab the cheapest hardware configuration for a model:
47+
[primary]tg endpoints hardware --model meta-llama/Meta-Llama-3-8B-Instruct --available --json | jq -r 'sort_by(.pricing.cents_per_minute) | .[0].id'[/primary]
48+
"""
49+
50+
ENDPOINTS_CREATE_HELP_EXAMPLES = """[dim]Examples:[/dim]
51+
[dim]-[/dim] Deploy your model with specific autoscaling configuration:
52+
[primary]tg endpoints create --model MODEL --hardware HARDWARE --min-replicas 2 --max-replicas 4[/primary]
53+
54+
[dim]-[/dim] Deploy your fine tuned model:
55+
[primary]tg endpoints create --model $(tg ft $MY_FT_JOB_ID --json | jq -r '.model_output_name') --hardware HARDWARE[/primary]
56+
57+
[dim]-[/dim] Create an endpoint to be started later:
58+
[primary]tg endpoints create --model MODEL --hardware HARDWARE --no-auto-start[/primary]
59+
"""
60+
61+
ENDPOINTS_UPDATE_HELP_EXAMPLES = """[dim]Examples:[/dim]
62+
[dim]-[/dim] Change the autoscaling configuration for an endpoint:
63+
[primary]tg endpoints update ENDPOINT_ID --min-replicas 4 --max-replicas 8[/primary]
64+
65+
[dim]-[/dim] Change the auto-stop timeout for an endpoint:
66+
[primary]tg endpoints update ENDPOINT_ID --inactive-timeout 30[/primary]
67+
"""

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)