Skip to content

Commit 1316203

Browse files
authored
chore: Add example usage for model commands (#358)
1 parent ad3cdb2 commit 1316203

2 files changed

Lines changed: 40 additions & 21 deletions

File tree

src/together/lib/cli/__init__.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
from together.lib.cli.utils._completion import install_completion
2929
from together.lib.cli.utils._help_examples import (
3030
EVALS_HELP_EXAMPLES,
31+
MODELS_HELP_EXAMPLES,
3132
ENDPOINTS_HELP_EXAMPLES,
3233
TOP_LEVEL_HELP_EXAMPLES,
3334
FINE_TUNING_HELP_EXAMPLES,
3435
EVALS_CREATE_HELP_EXAMPLES,
36+
MODELS_UPLOAD_HELP_EXAMPLES,
3537
ENDPOINTS_CREATE_HELP_EXAMPLES,
3638
ENDPOINTS_UPDATE_HELP_EXAMPLES,
3739
ENDPOINTS_HARDWARE_HELP_EXAMPLES,
@@ -63,6 +65,7 @@ def _propagate_global_param_group(target_app: App) -> None:
6365
target_app[flag].group = "Global Options"
6466
target_app[flag].show = True
6567
target_app[flag].help = help_text
68+
target_app.help_epilogue = target_app.help_epilogue or ""
6669
except KeyError:
6770
pass
6871
for sub in target_app.subapps:
@@ -328,30 +331,25 @@ async def run_command() -> None:
328331
help="Start a new fine-tuning job",
329332
help_epilogue=FINE_TUNING_CREATE_HELP_EXAMPLES,
330333
)
331-
fine_tuning_app.command((f"{_CLI}.fine_tuning.list:list"), alias="ls", help="List fine-tuning jobs", help_epilogue="")
332-
fine_tuning_app.command((f"{_CLI}.fine_tuning.retrieve:retrieve"), help="Get fine-tuning job details", help_epilogue="")
333-
fine_tuning_app.command((f"{_CLI}.fine_tuning.cancel:cancel"), help="Cancel a fine-tuning job", help_epilogue="")
334-
fine_tuning_app.command(
335-
(f"{_CLI}.fine_tuning.list_events:list_events"), help="List events for a fine-tuning job", help_epilogue=""
336-
)
334+
fine_tuning_app.command((f"{_CLI}.fine_tuning.list:list"), alias="ls", help="List fine-tuning jobs")
335+
fine_tuning_app.command((f"{_CLI}.fine_tuning.retrieve:retrieve"), help="Get fine-tuning job details")
336+
fine_tuning_app.command((f"{_CLI}.fine_tuning.cancel:cancel"), help="Cancel a fine-tuning job")
337+
fine_tuning_app.command((f"{_CLI}.fine_tuning.list_events:list_events"), help="List events for a fine-tuning job")
337338
fine_tuning_app.command(
338339
(f"{_CLI}.fine_tuning.list_checkpoints:list_checkpoints"),
339340
help="List checkpoints for a fine-tuning job",
340-
help_epilogue="",
341341
)
342342
fine_tuning_app.command(
343343
(f"{_CLI}.fine_tuning.download:download"),
344344
help="Download a fine-tuned model's weights",
345345
help_epilogue=FINE_TUNING_DOWNLOAD_HELP_EXAMPLES,
346346
)
347-
fine_tuning_app.command(
348-
(f"{_CLI}.fine_tuning.delete:delete"), alias="-d", help="Delete a fine-tuning job", help_epilogue=""
349-
)
347+
fine_tuning_app.command((f"{_CLI}.fine_tuning.delete:delete"), alias="-d", help="Delete a fine-tuning job")
350348

351349
## Models API commands
352-
models_app = app.command(App(name="models", help="List and upload models"))
350+
models_app = app.command(App(name="models", help="List and upload models", help_epilogue=MODELS_HELP_EXAMPLES))
353351
models_app.command((f"{_CLI}.models.list:list"), alias="ls", help="List available models")
354-
models_app.command((f"{_CLI}.models.upload:upload"), help="Upload a model")
352+
models_app.command((f"{_CLI}.models.upload:upload"), help="Upload a model", help_epilogue=MODELS_UPLOAD_HELP_EXAMPLES)
355353

356354
## Endpoints API commands
357355
endpoints_app = app.command(App(name="endpoints", help="Deploy and manage dedicated endpoints"))
@@ -366,28 +364,27 @@ async def run_command() -> None:
366364
help="Create a new endpoint",
367365
help_epilogue=ENDPOINTS_CREATE_HELP_EXAMPLES,
368366
)
369-
endpoints_app.command((f"{_CLI}.endpoints.retrieve:retrieve"), help="Get endpoint details", help_epilogue="")
370-
endpoints_app.command((f"{_CLI}.endpoints.stop:stop"), help="Stop an endpoint", help_epilogue="")
371-
endpoints_app.command((f"{_CLI}.endpoints.start:start"), help="Start an endpoint", help_epilogue="")
372-
endpoints_app.command((f"{_CLI}.endpoints.delete:delete"), alias="-d", help="Delete an endpoint", help_epilogue="")
373-
endpoints_app.command((f"{_CLI}.endpoints.list:list"), alias="ls", help="List your endpoints", help_epilogue="")
367+
endpoints_app.command((f"{_CLI}.endpoints.retrieve:retrieve"), help="Get endpoint details")
368+
endpoints_app.command((f"{_CLI}.endpoints.stop:stop"), help="Stop an endpoint")
369+
endpoints_app.command((f"{_CLI}.endpoints.start:start"), help="Start an endpoint")
370+
endpoints_app.command((f"{_CLI}.endpoints.delete:delete"), alias="-d", help="Delete an endpoint")
371+
endpoints_app.command((f"{_CLI}.endpoints.list:list"), alias="ls", help="List your endpoints")
374372
endpoints_app.command(
375373
(f"{_CLI}.endpoints.update:update"), help="Update an endpoint", help_epilogue=ENDPOINTS_UPDATE_HELP_EXAMPLES
376374
)
377375
endpoints_app.command(
378376
(f"{_CLI}.endpoints.availability_zones:availability_zones"),
379377
help="List availability zones for deploying models",
380-
help_epilogue="",
381378
)
382379

