diff --git a/autonomy/analyse/service.py b/autonomy/analyse/service.py index a7e040e487..09574029cf 100644 --- a/autonomy/analyse/service.py +++ b/autonomy/analyse/service.py @@ -183,7 +183,7 @@ ABCI = "abci" LEDGER = "ledger" - +TERMINATION_ABCI = PublicId(author="valory", name="termination_abci", version="any") ENV_VAR_RE = re.compile( r"^\$\{(?P[A-Z_0-9]+)?:?(?Pbool|int|float|str|list|dict)?:?(?P.+)?\}$" ) @@ -728,6 +728,13 @@ def validate_override( ) ) + def _check_for_termination_abci_skill(self, dependencies: Set[PublicId]) -> None: + """Check termination ABCI skill is an dependency for the agent""" + for dependency in dependencies: + if dependency.to_any() == TERMINATION_ABCI: + return + self.logger.warning("Termination skill is not defined as a dependency") + def validate_skill_config(self, skill_config: SkillConfig) -> None: """Check required overrides.""" @@ -744,6 +751,7 @@ def validate_skill_config(self, skill_config: SkillConfig) -> None: has_multiple_overrides=False, error_message="ABCI skill validation failed; {error}", ) + self._check_for_termination_abci_skill(skill_config.skills) self.logger.info("No issues found in the ABCI skill configuration") def validate_agent_overrides(self, agent_config: AgentConfig) -> None: @@ -770,7 +778,7 @@ def validate_agent_overrides(self, agent_config: AgentConfig) -> None: "Agent overrides validation failed with following errors" f"\n\t- {error_string}" ) - + self._check_for_termination_abci_skill(agent_config.skills) self.logger.info("No issues found in the agent overrides") def validate_service_overrides(self) -> None: diff --git a/tests/test_autonomy/test_cli/test_analyse/test_verify_service.py b/tests/test_autonomy/test_cli/test_analyse/test_verify_service.py index 82c127670c..156f007c55 100644 --- a/tests/test_autonomy/test_cli/test_analyse/test_verify_service.py +++ b/tests/test_autonomy/test_cli/test_analyse/test_verify_service.py @@ -855,7 +855,7 @@ def test_on_chain_status_check_rpc_failure(self) -> None: class TestCheckSuccessful(BaseAnalyseServiceTest): """Test a successful check""" - def test_run(self) -> None: + def test_run(self, caplog: Any) -> None: """Test run.""" skill_config = get_dummy_overrides_skill(env_vars_with_name=True) @@ -900,8 +900,11 @@ def test_run(self) -> None: ), self.patch_get_on_chain_service_id(), mock.patch( "autonomy.analyse.service.get_service_info", return_value=(None, 4, None), + ), caplog.at_level( + logging.WARNING ): result = self.run_cli(commands=self.token_id_option) assert result.exit_code == 0, result.stderr assert "Service is ready to be deployed" in result.output + assert "Termination skill is not defined as a dependency" in caplog.text diff --git a/tests/test_autonomy/test_cli/test_helpers/test_fsm_spec.py b/tests/test_autonomy/test_cli/test_helpers/test_fsm_spec.py index d90dec04f1..32e29eeba6 100644 --- a/tests/test_autonomy/test_cli/test_helpers/test_fsm_spec.py +++ b/tests/test_autonomy/test_cli/test_helpers/test_fsm_spec.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2022 Valory AG +# Copyright 2022-2023 Valory AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.