From b69dd8689c6bb0b853d1f1f3b231e633ff61c8dc Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Fri, 30 Aug 2024 14:08:48 +0300 Subject: [PATCH] lint fixes --- operate/cli.py | 7 ++++--- operate/services/deployment_runner.py | 8 +++++--- operate/services/health_checker.py | 4 +++- operate/services/service.py | 12 +++++++----- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/operate/cli.py b/operate/cli.py index 7405505e0..2c491ad3b 100644 --- a/operate/cli.py +++ b/operate/cli.py @@ -138,7 +138,7 @@ def json(self) -> dict: "home": str(self._path), } - + def create_app( # pylint: disable=too-many-locals, unused-argument, too-many-statements home: t.Optional[Path] = None, ) -> FastAPI: @@ -146,13 +146,14 @@ def create_app( # pylint: disable=too-many-locals, unused-argument, too-many-st HEALTH_CHECKER_OFF = os.environ.get("HEALTH_CHECKER_OFF", "0") == "1" number_of_fails = int(os.environ.get("HEALTH_CHECKER_TRIES", "5")) - logger = setup_logger(name="operate") if HEALTH_CHECKER_OFF: logger.warning("healthchecker is off!!!") operate = OperateApp(home=home, logger=logger) funding_jobs: t.Dict[str, asyncio.Task] = {} - health_checker = HealthChecker(operate.service_manager(), number_of_fails=number_of_fails) + health_checker = HealthChecker( + operate.service_manager(), number_of_fails=number_of_fails + ) # Create shutdown endpoint shutdown_endpoint = uuid.uuid4().hex (operate._path / "operate.kill").write_text( # pylint: disable=protected-access diff --git a/operate/services/deployment_runner.py b/operate/services/deployment_runner.py index 557e93a6c..79c8940dc 100644 --- a/operate/services/deployment_runner.py +++ b/operate/services/deployment_runner.py @@ -22,7 +22,6 @@ import os import platform import shutil # nosec -import signal # nosec import subprocess # nosec import sys # nosec import time @@ -31,6 +30,7 @@ from pathlib import Path from typing import Any from venv import main as venv_cli + import psutil from aea.__version__ import __version__ as aea_version from autonomy.__version__ import __version__ as autonomy_version @@ -65,7 +65,7 @@ def _kill_process(pid: int) -> None: return try: process.kill() - except OSError as e: + except OSError: return time.sleep(1) @@ -268,10 +268,12 @@ def _start_tendermint(self) -> None: class PyInstallerHostDeploymentRunnerMac(PyInstallerHostDeploymentRunner): - pass + """Mac deployment runner.""" class PyInstallerHostDeploymentRunnerWindows(PyInstallerHostDeploymentRunner): + """Windows deployment runner.""" + @property def _aea_bin(self) -> str: """Return aea_bin path.""" diff --git a/operate/services/health_checker.py b/operate/services/health_checker.py index ba1c5d57c..7a9c27373 100644 --- a/operate/services/health_checker.py +++ b/operate/services/health_checker.py @@ -110,7 +110,9 @@ async def _wait_for_port(sleep_period: int = 15) -> None: self.logger.info("[HEALTH_CHECKER]: port is UP") return except aiohttp.ClientConnectionError: - self.logger.error("[HEALTH_CHECKER]: error connecting http port") + self.logger.error( + "[HEALTH_CHECKER]: error connecting http port" + ) await asyncio.sleep(sleep_period) async def _check_port_ready( diff --git a/operate/services/service.py b/operate/services/service.py index 4d7fc8787..362fb95e0 100644 --- a/operate/services/service.py +++ b/operate/services/service.py @@ -22,9 +22,9 @@ import json import os import platform -import sys import shutil import subprocess # nosec +import sys import typing as t from copy import copy, deepcopy from dataclasses import dataclass @@ -279,7 +279,9 @@ def generate_config_tendermint(self) -> "HostDeploymentGenerator": ) # TODO: move all platform related things to a dedicated file if platform.system() == "Windows": - tendermint_executable = Path(os.path.dirname(sys.executable)) / "tendermint.exe" + tendermint_executable = ( + Path(os.path.dirname(sys.executable)) / "tendermint.exe" + ) print(11111111111111111, tendermint_executable) subprocess.run( # pylint: disable=subprocess-run-check # nosec args=[ @@ -569,9 +571,9 @@ def _build_host(self, force: bool = True, chain_id: str = "100") -> None: # Mech price patch. agent_vars = json.loads(Path(build, "agent.json").read_text(encoding="utf-8")) if "SKILL_TRADER_ABCI_MODELS_PARAMS_ARGS_MECH_REQUEST_PRICE" in agent_vars: - agent_vars["SKILL_TRADER_ABCI_MODELS_PARAMS_ARGS_MECH_REQUEST_PRICE"] = ( - "10000000000000000" - ) + agent_vars[ + "SKILL_TRADER_ABCI_MODELS_PARAMS_ARGS_MECH_REQUEST_PRICE" + ] = "10000000000000000" Path(build, "agent.json").write_text( json.dumps(agent_vars, indent=4), encoding="utf-8",