actableai.parameters package

Submodules

actableai.parameters.base module

class actableai.parameters.base.BaseParameter(*, name: str, display_name: str, description: Optional[str] = None, parameter_type: actableai.parameters.type.ParameterType, default: Optional[Any] = None, hidden: bool = False)

Bases: actableai.parameters.base.NamedParameter, actableai.parameters.base.ProcessableParameter

Base class representing a parameter.

default: Optional[Any]
get_default() Any

Return default value for the parameter.

Returns
Default value.
hidden: bool
parameter_type: actableai.parameters.type.ParameterType
process_parameter(value: Any) Any

Process a value using the current parameter.

Parameters
value – Value to process.
Returns
Processed value.
validate_parameter(value: Any, ignore_extra: bool = False) actableai.parameters.validation.ParameterValidationErrors

Validate value using the current parameter.

Parameters
  • value – Value to validate.
  • ignore_extra – If True will ignore extra fields.
Returns

ParameterValidationErrors object containing the validation errors.

class actableai.parameters.base.NamedParameter(*, name: str, display_name: str, description: Optional[str] = None)

Bases: pydantic.main.BaseModel

Base class representing a parameter with a name.

description: Optional[str]
display_name: str
name: str
class actableai.parameters.base.ProcessableParameter

Bases: actableai.parameters.base.ValidatableParameter, abc.ABC

Abstract class representing a processable parameter (also validatable).

abstract process_parameter(value: Any) Any

Process a value using the current parameter.

Parameters
value – Value to process.
Returns
Processed value.
validate_process_parameter(value: Any, ignore_extra: bool = False) Tuple[actableai.parameters.validation.ParameterValidationErrors, Any]

Validate and process value using current parameter.

Parameters
  • value – Value to validate and process.
  • ignore_extra – If True will ignore extra fields.
Returns

  • ParameterValidationErrors object containing the validation errors.
  • Processed value.

class actableai.parameters.base.ValidatableParameter

Bases: abc.ABC

Abstract class representing a validatable parameter.

abstract validate_parameter(value: Any, ignore_extra: bool = False) actableai.parameters.validation.ParameterValidationErrors

Validate value using the current parameter.

Parameters
  • value – Value to validate.
  • ignore_extra – If True will ignore extra fields.
Returns

ParameterValidationErrors object containing the validation errors.

actableai.parameters.boolean module

actableai.parameters.boolean.BooleanListParameter

alias of actableai.parameters.boolean.ListParameter[bool]

actableai.parameters.boolean.BooleanParameter

alias of actableai.parameters.boolean.ValueParameter[bool]

class actableai.parameters.boolean.BooleanSpace(*, name: <pydantic.fields.DeferredType object at 0x7f5e21a2a280>, display_name: <pydantic.fields.DeferredType object at 0x7f5e21a2a310>, description: <pydantic.fields.DeferredType object at 0x7f5e21a2a400> = None, parameter_type: <pydantic.fields.DeferredType object at 0x7f5e21a2a4c0> = ParameterType.OPTIONS, default: <pydantic.fields.DeferredType object at 0x7f5e21a2a5e0> = [], hidden: <pydantic.fields.DeferredType object at 0x7f5e21a2a760> = False, dict_parameter: <pydantic.fields.DeferredType object at 0x7f5e21a2a850> = False, is_multi: <pydantic.fields.DeferredType object at 0x7f5e21a2a970> = True, options: typing.Dict[bool, pydantic.generics.Option[bool]] = {'false': Option(display_name='False', value=False), 'true': Option(display_name='True', value=True)})

Bases: actableai.parameters.boolean.OptionsSpace[bool]

Boolean space parameter.

options: Dict[bool, pydantic.generics.Option[bool]]

actableai.parameters.list module

