aea.configurations.loader
Implementation of the parser for configuration file.
_
for tests compatibility
BaseConfigLoader Objects
class BaseConfigLoader()
Base class for configuration loader classes.
__init__
def __init__(schema_filename: str) -> None
Initialize the parser for configuration files.
Arguments:
schema_filename: the path to the JSON-schema file in 'aea/configurations/schemas'.
validator
@property
def validator() -> ConfigValidator
Get the json schema validator.
validate
def validate(json_data: Dict) -> None
Validate a JSON object.
Arguments:
json_data: the JSON data.
required_fields
@property
def required_fields() -> List[str]
Get the required fields.
Returns:
list of required fields.
ConfigLoader Objects
class ConfigLoader(Generic[T], BaseConfigLoader)
Parsing, serialization and validation for package configuration files.
__init__
def __init__(schema_filename: str,
configuration_class: Type[T],
skip_aea_validation: bool = True) -> None
Initialize the parser for configuration files.
Arguments:
schema_filename: the path to the JSON-schema file in 'aea/configurations/schemas'.configuration_class: the configuration class (e.g. AgentConfig, SkillConfig etc.)skip_aea_validation: if True, the validation of the AEA version is skipped.
configuration_class
@property
def configuration_class() -> Type[T]
Get the configuration class of the loader.
validate
def validate(json_data: Dict) -> None
Validate a JSON representation of an AEA package.
First, checks whether the AEA version is compatible with the configuration file. Then, validates the JSON object against the specific schema.
Arguments:
json_data: the JSON data.
load_protocol_specification
def load_protocol_specification(file_pointer: TextIO) -> ProtocolSpecification
Load an agent configuration file.
Arguments:
file_pointer: the file pointer to the configuration file
Raises:
ValueError: If there are incorrect number of YAML documents provided
Returns:
the configuration object.
load
def load(file_pointer: TextIO) -> T
Load a configuration file.
Arguments:
file_pointer: the file pointer to the configuration file
Returns:
the configuration object.
dump
def dump(configuration: T, file_pointer: TextIO) -> None
Dump a configuration.
Arguments:
configuration: the configuration to be dumped.file_pointer: the file pointer to the configuration file
from_configuration_type
@classmethod
def from_configuration_type(cls,
configuration_type: Union[PackageType, str],
package_type_config_class: Optional[Dict] = None,
**kwargs: Any) -> "ConfigLoader"
Get the configuration loader from the type.
Arguments:
configuration_type: the type of configurationpackage_type_config_class: PackageType to config file mappingskwargs: keyword arguments to the configuration loader constructor.
Returns:
the configuration loader
load_agent_config_from_json
def load_agent_config_from_json(configuration_json: List[Dict],
validate: bool = True) -> AgentConfig
Load agent configuration from configuration json data.
Arguments:
configuration_json: list of dicts with agent configurationvalidate: whether to validate or not
Returns:
AgentConfig instance
ConfigLoaders Objects
class ConfigLoaders()
Configuration Loader class to load any package type.
from_package_type
@classmethod
def from_package_type(cls,
configuration_type: Union[PackageType, str],
package_type_config_class: Optional[Dict] = None,
**kwargs: Any) -> "ConfigLoader"
Get a config loader from the configuration type.
Arguments:
configuration_type: the configuration type.package_type_config_class: PackageType to config file mappingskwargs: keyword arguments to the configuration loader constructor.
Returns:
configuration loader
load_component_configuration
def load_component_configuration(
component_type: ComponentType,
directory: Path,
skip_consistency_check: bool = False,
skip_aea_validation: bool = True) -> ComponentConfiguration
Load configuration and check that it is consistent against the directory.
Arguments:
component_type: the component type.directory: the root of the packageskip_consistency_check: if True, the consistency check are skipped.skip_aea_validation: if True, the validation of the AEA version is skipped.
Returns:
the configuration object.
load_package_configuration
def load_package_configuration(
package_type: PackageType,
directory: Path,
skip_consistency_check: bool = False,
skip_aea_validation: bool = True) -> PackageConfiguration
Load configuration and check that it is consistent against the directory.
Arguments:
package_type: the package type.directory: the root of the packageskip_consistency_check: if True, the consistency check are skipped.skip_aea_validation: if True, the validation of the AEA version is skipped.
Returns:
the configuration object.
load_configuration_object
def load_configuration_object(
package_type: PackageType,
directory: Path,
package_type_config_class: Optional[Dict] = None,
skip_aea_validation: bool = True) -> PackageConfiguration
Load the configuration object, without consistency checks.
Arguments:
package_type: the package type.directory: the directory of the configuration.package_type_config_class: PackageType to config file mappingsskip_aea_validation: if True, the validation of the AEA version is skipped.
Raises:
FileNotFoundError: if the configuration file is not found.
Returns:
the configuration object.
load_protocol_specification_from_string
def load_protocol_specification_from_string(
specification_content: str) -> ProtocolSpecification
Load a protocol specification from string.