refactor: fix some formatting issues and bugs.
This commit is contained in:
@@ -20,7 +20,6 @@ from pyasic.config.base import MinerConfigOption, MinerConfigValue
|
||||
from pyasic.web.braiins_os.proto.braiins.bos.v1 import (
|
||||
DpsPowerTarget,
|
||||
DpsTarget,
|
||||
Hours,
|
||||
Power,
|
||||
SetDpsRequest,
|
||||
)
|
||||
@@ -210,9 +209,8 @@ class PowerScalingConfig(MinerConfigOption):
|
||||
except LookupError:
|
||||
return cls.default()
|
||||
|
||||
conf = {}
|
||||
conf = {"shutdown_enabled": PowerScalingShutdown.from_boser(dps_conf)}
|
||||
|
||||
conf["shutdown_enabled"] = PowerScalingShutdown.from_boser(dps_conf)
|
||||
if dps_conf.get("minPowerTarget") is not None:
|
||||
conf["minimum_power"] = dps_conf["minPowerTarget"]["watt"]
|
||||
if dps_conf.get("powerStep") is not None:
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import time
|
||||
from collections import namedtuple
|
||||
from typing import List, Optional, Tuple, Union
|
||||
from typing import List, Optional, Union
|
||||
|
||||
import toml
|
||||
|
||||
@@ -32,7 +31,6 @@ from pyasic.miners.base import (
|
||||
DataFunction,
|
||||
DataLocations,
|
||||
DataOptions,
|
||||
GraphQLCommand,
|
||||
GRPCCommand,
|
||||
RPCAPICommand,
|
||||
WebAPICommand,
|
||||
@@ -537,13 +535,13 @@ class BOSMiner(BaseMiner):
|
||||
|
||||
if api_fans:
|
||||
fans = []
|
||||
for n in range(self.fan_count):
|
||||
for n in range(self.expected_fans):
|
||||
try:
|
||||
fans.append(Fan(api_fans["FANS"][n]["RPM"]))
|
||||
except (IndexError, KeyError):
|
||||
pass
|
||||
return fans
|
||||
return [Fan() for _ in range(self.fan_count)]
|
||||
return [Fan() for _ in range(self.expected_fans)]
|
||||
|
||||
async def _get_fan_psu(self) -> Optional[int]:
|
||||
return None
|
||||
@@ -978,13 +976,13 @@ class BOSer(BaseMiner):
|
||||
|
||||
if grpc_cooling_state:
|
||||
fans = []
|
||||
for n in range(self.fan_count):
|
||||
for n in range(self.expected_fans):
|
||||
try:
|
||||
fans.append(Fan(grpc_cooling_state["fans"][n]["rpm"]))
|
||||
except (IndexError, KeyError):
|
||||
pass
|
||||
return fans
|
||||
return [Fan() for _ in range(self.fan_count)]
|
||||
return [Fan() for _ in range(self.expected_fans)]
|
||||
|
||||
async def _get_fan_psu(self) -> Optional[int]:
|
||||
return None
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
import logging
|
||||
import re
|
||||
from typing import List, Optional
|
||||
|
||||
@@ -315,7 +314,7 @@ class CGMinerAvalon(CGMiner):
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
fans_data = [Fan() for _ in range(self.fan_count)]
|
||||
fans_data = [Fan() for _ in range(self.expected_fans)]
|
||||
if api_stats:
|
||||
try:
|
||||
unparsed_stats = api_stats["STATS"][0]["MM ID0"]
|
||||
@@ -323,7 +322,7 @@ class CGMinerAvalon(CGMiner):
|
||||
except LookupError:
|
||||
return fans_data
|
||||
|
||||
for fan in range(self.fan_count):
|
||||
for fan in range(self.expected_fans):
|
||||
try:
|
||||
fans_data[fan].speed = int(parsed_stats[f"Fan{fan + 1}"])
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
|
||||
@@ -188,7 +188,7 @@ class ePIC(BaseMiner):
|
||||
if web_summary:
|
||||
try:
|
||||
hashrate = 0
|
||||
if web_summary["HBs"] != None:
|
||||
if web_summary["HBs"] is not None:
|
||||
for hb in web_summary["HBs"]:
|
||||
hashrate += hb["Hashrate"][0]
|
||||
return round(float(float(hashrate / 1000000)), 2)
|
||||
@@ -207,7 +207,7 @@ class ePIC(BaseMiner):
|
||||
if web_summary:
|
||||
try:
|
||||
hashrate = 0
|
||||
if web_summary["HBs"] != None:
|
||||
if web_summary["HBs"] is not None:
|
||||
for hb in web_summary["HBs"]:
|
||||
if hb["Hashrate"][1] == 0:
|
||||
ideal = 1.0
|
||||
@@ -266,7 +266,7 @@ class ePIC(BaseMiner):
|
||||
HashBoard(slot=i, expected_chips=self.expected_chips)
|
||||
for i in range(self.expected_hashboards)
|
||||
]
|
||||
if web_summary["HBs"] != None:
|
||||
if web_summary["HBs"] is not None:
|
||||
for hb in web_summary["HBs"]:
|
||||
for hr in web_hashrate:
|
||||
if hr["Index"] == hb["Index"]:
|
||||
@@ -312,7 +312,7 @@ class ePIC(BaseMiner):
|
||||
if web_summary:
|
||||
try:
|
||||
error = web_summary["Status"]["Last Error"]
|
||||
if error != None:
|
||||
if error is not None:
|
||||
errors.append(X19Error(str(error)))
|
||||
return errors
|
||||
except KeyError:
|
||||
@@ -328,9 +328,6 @@ class ePIC(BaseMiner):
|
||||
def _get_api_ver(self, *args, **kwargs) -> Optional[str]:
|
||||
pass
|
||||
|
||||
def get_config(self) -> MinerConfig:
|
||||
return self.config
|
||||
|
||||
def _get_env_temp(self, *args, **kwargs) -> Optional[float]:
|
||||
pass
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ class Innosilicon(CGMiner):
|
||||
else:
|
||||
web_get_all = web_get_all["all"]
|
||||
|
||||
fans = [Fan() for _ in range(self.fan_count)]
|
||||
fans = [Fan() for _ in range(self.expected_fans)]
|
||||
if web_get_all:
|
||||
try:
|
||||
spd = web_get_all["fansSpeed"]
|
||||
@@ -348,7 +348,7 @@ class Innosilicon(CGMiner):
|
||||
pass
|
||||
else:
|
||||
round((int(spd) * 6000) / 100)
|
||||
for i in range(self.fan_count):
|
||||
for i in range(self.expected_fans):
|
||||
fans[i].speed = spd
|
||||
|
||||
return fans
|
||||
|
||||
@@ -476,6 +476,7 @@ class MinerFactory:
|
||||
fn = miner_model_fns.get(miner_type)
|
||||
|
||||
if fn is not None:
|
||||
# noinspection PyArgumentList
|
||||
task = asyncio.create_task(fn(ip))
|
||||
try:
|
||||
miner_model = await asyncio.wait_for(
|
||||
|
||||
@@ -33,7 +33,6 @@ class UnknownMiner(BaseMiner):
|
||||
super().__init__(ip)
|
||||
self.ip = ip
|
||||
self.api = UnknownAPI(ip)
|
||||
self.model = "Unknown"
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"Unknown: {str(self.ip)}"
|
||||
|
||||
@@ -89,10 +89,10 @@ class ePICWebAPI(BaseWebAPI):
|
||||
return data
|
||||
|
||||
async def restart_epic(self) -> dict:
|
||||
return await self.send_command("softreboot", post=True, parameters=None)
|
||||
return await self.send_command("softreboot", post=True)
|
||||
|
||||
async def reboot(self) -> dict:
|
||||
return await self.send_command("reboot", post=True, parameters=None)
|
||||
return await self.send_command("reboot", post=True)
|
||||
|
||||
async def pause_mining(self) -> dict:
|
||||
return await self.send_command("miner", post=True, parameters="Stop")
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
import unittest
|
||||
|
||||
from tests.api_tests import *
|
||||
from tests.config_tests import TestConfig
|
||||
from tests.miners_tests import MinersTest
|
||||
|
||||
Reference in New Issue
Block a user