class actableai.parameters.list.ListParameter(*, name: str, display_name: str, description: Optional[str] = None, parameter_type: actableai.parameters.type.ParameterType = ParameterType.LIST, default: Union[actableai.parameters.list.ListT, Tuple[actableai.parameters.list.ListT, ...], List[actableai.parameters.list.ListT]] = [], hidden: bool = False, value_type: actableai.parameters.type.ValueType = None, min_len: int = 0, max_len: Optional[int] = None)

Bases: actableai.parameters.base.BaseParameter, pydantic.generics.GenericModel, Generic[actableai.parameters.list.ListT]

TODO write documentation

classmethod check_default_len(values: Dict[str, Any]) Dict[str, Any]

Check default value using the current parameter.

Parameters
values – Values used to create the current parameter.
Returns
The validated dictionary containing the values used to create the current
parameters.
classmethod check_len(values: Dict[str, Any]) Dict[str, Any]

TODO write documentation

classmethod check_min_len(value: int) int

TODO write documentation

default: Union[actableai.parameters.list.ListT, Tuple[actableai.parameters.list.ListT, ...], List[actableai.parameters.list.ListT]]
max_len: Optional[int]
min_len: int
parameter_type: actableai.parameters.type.ParameterType
process_parameter(value: Any) Any

Process a value using the current parameter.

Parameters
value – Value to process.
Returns
Processed value.
classmethod set_default(value: Union[actableai.parameters.list.ListT, Tuple[actableai.parameters.list.ListT, ...], List[actableai.parameters.list.ListT]]) List[str]

Set default value.

Parameters
value – Current value of default.
Returns
New default value.
classmethod set_value_type(value: actableai.parameters.type.ValueType) actableai.parameters.type.ValueType

TODO write documentation

validate_parameter(value: Any, ignore_extra: bool = False) actableai.parameters.validation.ParameterValidationErrors

Validate value using the current parameter.

Parameters
  • value – Value to validate.
  • ignore_extra – If True will ignore extra fields.
Returns

ParameterValidationErrors object containing the validation errors.

value_type: actableai.parameters.type.ValueType

actableai.parameters.models module

actableai.parameters.models.ModelSpace

alias of actableai.parameters.models.OptionsSpace[Parameters]

actableai.parameters.numeric module

actableai.parameters.numeric.FloatParameter

alias of actableai.parameters.numeric._NumericParameter[float]

actableai.parameters.numeric.FloatRangeSpace

alias of actableai.parameters.numeric._NumericRangeSpace[float]

actableai.parameters.numeric.IntegerParameter

alias of actableai.parameters.numeric._NumericParameter[int]

actableai.parameters.numeric.IntegerRangeSpace

alias of actableai.parameters.numeric._NumericRangeSpace[int]

actableai.parameters.options module

class actableai.parameters.options.Option(*, display_name: str, value: actableai.parameters.options.OptionT = None)

Bases: pydantic.generics.GenericModel, Generic[actableai.parameters.options.OptionT]

Class to represent a simple option, used in OptionsParameter.

display_name: str
value: actableai.parameters.options.OptionT
class actableai.parameters.options.OptionsParameter(*, name: str, display_name: str, description: Optional[str] = None, parameter_type: actableai.parameters.type.ParameterType = ParameterType.OPTIONS, default: Union[str, List[str]] = [], hidden: bool = False, dict_parameter: bool = False, is_multi: bool, options: Dict[str, actableai.parameters.options.Option])

Bases: actableai.parameters.base.BaseParameter, pydantic.generics.GenericModel, Generic[actableai.parameters.options.OptionT]

Parameter representing options of type OptionT

classmethod check_default(values: Dict[str, Any]) Dict[str, Any]

Check default value using the current parameter.

Parameters
values – Values used to create the current parameter.
Returns
The validated dictionary containing the values used to create the current
parameters.
default: Union[str, List[str]]
dict_parameter: bool
get_available_options() Set[actableai.parameters.options.OptionT]

Returns available options.

Returns
Available options.
get_default()

Return default value for the parameter.