383380
## Evals API commands
384381
evals_app = app.command(App(name="evals", help="Run and manage model evaluations", help_epilogue=EVALS_HELP_EXAMPLES))
385382
evals_app.command(
386383
(f"{_CLI}.evals.create:create"), alias="-c", help="Create a new eval job", help_epilogue=EVALS_CREATE_HELP_EXAMPLES
387384
)
388-
evals_app.command((f"{_CLI}.evals.list:list"), alias="ls", help="List eval jobs", help_epilogue="")
389-
evals_app.command((f"{_CLI}.evals.retrieve:retrieve"), help="Get eval job details", help_epilogue="")
390-
evals_app.command((f"{_CLI}.evals.status:status"), help="Get an eval job's status", help_epilogue="")
385+
evals_app.command((f"{_CLI}.evals.list:list"), alias="ls", help="List eval jobs")
386+
evals_app.command((f"{_CLI}.evals.retrieve:retrieve"), help="Get eval job details")
387+
evals_app.command((f"{_CLI}.evals.status:status"), help="Get an eval job's status")
391388

392389
## Telemetry API commands
393390
telemetry_app = app.command(App(name="telemetry", help="Configure CLI telemetry"))

src/together/lib/cli/utils/_help_examples.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,28 @@
1111
[primary]tg models upload --model-name my-org/my-model --model-source s3-or-hugging-face[/primary]
1212
"""
1313

14+
## Models API commands
15+
MODELS_HELP_EXAMPLES = """[dim]Examples:[/dim]
16+
[dim]-[/dim] List all models:
17+
[primary]tg models list[/primary]
18+
19+
[dim]-[/dim] Upload a model:
20+
[primary]tg models upload --model-name my-model --model-source s3-or-hugging-face[/primary]
21+
"""
22+
23+
MODELS_UPLOAD_HELP_EXAMPLES = """[dim]Examples:[/dim]
24+
[dim]-[/dim] Upload a model from S3:
25+
[primary]tg models upload \\
26+
--model-name my-model \\
27+
--model-source $(aws s3 presign s3://my-bucket/my-model)[/primary]
28+
29+
[dim]-[/dim] Upload private model from Hugging Face:
30+
[primary]tg models upload \\
31+
--model-name my-model \\
32+
--model-source my-org/model-name \\
33+
--hf-token $HUGGING_FACE_TOKEN[/primary]
34+
"""
35+
1436
## Fine-tuning API commands
1537
FINE_TUNING_HELP_EXAMPLES = """[dim]Examples:[/dim]
1638
[dim]-[/dim] Create a fine-tuning job:

0 commit comments

Comments
 (0)