From 1f740e5984d8071522428985510ec8635b857b27 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Wed, 4 Oct 2023 15:49:39 +0530 Subject: [PATCH 1/3] feat: warn if the termination skill is not defined as a dependency --- autonomy/analyse/service.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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: From 0b6a43e5e9d540f4405e78a33c48d3e0f9843d68 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Wed, 4 Oct 2023 15:50:10 +0530 Subject: [PATCH 2/3] test: service analyser warsn if the termination skill is not defined as a dependency --- .../test_cli/test_analyse/test_verify_service.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 From e1d15468a98580c38ff7e9816f2bc463ed6c3749 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Wed, 4 Oct 2023 15:51:29 +0530 Subject: [PATCH 3/3] chore: copyright --- tests/test_autonomy/test_cli/test_helpers/test_fsm_spec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.