Returns
Default value.
is_multi: bool
options: Dict[str, actableai.parameters.options.Option]
parameter_type: actableai.parameters.type.ParameterType
process_parameter(value: Any) Any

Process a value using the current parameter.

Parameters
value – Value to process.
Returns
Processed value.
classmethod set_default(value: Union[str, List[str]]) List[str]

Set default value.

Parameters
value – Current value of default.
Returns
New default value.
classmethod set_dict_parameter(value: bool) bool

Set dict_parameter value.

Parameters
value – Current value of dict_parameter.
Returns
New dict_parameter value.
validate_parameter(value: Any, ignore_extra: bool = False) actableai.parameters.validation.ParameterValidationErrors

Validate value using the current parameter.

Parameters
  • value – Value to validate.
  • ignore_extra – If True will ignore extra fields.
Returns

ParameterValidationErrors object containing the validation errors.

class actableai.parameters.options.OptionsSpace(*, name: str, display_name: str, description: Optional[str] = None, parameter_type: actableai.parameters.type.ParameterType = ParameterType.OPTIONS, default: Union[str, List[str]] = [], hidden: bool = False, dict_parameter: bool = False, is_multi: bool = True, options: Dict[str, actableai.parameters.options.Option])

Bases: actableai.parameters.options.OptionsParameter, Generic[actableai.parameters.options.OptionT]

Parameter representing an options space.

is_multi: bool

actableai.parameters.parameters module

class actableai.parameters.parameters.Parameters(*, name: str, display_name: str, description: Optional[str] = None, parameter_type: actableai.parameters.type.ParameterType = ParameterType.PARAMETERS, default: Any = {}, hidden: bool = False, parameters: Union[Dict[str, actableai.parameters.base.BaseParameter], List[actableai.parameters.base.BaseParameter]])

Bases: actableai.parameters.base.BaseParameter

Class containing multiple parameters.

default: Any
parameter_type: actableai.parameters.type.ParameterType
parameters: Union[Dict[str, actableai.parameters.base.BaseParameter], List[actableai.parameters.base.BaseParameter]]
process_parameter(value: Any) Any

Process a value using the current parameter.

Parameters
value – Value to process.
Returns
Processed value.
classmethod set_parameters(value: Union[Dict[str, actableai.parameters.base.BaseParameter], List[actableai.parameters.base.BaseParameter]]) Dict[str, actableai.parameters.base.BaseParameter]

Set parameters value.

Parameters
value – Current value of parameters.
Returns
New parameters value.
validate_parameter(value: Any, ignore_extra: bool = False) actableai.parameters.validation.ParameterValidationErrors

Validate value using the current parameter.

Parameters
  • value – Value to validate.
  • ignore_extra – If True will ignore extra fields.
Returns

ParameterValidationErrors object containing the validation errors.

actableai.parameters.string module

actableai.parameters.string.StringListParameter

alias of actableai.parameters.string.ListParameter[str]

actableai.parameters.string.StringParameter

alias of actableai.parameters.string.ValueParameter[str]

actableai.parameters.type module

class actableai.parameters.type.ParameterType(value)

Bases: str, enum.Enum

Enum representing the different parameter types available.

LIST = 'list'
OPTIONS = 'options'
PARAMETERS = 'parameters'
VALUE = 'value'
class actableai.parameters.type.ValueType(value)

Bases: str, enum.Enum

TODO write documentation

BOOL = 'bool'
FLOAT = 'float'
INT = 'int'
STR = 'str'

actableai.parameters.validation module

class actableai.parameters.validation.InvalidKeyError(*, parameter_name: str, message: Optional[str] = None, parent_parameter_list: List[str] = [], key: str)

Bases: actableai.parameters.validation.ParameterValidationError

Class representing a parameter invalid key error.

key: str
classmethod set_message(values: Dict[str, Any]) Dict[str, Any]

Set message value.

