From 8df708b91e9bbc51f96f50e1456b27abd059ad60 Mon Sep 17 00:00:00 2001 From: Josh Salomon Date: Mon, 14 Apr 2025 13:50:51 +0300 Subject: [PATCH 1/2] CLI fix: Fix CLI for datasets register Fixed the `llama-stack-cli datasets register` to match the modified API (some mandatory parameters were removed and a new one was added). Added the dataset purpose to the output of the `llama-stack-cli datasets list` command. Signed-off-by: Josh Salomon --- .../lib/cli/datasets/list.py | 2 +- .../lib/cli/datasets/register.py | 26 +++++++------------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/llama_stack_client/lib/cli/datasets/list.py b/src/llama_stack_client/lib/cli/datasets/list.py index 8e21ad0d..61d625c9 100644 --- a/src/llama_stack_client/lib/cli/datasets/list.py +++ b/src/llama_stack_client/lib/cli/datasets/list.py @@ -19,7 +19,7 @@ def list_datasets(ctx): """Show available datasets on distribution endpoint""" client = ctx.obj["client"] console = Console() - headers = ["identifier", "provider_id", "metadata", "type"] + headers = ["identifier", "provider_id", "metadata", "type", "purpose"] datasets_list_response = client.datasets.list() if datasets_list_response: diff --git a/src/llama_stack_client/lib/cli/datasets/register.py b/src/llama_stack_client/lib/cli/datasets/register.py index 54c164d1..d990e30c 100644 --- a/src/llama_stack_client/lib/cli/datasets/register.py +++ b/src/llama_stack_client/lib/cli/datasets/register.py @@ -7,7 +7,7 @@ import json import mimetypes import os -from typing import Optional +from typing import Optional, Literal import click import yaml @@ -32,34 +32,30 @@ def data_url_from_file(file_path: str) -> str: @click.command("register") @click.help_option("-h", "--help") @click.option("--dataset-id", required=True, help="Id of the dataset") -@click.option("--provider-id", help="Provider ID for the dataset", default=None) -@click.option("--provider-dataset-id", help="Provider's dataset ID", default=None) +@click.option( + "--purpose", + type=click.Choice(["post-training/messages", "eval/question-answer", "eval/messages-answer"]), + help="Purpose of the dataset", + required=True, +) @click.option("--metadata", type=str, help="Metadata of the dataset") @click.option("--url", type=str, help="URL of the dataset", required=False) @click.option( "--dataset-path", required=False, help="Local file path to the dataset. If specified, upload dataset via URL" ) -@click.option("--schema", type=str, help="JSON schema of the dataset", required=True) @click.pass_context @handle_client_errors("register dataset") def register( ctx, dataset_id: str, - provider_id: Optional[str], - provider_dataset_id: Optional[str], + purpose: Literal["post-training/messages", "eval/question-answer", "eval/messages-answer"], metadata: Optional[str], url: Optional[str], dataset_path: Optional[str], - schema: str, ): """Create a new dataset""" client = ctx.obj["client"] - try: - dataset_schema = json.loads(schema) - except json.JSONDecodeError as err: - raise click.BadParameter("Schema must be valid JSON") from err - if metadata: try: metadata = json.loads(metadata) @@ -74,11 +70,9 @@ def register( response = client.datasets.register( dataset_id=dataset_id, - dataset_schema=dataset_schema, - url={"uri": url}, - provider_id=provider_id, - provider_dataset_id=provider_dataset_id, + source={"uri": url}, metadata=metadata, + purpose=purpose, ) if response: click.echo(yaml.dump(response.dict())) From 5582e3bb03454d642168626595f196116f20d8d3 Mon Sep 17 00:00:00 2001 From: Josh Salomon Date: Tue, 15 Apr 2025 21:32:09 +0300 Subject: [PATCH 2/2] Updated CLI documentation (generated) The cli_reference.md was re-generated with the updated generator A small change in the doc generator to have the full help text instead of the short one (which is truncated after 45 chars) for the commands Signed-off-by: Josh Salomon --- docs/cli_reference.md | 78 ++++++++++++++++++++++++++++++------------ scripts/gen_cli_doc.py | 2 +- 2 files changed, 58 insertions(+), 22 deletions(-) diff --git a/docs/cli_reference.md b/docs/cli_reference.md index d3e403b7..48f36323 100644 --- a/docs/cli_reference.md +++ b/docs/cli_reference.md @@ -80,10 +80,12 @@ Usage: llama-stack-client datasets [OPTIONS] COMMAND [ARGS]... **Commands** -* **list**: Show available datasets on distribution... +* **list**: Show available datasets on distribution endpoint * **register**: Create a new dataset +* **unregister**: Remove a dataset + ### list @@ -114,9 +116,7 @@ Usage: llama-stack-client datasets register [OPTIONS] * **--dataset-id**: Id of the dataset -* **--provider-id**: Provider ID for the dataset - -* **--provider-dataset-id**: Provider's dataset ID +* **--purpose**: Purpose of the dataset * **--metadata**: Metadata of the dataset @@ -124,7 +124,23 @@ Usage: llama-stack-client datasets register [OPTIONS] * **--dataset-path**: Local file path to the dataset. If specified, upload dataset via URL -* **--schema**: JSON schema of the dataset + + +### unregister + +Remove a dataset + +``` +Usage: llama-stack-client datasets unregister [OPTIONS] DATASET_ID +``` + +**Options** + +* **-h, --help**: Show this message and exit. [default: False] + +**Arguments** + +* **DATASET_ID** @@ -226,7 +242,7 @@ Usage: llama-stack-client eval-tasks [OPTIONS] COMMAND [ARGS]... **Commands** -* **list**: Show available eval tasks on distribution... +* **list**: Show available eval tasks on distribution endpoint * **register**: Register a new eval task @@ -286,7 +302,7 @@ Usage: llama-stack-client inference [OPTIONS] COMMAND [ARGS]... **Commands** -* **chat-completion**: Show available inference chat completion... +* **chat-completion**: Show available inference chat completion endpoints on distribution endpoint @@ -326,7 +342,7 @@ Usage: llama-stack-client inspect [OPTIONS] COMMAND [ARGS]... **Commands** -* **version**: Show available providers on distribution... +* **version**: Show available providers on distribution endpoint @@ -358,9 +374,9 @@ Usage: llama-stack-client models [OPTIONS] COMMAND [ARGS]... **Commands** -* **get**: Show available llama models at distribution... +* **get**: Show details of a specific model at the distribution endpoint -* **list**: Show available llama models at distribution... +* **list**: Show available llama models at distribution endpoint * **register**: Register a new model at distribution endpoint @@ -370,7 +386,7 @@ Usage: llama-stack-client models [OPTIONS] COMMAND [ARGS]... ### get -Show available llama models at distribution endpoint +Show details of a specific model at the distribution endpoint ``` Usage: llama-stack-client models get [OPTIONS] MODEL_ID @@ -456,13 +472,13 @@ Usage: llama-stack-client post-training [OPTIONS] COMMAND [ARGS]... **Commands** -* **artifacts**: Get the training artifacts of a specific post... +* **artifacts**: Get the training artifacts of a specific post training job * **cancel**: Cancel the training job * **list**: Show the list of available post training jobs -* **status**: Show the status of a specific post training... +* **status**: Show the status of a specific post training job * **supervised_fine_tune**: Kick off a supervised fine tune job @@ -569,7 +585,27 @@ Usage: llama-stack-client providers [OPTIONS] COMMAND [ARGS]... **Commands** -* **list**: Show available providers on distribution... +* **inspect**: Show available providers on distribution endpoint + +* **list**: Show available providers on distribution endpoint + + + +### inspect + +Show available providers on distribution endpoint + +``` +Usage: llama-stack-client providers inspect [OPTIONS] PROVIDER_ID +``` + +**Options** + +* **--help**: Show this message and exit. [default: False] + +**Arguments** + +* **PROVIDER_ID** @@ -601,7 +637,7 @@ Usage: llama-stack-client scoring-functions [OPTIONS] COMMAND [ARGS]... **Commands** -* **list**: Show available scoring functions on... +* **list**: Show available scoring functions on distribution endpoint * **register**: Register a new scoring function @@ -661,7 +697,7 @@ Usage: llama-stack-client shields [OPTIONS] COMMAND [ARGS]... **Commands** -* **list**: Show available safety shields on distribution... +* **list**: Show available safety shields on distribution endpoint * **register**: Register a new safety shield @@ -717,13 +753,13 @@ Usage: llama-stack-client toolgroups [OPTIONS] COMMAND [ARGS]... **Commands** -* **get**: Show available llama toolgroups at... +* **get**: Show available llama toolgroups at distribution endpoint -* **list**: Show available llama toolgroups at... +* **list**: Show available llama toolgroups at distribution endpoint -* **register**: Register a new toolgroup at distribution... +* **register**: Register a new toolgroup at distribution endpoint -* **unregister**: Unregister a toolgroup from distribution... +* **unregister**: Unregister a toolgroup from distribution endpoint @@ -817,7 +853,7 @@ Usage: llama-stack-client vector-dbs [OPTIONS] COMMAND [ARGS]... **Commands** -* **list**: Show available vector dbs on distribution... +* **list**: Show available vector dbs on distribution endpoint * **register**: Create a new vector db diff --git a/scripts/gen_cli_doc.py b/scripts/gen_cli_doc.py index 859b88d2..53aea424 100644 --- a/scripts/gen_cli_doc.py +++ b/scripts/gen_cli_doc.py @@ -56,7 +56,7 @@ def generate_markdown_docs(command, parent=None, level=1): doc.append("**Commands**\n") for cmd_name in command.list_commands(ctx): cmd = command.get_command(ctx, cmd_name) - cmd_help = cmd.get_short_help_str() if cmd else "" + cmd_help = cmd.get_short_help_str(limit=80) if cmd else "" doc.append(f"* **{cmd_name}**: {cmd_help}\n") # Add detailed subcommand documentation