4343 ComponentType ,
4444 ConnectionConfig ,
4545 ContractConfig ,
46- DEFAULT_AEA_CONFIG_FILE ,
4746 Dependencies ,
4847 PackageType ,
4948 ProtocolConfig ,
5049 PublicId ,
5150 SkillConfig ,
5251)
5352from aea .configurations .constants import (
53+ CONNECTIONS ,
54+ DEFAULT_AEA_CONFIG_FILE ,
5455 DEFAULT_CONNECTION ,
56+ DEFAULT_ENV_DOTFILE ,
5557 DEFAULT_LEDGER ,
5658 DEFAULT_PROTOCOL ,
59+ DEFAULT_REGISTRY_NAME ,
5760)
5861from aea .configurations .constants import (
5962 DEFAULT_SEARCH_SERVICE_ADDRESS as _DEFAULT_SEARCH_SERVICE_ADDRESS ,
6063)
6164from aea .configurations .constants import (
6265 DEFAULT_SKILL ,
66+ FETCHAI ,
67+ PROTOCOLS ,
6368 SIGNING_PROTOCOL ,
69+ SKILLS ,
6470 STATE_UPDATE_PROTOCOL ,
71+ VENDOR ,
6572)
6673from aea .configurations .loader import ConfigLoader , load_component_configuration
6774from aea .configurations .pypi import is_satisfiable , merge_dependencies
6875from aea .crypto .helpers import verify_or_create_private_keys
6976from aea .crypto .ledger_apis import DEFAULT_CURRENCY_DENOMINATIONS
7077from aea .crypto .wallet import Wallet
7178from aea .decision_maker .base import DecisionMakerHandler
72- from aea .exceptions import AEAException
79+ from aea .exceptions import AEAException , AEAValidationError
7380from aea .helpers .base import find_topological_order , load_env_file , load_module
7481from aea .helpers .exception_policy import ExceptionPolicyEnum
7582from aea .helpers .install_dependency import install_dependency
8188PathLike = Union [os .PathLike , Path , str ]
8289
8390_default_logger = logging .getLogger (__name__ )
84- DEFAULT_ENV_DOTFILE = ".env"
8591
8692
8793class _DependenciesManager :
@@ -281,7 +287,7 @@ class AEABuilder(WithLogger): # pylint: disable=too-many-public-methods
281287 """
282288
283289 DEFAULT_LEDGER = DEFAULT_LEDGER
284- DEFAULT_CONNECTION = DEFAULT_CONNECTION
290+ DEFAULT_CONNECTION = PublicId . from_str ( DEFAULT_CONNECTION )
285291 DEFAULT_CURRENCY_DENOMINATIONS = DEFAULT_CURRENCY_DENOMINATIONS
286292 DEFAULT_AGENT_ACT_PERIOD = 0.05 # seconds
287293 DEFAULT_EXECUTION_TIMEOUT = 0
@@ -297,7 +303,9 @@ class AEABuilder(WithLogger): # pylint: disable=too-many-public-methods
297303 # pylint: disable=attribute-defined-outside-init
298304
299305 def __init__ (
300- self , with_default_packages : bool = True , registry_dir : str = "packages"
306+ self ,
307+ with_default_packages : bool = True ,
308+ registry_dir : str = DEFAULT_REGISTRY_NAME ,
301309 ):
302310 """
303311 Initialize the builder.
@@ -516,24 +524,27 @@ def set_search_service_address(
516524 def _add_default_packages (self ) -> None :
517525 """Add default packages."""
518526 # add default protocol
527+ default_protocol = PublicId .from_str (DEFAULT_PROTOCOL )
519528 self .add_protocol (
520- Path (self .registry_dir , "fetchai" , "protocols" , DEFAULT_PROTOCOL .name )
529+ Path (self .registry_dir , FETCHAI , PROTOCOLS , default_protocol .name )
521530 )
522531 # add signing protocol
532+ signing_protocol = PublicId .from_str (SIGNING_PROTOCOL )
523533 self .add_protocol (
524- Path (self .registry_dir , "fetchai" , "protocols" , SIGNING_PROTOCOL .name )
534+ Path (self .registry_dir , FETCHAI , PROTOCOLS , signing_protocol .name )
525535 )
526536 # add state update protocol
537+ state_update_protocol = PublicId .from_str (STATE_UPDATE_PROTOCOL )
527538 self .add_protocol (
528- Path (self .registry_dir , "fetchai" , "protocols" , STATE_UPDATE_PROTOCOL .name )
539+ Path (self .registry_dir , FETCHAI , PROTOCOLS , state_update_protocol .name )
529540 )
530-
531541 # add stub connection
532542 self .add_connection (
533- Path (self .registry_dir , "fetchai" , "connections" , DEFAULT_CONNECTION .name )
543+ Path (self .registry_dir , FETCHAI , CONNECTIONS , self . DEFAULT_CONNECTION .name )
534544 )
535545 # add error skill
536- self .add_skill (Path (self .registry_dir , "fetchai" , "skills" , DEFAULT_SKILL .name ))
546+ default_skill = PublicId .from_str (DEFAULT_SKILL )
547+ self .add_skill (Path (self .registry_dir , FETCHAI , SKILLS , default_skill .name ))
537548
538549 def _check_can_remove (self , component_id : ComponentId ) -> None :
539550 """
@@ -1156,7 +1167,7 @@ def find_component_directory_from_component_id(
11561167 # search in vendor first
11571168 vendor_package_path = (
11581169 aea_project_directory
1159- / "vendor"
1170+ / VENDOR
11601171 / component_id .public_id .author
11611172 / component_id .component_type .to_plural ()
11621173 / component_id .public_id .name
@@ -1185,13 +1196,13 @@ def _try_to_load_agent_configuration_file(aea_project_path: Path) -> None:
11851196 agent_configuration = loader .load (fp )
11861197 logging .config .dictConfig (agent_configuration .logging_config ) # type: ignore
11871198 except FileNotFoundError : # pragma: nocover
1188- raise Exception (
1199+ raise ValueError (
11891200 "Agent configuration file '{}' not found in the current directory." .format (
11901201 DEFAULT_AEA_CONFIG_FILE
11911202 )
11921203 )
11931204 except jsonschema .exceptions .ValidationError : # pragma: nocover
1194- raise Exception (
1205+ raise AEAValidationError (
11951206 "Agent configuration file '{}' is invalid. Please check the documentation." .format (
11961207 DEFAULT_AEA_CONFIG_FILE
11971208 )
@@ -1345,9 +1356,9 @@ def _find_import_order(
13451356 if component_id not in dependency_to_supported_dependencies :
13461357 dependency_to_supported_dependencies [component_id ] = set ()
13471358 if isinstance (configuration , SkillConfig ):
1348- dependencies , component_type = configuration .skills , "skills"
1359+ dependencies , component_type = configuration .skills , SKILLS
13491360 elif isinstance (configuration , ConnectionConfig ):
1350- dependencies , component_type = configuration .connections , "connections"
1361+ dependencies , component_type = configuration .connections , CONNECTIONS
13511362 else :
13521363 raise AEAException ("Not a valid configuration type." ) # pragma: nocover
13531364 for dependency in dependencies :
0 commit comments