From 6dc26d68c172c15ef5d682839eb7a8c7161f7503 Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Sat, 28 Sep 2024 16:47:09 +0300 Subject: [PATCH] fix: formatting typo, some mypy errors --- app.py | 9 ++++----- config_loader.py | 4 ++-- network_metrics.py | 6 ++---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app.py b/app.py index ccbaafc..cefcc13 100644 --- a/app.py +++ b/app.py @@ -1,8 +1,8 @@ import os import logging import sys -from prometheus_client import generate_latest, CollectorRegistry -from flask import Flask, Response +from prometheus_client import generate_latest +from flask import Flask, Response, cli import config_loader import metrics @@ -16,7 +16,6 @@ # Disable Flask's default logging logging.getLogger("werkzeug").disabled = True -cli = sys.modules['flask.cli'] cli.show_server_banner = lambda *x: None app = Flask(__name__) @@ -30,7 +29,7 @@ def root(): @app.route('/metrics') -def metrics(): +def metrics_endpoint(): try: nm.collect_metrics(rpc, addresses_to_monitor, diamond_address) gm.collect_metrics(graph_node, providers_to_monitor) @@ -50,7 +49,7 @@ def metrics(): rpc_url = config.rpc_url graph_node_url = config.graph_node_url - port = int(os.getenv("PORT", config.port)) + port = int(os.getenv("PORT", str(config.port))) addresses_to_monitor = config.addresses providers_to_monitor = config.providers diff --git a/config_loader.py b/config_loader.py index 43e5ab2..0cff5c6 100644 --- a/config_loader.py +++ b/config_loader.py @@ -1,6 +1,6 @@ import yaml from pydantic import BaseModel, ValidationError, constr, conlist, condecimal -from typing import List, Optional +from typing import Optional import pathlib import logging @@ -16,7 +16,7 @@ class AddressEntry(BaseModel): class TransactionConfig(BaseModel): enabled: bool private_key_path: Optional[str] = None - interval: Optional[str] = "60s" + interval: str = "60s" class ConfigSchema(BaseModel): diff --git a/network_metrics.py b/network_metrics.py index 0073ca1..5df3f50 100644 --- a/network_metrics.py +++ b/network_metrics.py @@ -110,8 +110,7 @@ def collect_balances(rpc: Web3, addresses_to_monitor: list[AddressEntry]): FLUENCE_BALANCE.labels( address=address, name=name).set(balance_eth) - logger.debug(f"Address {address} ({name}) balance is: { - balance_eth} FLT") + logger.debug(f"Address {address} ({name}) balance is: {balance_eth} FLT") FLUENCE_BALANCE_MINIMUM.labels( address=address, name=name).set(minimum_balance) @@ -129,8 +128,7 @@ def collect_reward_balance(rpc: Web3, diamond_address: str): reward_balance = diamond.functions.getRewardBalance().call() reward_balance_eth = rpc.from_wei(reward_balance, 'ether') REWARD_BALANCE_FLT.set(reward_balance_eth) - logger.debug(f"Diamond {diamond_address} reward balance is { - reward_balance_eth} FLT") + logger.debug(f"Diamond {diamond_address} reward balance is {reward_balance_eth} FLT") def collect_metrics(