Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning if the termination skill is missing as a dependency #2076

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions autonomy/analyse/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<name>[A-Z_0-9]+)?:?(?P<type>bool|int|float|str|list|dict)?:?(?P<value>.+)?\}$"
)
Expand Down Expand Up @@ -728,6 +728,13 @@
)
)

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

Check warning on line 735 in autonomy/analyse/service.py

View check run for this annotation

Codecov / codecov/patch

autonomy/analyse/service.py#L735

Added line #L735 was not covered by tests
self.logger.warning("Termination skill is not defined as a dependency")

def validate_skill_config(self, skill_config: SkillConfig) -> None:
"""Check required overrides."""

Expand All @@ -744,6 +751,7 @@
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:
Expand All @@ -770,7 +778,7 @@
"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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/test_autonomy/test_cli/test_helpers/test_fsm_spec.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Loading