guidellm.utils.click_pydantic
RegistryAwareCommand
Bases: Command
Command subclass that enriches missing-argument errors for registry options.
When Click's parser raises BadOptionUsage for a registry-backed option (e.g. bare --constraint with no value), this override catches it and re-raises a BadParameter with the expected format and valid kinds.
Source code in src/guidellm/utils/click_pydantic.py
parse_args(ctx, args)
Override to intercept missing-value errors for registry options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | Click context | required |
args | list[str] | Command-line arguments to parse | required |
Returns:
| Type | Description |
|---|---|
list[str] | Remaining arguments after parsing |
Source code in src/guidellm/utils/click_pydantic.py
RegistryConfigOption
Bases: Option
Click option subclass that carries a reference to its registry type.
Used by :class:RegistryAwareCommand to enrich missing-argument errors with the expected format and valid kinds.
Source code in src/guidellm/utils/click_pydantic.py
format_kind_config_usage(registry_type)
Build a self-documenting usage hint for a registry-backed config option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry_type | type[PydanticClassRegistryMixin] | The | required |
Returns:
| Type | Description |
|---|---|
str | Multi-line string describing expected format and valid kinds |
Source code in src/guidellm/utils/click_pydantic.py
format_validation_errors(ctx, err, base_class=None)
Translate a pydantic ValidationError into a click.BadParameter error.
Includes the top-level field names and full location paths, such as data[0].synthetic_text.output_tokens, so callers can identify which nested subfield failed rather than only the top-level CLI option.
For registry shape failures where the stock message does not list kinds (non-object input), appends a usage hint with expected format and valid kinds. Invalid kind tags are left as-is because pydantic already lists them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The active Click context | required |
err | ValidationError | The pydantic validation error to translate | required |
base_class | type[BaseModel] | None | Optional root model class for resolving argument aliases | None |
Returns:
| Type | Description |
|---|---|
BadParameter | A |
Source code in src/guidellm/utils/click_pydantic.py
registry_option(*param_decls, registry, multiple=False, **extra)
Click option decorator for PydanticClassRegistryMixin-backed fields.
Produces a --name <config> option where <config> is a single comma-separated key=value string (e.g. kind=constant,rate=10).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param_decls | str | Click-style parameter declarations (e.g. | () |
registry | type[PydanticClassRegistryMixin] | A | required |
multiple | bool | When | False |
extra | Any | Additional keyword arguments forwarded to | {} |
Returns:
| Type | Description |
|---|---|
| A decorator that adds the option to a Click command |
Source code in src/guidellm/utils/click_pydantic.py
registry_options_from_model(model, group_key=None)
Decorator factory that introspects a Pydantic model and generates click.option decorators for each registry-backed field.
Each field in the model that has a schema_discriminator attribute gets a CLI option accepting a single comma-separated key=value string (e.g. --profile kind=constant,rate=10). All parsed values are aggregated into a group kwarg passed to the decorated function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model | type[BaseModel] | A Pydantic model class whose fields are | required |
group_key | str | None | Optional key under which to group all registry values | None |
Returns:
| Type | Description |
|---|---|
| A decorator that adds click options and wraps the function |