6565)
6666from aea .configurations .constants import (
6767 DEFAULT_CONNECTION ,
68+ DEFAULT_LEDGER ,
6869 DEFAULT_PROTOCOL ,
6970 DEFAULT_SKILL ,
7071)
@@ -208,6 +209,7 @@ def remove_component(self, component_id: ComponentId):
208209 component = self ._dependencies .pop (component_id )
209210 # remove from the index of all dependencies grouped by type
210211 self ._all_dependencies_by_type [component_id .component_type ].pop (component_id )
212+
211213 if len (self ._all_dependencies_by_type [component_id .component_type ]) == 0 :
212214 self ._all_dependencies_by_type .pop (component_id .component_type )
213215 # remove from prefix to id index
@@ -236,14 +238,6 @@ def pypi_dependencies(self) -> Dependencies:
236238 )
237239 return all_pypi_dependencies
238240
239- @staticmethod
240- def _build_dotted_part (component , relative_import_path ) -> str :
241- """Given a component, build a dotted path for import."""
242- if relative_import_path == "" :
243- return component .prefix_import_path
244- else :
245- return component .prefix_import_path + "." + relative_import_path
246-
247241
248242class AEABuilder :
249243 """
@@ -302,7 +296,7 @@ class AEABuilder:
302296 DEFAULT_SKILL_EXCEPTION_POLICY = ExceptionPolicyEnum .propagate
303297 DEFAULT_LOOP_MODE = "async"
304298 DEFAULT_RUNTIME_MODE = "threaded"
305- DEFAULT_SEARCH_SERVICE_ADDRESS = "oef "
299+ DEFAULT_SEARCH_SERVICE_ADDRESS = "fetchai/soef:* "
306300
307301 # pylint: disable=attribute-defined-outside-init
308302
@@ -352,10 +346,7 @@ def _reset(self, is_full_reset: bool = False) -> None:
352346 self ._build_called : bool = False
353347 if not is_full_reset :
354348 return
355- self ._ledger_apis_configs = {} # type: Dict[str, Dict[str, Union[str, int]]]
356- self ._default_ledger = (
357- "fetchai" # set by the user, or instantiate a default one.
358- )
349+ self ._default_ledger = DEFAULT_LEDGER
359350 self ._default_connection : PublicId = DEFAULT_CONNECTION
360351 self ._context_namespace = {} # type: Dict[str, Any]
361352 self ._timeout : Optional [float ] = None
@@ -430,7 +421,7 @@ def set_decision_maker_handler(
430421 try :
431422 _class = getattr (module , class_name )
432423 self ._decision_maker_handler_class = _class
433- except Exception as e :
424+ except Exception as e : # pragma: nocover
434425 logger .error (
435426 "Could not locate decision maker handler for dotted path '{}', class name '{}' and file path '{}'. Error message: {}" .format (
436427 dotted_path , class_name , file_path , e
@@ -442,7 +433,7 @@ def set_decision_maker_handler(
442433
443434 def set_skill_exception_policy (
444435 self , skill_exception_policy : Optional [ExceptionPolicyEnum ]
445- ) -> "AEABuilder" :
436+ ) -> "AEABuilder" : # pragma: nocover
446437 """
447438 Set skill exception policy.
448439
@@ -465,10 +456,12 @@ def set_default_routing(
465456
466457 :return: self
467458 """
468- self ._default_routing = default_routing
459+ self ._default_routing = default_routing # pragma: nocover
469460 return self
470461
471- def set_loop_mode (self , loop_mode : Optional [str ]) -> "AEABuilder" :
462+ def set_loop_mode (
463+ self , loop_mode : Optional [str ]
464+ ) -> "AEABuilder" : # pragma: nocover
472465 """
473466 Set the loop mode.
474467
@@ -478,7 +471,9 @@ def set_loop_mode(self, loop_mode: Optional[str]) -> "AEABuilder":
478471 self ._loop_mode = loop_mode
479472 return self
480473
481- def set_runtime_mode (self , runtime_mode : Optional [str ]) -> "AEABuilder" :
474+ def set_runtime_mode (
475+ self , runtime_mode : Optional [str ]
476+ ) -> "AEABuilder" : # pragma: nocover
482477 """
483478 Set the runtime mode.
484479
@@ -488,7 +483,9 @@ def set_runtime_mode(self, runtime_mode: Optional[str]) -> "AEABuilder":
488483 self ._runtime_mode = runtime_mode
489484 return self
490485
491- def set_search_service_address (self , search_service_address : str ) -> "AEABuilder" :
486+ def set_search_service_address (
487+ self , search_service_address : str
488+ ) -> "AEABuilder" : # pragma: nocover
492489 """
493490 Set the search service address.
494491
@@ -533,7 +530,7 @@ def _check_can_add(self, configuration: ComponentConfiguration) -> None:
533530 self ._check_package_dependencies (configuration )
534531 self ._check_pypi_dependencies (configuration )
535532
536- def set_name (self , name : str ) -> "AEABuilder" :
533+ def set_name (self , name : str ) -> "AEABuilder" : # pragma: nocover
537534 """
538535 Set the name of the agent.
539536
@@ -543,7 +540,9 @@ def set_name(self, name: str) -> "AEABuilder":
543540 self ._name = name
544541 return self
545542
546- def set_default_connection (self , public_id : PublicId ) -> "AEABuilder" :
543+ def set_default_connection (
544+ self , public_id : PublicId
545+ ) -> "AEABuilder" : # pragma: nocover
547546 """
548547 Set the default connection.
549548
@@ -606,33 +605,7 @@ def connection_private_key_paths(self) -> Dict[str, Optional[str]]:
606605 """Get the connection private key paths."""
607606 return self ._connection_private_key_paths
608607
609- def add_ledger_api_config (self , identifier : str , config : Dict ) -> "AEABuilder" :
610- """
611- Add a configuration for a ledger API to be supported by the agent.
612-
613- :param identifier: the identifier of the ledger api
614- :param config: the configuration of the ledger api
615- :return: the AEABuilder
616- """
617- self ._ledger_apis_configs [identifier ] = config
618- return self
619-
620- def remove_ledger_api_config (self , identifier : str ) -> "AEABuilder" :
621- """
622- Remove a ledger API configuration.
623-
624- :param identifier: the identifier of the ledger api
625- :return: the AEABuilder
626- """
627- self ._ledger_apis_configs .pop (identifier , None )
628- return self
629-
630- @property
631- def ledger_apis_config (self ) -> Dict [str , Dict [str , Union [str , int ]]]:
632- """Get the ledger api configurations."""
633- return self ._ledger_apis_configs
634-
635- def set_default_ledger (self , identifier : str ) -> "AEABuilder" :
608+ def set_default_ledger (self , identifier : str ) -> "AEABuilder" : # pragma: nocover
636609 """
637610 Set a default ledger API to use.
638611
@@ -689,7 +662,9 @@ def add_component_instance(self, component: Component) -> "AEABuilder":
689662 ] = component
690663 return self
691664
692- def set_context_namespace (self , context_namespace : Dict [str , Any ]) -> "AEABuilder" :
665+ def set_context_namespace (
666+ self , context_namespace : Dict [str , Any ]
667+ ) -> "AEABuilder" : # pragma: nocover
693668 """Set the context namespace."""
694669 self ._context_namespace = context_namespace
695670 return self
@@ -1123,13 +1098,13 @@ def _try_to_load_agent_configuration_file(aea_project_path: Path) -> None:
11231098 loader = ConfigLoader .from_configuration_type (PackageType .AGENT )
11241099 agent_configuration = loader .load (fp )
11251100 logging .config .dictConfig (agent_configuration .logging_config ) # type: ignore
1126- except FileNotFoundError :
1101+ except FileNotFoundError : # pragma: nocover
11271102 raise Exception (
11281103 "Agent configuration file '{}' not found in the current directory." .format (
11291104 DEFAULT_AEA_CONFIG_FILE
11301105 )
11311106 )
1132- except jsonschema .exceptions .ValidationError :
1107+ except jsonschema .exceptions .ValidationError : # pragma: nocover
11331108 raise Exception (
11341109 "Agent configuration file '{}' is invalid. Please check the documentation." .format (
11351110 DEFAULT_AEA_CONFIG_FILE
@@ -1198,13 +1173,6 @@ def set_from_configuration(
11981173 ledger_identifier , private_key_path , is_connection = True
11991174 )
12001175
1201- # load ledger API configurations
1202- for (
1203- ledger_identifier ,
1204- ledger_api_conf ,
1205- ) in agent_configuration .ledger_apis_dict .items ():
1206- self .add_ledger_api_config (ledger_identifier , ledger_api_conf )
1207-
12081176 component_ids = itertools .chain (
12091177 [
12101178 ComponentId (ComponentType .PROTOCOL , p_id )
@@ -1284,6 +1252,7 @@ def _find_import_order(
12841252
12851253 if len (configuration .skills ) != 0 :
12861254 roots .remove (skill_id )
1255+
12871256 depends_on [skill_id ].update (
12881257 [
12891258 ComponentId (ComponentType .SKILL , skill )
@@ -1300,7 +1269,9 @@ def _find_import_order(
13001269 while len (queue ) > 0 :
13011270 current = queue .pop ()
13021271 order .append (current )
1303- for node in supports [current ]:
1272+ for node in supports [
1273+ current
1274+ ]: # pragma: nocover # TODO: extract method and test properly
13041275 depends_on [node ].discard (current )
13051276 if len (depends_on [node ]) == 0 :
13061277 queue .append (node )
@@ -1405,7 +1376,7 @@ def _populate_contract_registry(self):
14051376 class_kwargs = {"contract_interface" : contract_interface },
14061377 contract_config = configuration , # TODO: resolve configuration being applied globally
14071378 )
1408- except AEAException as e :
1379+ except AEAException as e : # pragma: nocover
14091380 if "Cannot re-register id:" in str (e ):
14101381 logger .warning (
14111382 "Already registered: {}" .format (configuration .class_name )
@@ -1452,7 +1423,7 @@ def _verify_or_create_private_keys(aea_project_path: Path) -> None:
14521423
14531424 for identifier , _value in agent_configuration .private_key_paths .read_all ():
14541425 if identifier not in crypto_registry .supported_ids :
1455- ValueError ("Unsupported identifier in private key paths ." )
1426+ raise ValueError (f"Item not registered with id ' { identifier } ' ." )
14561427
14571428 for identifier , private_key_path in IDENTIFIER_TO_KEY_FILES .items ():
14581429 config_private_key_path = agent_configuration .private_key_paths .read (identifier )
0 commit comments