1 configs.optimizable
configs.optimizable
Optuna-friendly search space helpers.
This mirrors the utility layer from external/doc_classifier so aria_nbv configs can declare Optuna search spaces declaratively via optimizable_field.
The core idea is:
- attach an
Optimizableinstance to a PydanticFieldviajson_schema_extra={"optimizable": ...}, - have an Optuna-aware orchestration layer traverse the config tree and apply trial suggestions before constructing runtime objects.
1.1 Classes
| Name | Description |
|---|---|
| Optimizable | Declarative description of an optimisable parameter. |
1.1.1 Optimizable
configs.optimizable.Optimizable()Declarative description of an optimisable parameter.
The class intentionally avoids importing Optuna at runtime so the rest of the package can be used without the optional dependency. The trial argument is treated duck-typed (expects suggest_float/int/categorical methods).
1.1.1.1 Attributes
| Name | Description |
|---|---|
| target | Type of the parameter (int, float, bool, str, Enum). |
| low | Lower bound for numeric spaces. |
| high | Upper bound for numeric spaces. |
| step | Step used for discrete integer suggestions. |
| categories | Explicit set of categorical choices (or Enum members). |
| log | Use logarithmic sampling for numeric spaces. |
| name | Optional override for the Optuna parameter name. |
| default | Default value used outside Optuna trials. |
| description | Human readable description of the parameter. |
| relies_on | Optional dependency map: {param_path: (accepted_values,…)}. |
1.1.1.2 Methods
| Name | Description |
|---|---|
| continuous | Describe a bounded floating-point search space. |
| discrete | Describe a bounded integer search space with a fixed step. |
| categorical | Describe a search space over an explicit finite choice set. |
| suggest | Sample a value from Optuna. |
| serialize | Convert a suggested value to a JSON/W&B friendly representation. |
1.1.1.2.1 continuous
configs.optimizable.Optimizable.continuous(
low,
high,
log=False,
name=None,
default=None,
description=None,
relies_on=None,
)Describe a bounded floating-point search space.
1.1.1.2.2 discrete
configs.optimizable.Optimizable.discrete(
low,
high,
step=1,
log=False,
name=None,
default=None,
description=None,
relies_on=None,
)Describe a bounded integer search space with a fixed step.
1.1.1.2.3 categorical
configs.optimizable.Optimizable.categorical(
choices,
name=None,
default=None,
description=None,
relies_on=None,
)Describe a search space over an explicit finite choice set.
1.1.1.2.4 suggest
configs.optimizable.Optimizable.suggest(
trial,
path,
*,
current_value=None,
value_lookup=None,
)Sample a value from Optuna.
1.1.1.2.4.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| trial | 'optuna.Trial' | Optuna trial (duck-typed; must implement suggest_* APIs). | required |
| path | str | Default parameter name derived from the config path. | required |
1.1.1.2.4.2 Returns
| Name | Type | Description |
|---|---|---|
T |
Suggested value coerced into the requested target type. |
1.1.1.2.5 serialize
configs.optimizable.Optimizable.serialize(value)Convert a suggested value to a JSON/W&B friendly representation.
1.2 Functions
| Name | Description |
|---|---|
| optimizable_field | Attach an optimizable definition to a Pydantic Field. |
1.2.1 optimizable_field
configs.optimizable.optimizable_field(
default=None,
default_factory=None,
optimizable,
**field_kwargs,
)Attach an optimizable definition to a Pydantic Field.
Exactly one of default or default_factory must be provided.