Parameters
values – Dictionary containing the current value of the message.
Returns
Updated dictionary containing the correct message.
class actableai.parameters.validation.OutOfRangeError(*, parameter_name: str, message: Optional[str] = None, parent_parameter_list: List[str] = [], min: Optional[Union[int, float]] = None, max: Optional[Union[int, float]] = None, given: Union[int, float])

Bases: actableai.parameters.validation.ParameterValidationError

Class representing a parameter out of range error.

given: Union[int, float]
max: Optional[Union[int, float]]
min: Optional[Union[int, float]]
classmethod set_message(values: Dict[str, Any]) Dict[str, Any]

Set message value.

Parameters
values – Dictionary containing the current value of the message.
Returns
Updated dictionary containing the correct message.
class actableai.parameters.validation.ParameterTypeError(*, parameter_name: str, message: Optional[str] = None, parent_parameter_list: List[str] = [], expected_type: Union[actableai.parameters.type.ParameterType, actableai.parameters.type.ValueType, str], given_type: str)

Bases: actableai.parameters.validation.ParameterValidationError

Class representing a parameter type error.

expected_type: Union[actableai.parameters.type.ParameterType, actableai.parameters.type.ValueType, str]
given_type: str
classmethod set_message(values: Dict[str, Any]) Dict[str, Any]

Set message value.

Parameters
values – Dictionary containing the current value of the message.
Returns
Updated dictionary containing the correct message.
class actableai.parameters.validation.ParameterValidationError(*, parameter_name: str, message: Optional[str] = None, parent_parameter_list: List[str] = [])

Bases: pydantic.main.BaseModel

Class representing a parameter validation error.

add_parent(parameter_name: str)

Add a new parent to the error.

Parameters
parameter_name – Name of the parent.
message: Optional[str]
parameter_name: str
parent_parameter_list: List[str]
property path: str

Compute the path of the error.

Returns
Error path.
class actableai.parameters.validation.ParameterValidationErrors(*, parameter_name: str, validation_error_list: List[actableai.parameters.validation.ParameterValidationError] = [])

Bases: pydantic.main.BaseModel

Class representing a multiple validation errors.

add_error(error: actableai.parameters.validation.ParameterValidationError)

Add a new error.

Parameters
error – New error to add.
add_errors(errors: actableai.parameters.validation.ParameterValidationErrors)

Concatenate two ParameterValidationErrors.

Parameters
errors – Other ParameterValidationErrors to concatenate.
has_error(error_type: Type[actableai.parameters.validation.ParameterValidationError]) bool

Check whether the current object contains any error of a specific type.

Parameters
error_type – Type of the error to look for.
Returns
True if the error_type has been found in the current errors.
parameter_name: str
to_check_results(name: str) List[actableai.data_validation.base.CheckResult]

Convert to CheckResult list.

Parameters
name – Name of the CheckResult.
Returns
List of CheckResult objects.
to_exception() ValueError
validation_error_list: List[actableai.parameters.validation.ParameterValidationError]

actableai.parameters.value module

class actableai.parameters.value.ValueParameter(*, name: str, display_name: str, description: Optional[str] = None, parameter_type: actableai.parameters.type.ParameterType = ParameterType.VALUE, default: Optional[actableai.parameters.value.ValueT] = None, hidden: bool = False, value_type: actableai.parameters.type.ValueType = None)

Bases: actableai.parameters.base.BaseParameter, pydantic.generics.GenericModel, Generic[actableai.parameters.value.ValueT]

TODO write documentation

default: Optional[actableai.parameters.value.ValueT]
parameter_type: actableai.parameters.type.ParameterType
classmethod set_value_type(value_type: actableai.parameters.type.ValueType) actableai.parameters.type.ValueType

TODO write documentation

validate_parameter(value: Any, ignore_extra: bool = False) actableai.parameters.validation.ParameterValidationErrors

Validate value using the current parameter.

Parameters
  • value – Value to validate.
  • ignore_extra – If True will ignore extra fields.
Returns

ParameterValidationErrors object containing the validation errors.

value_type: actableai.parameters.type.ValueType

Module contents