Skip to content

Commit

Permalink
Merge pull request #2079 from valory-xyz/feat/slashing-abci-warning
Browse files Browse the repository at this point in the history
Raise warning if slashing abci is missing as a dependency
  • Loading branch information
angrybayblade authored Oct 6, 2023
2 parents bba96bd + 8af2e30 commit aec2f4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
18 changes: 12 additions & 6 deletions autonomy/analyse/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
ABCI = "abci"
LEDGER = "ledger"
TERMINATION_ABCI = PublicId(author="valory", name="termination_abci", version="any")
SLASHING_ABCI = PublicId(author="valory", name="slashing_abci", version="any")
ENV_VAR_RE = re.compile(
r"^\$\{(?P<name>[A-Z_0-9]+)?:?(?P<type>bool|int|float|str|list|dict)?:?(?P<value>.+)?\}$"
)
Expand Down Expand Up @@ -728,12 +729,14 @@ def validate_override(
)
)

def _check_for_termination_abci_skill(self, dependencies: Set[PublicId]) -> None:
def _check_for_dependency(
self, dependencies: Set[PublicId], dependency: PublicId
) -> None:
"""Check termination ABCI skill is an dependency for the agent"""
for dependency in dependencies:
if dependency.to_any() == TERMINATION_ABCI:
for _dependency in dependencies:
if _dependency.to_any() == dependency:
return
self.logger.warning("Termination skill is not defined as a dependency")
self.logger.warning(f"{dependency} is not defined as a dependency")

def validate_skill_config(self, skill_config: SkillConfig) -> None:
"""Check required overrides."""
Expand All @@ -751,7 +754,8 @@ 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._check_for_dependency(skill_config.skills, TERMINATION_ABCI)
self._check_for_dependency(skill_config.skills, SLASHING_ABCI)
self.logger.info("No issues found in the ABCI skill configuration")

def validate_agent_overrides(self, agent_config: AgentConfig) -> None:
Expand All @@ -778,7 +782,9 @@ 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._check_for_dependency(agent_config.skills, TERMINATION_ABCI)
self._check_for_dependency(agent_config.skills, SLASHING_ABCI)
self.logger.info("No issues found in the agent overrides")

def validate_service_overrides(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,4 +907,7 @@ def test_run(self, caplog: Any) -> None:

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
assert (
"valory/termination_abci:any is not defined as a dependency" in caplog.text
)
assert "valory/slashing_abci:any is not defined as a dependency" in caplog.text

0 comments on commit aec2f4a

Please sign in to comment.