* Fix incorrect computation of active_preset for Antminer VNish. See #338. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * #338 renamed perf_summary to web_perf_summary for clarity and consistency. New API call is done in backward compatibility manner. Data is also retrieved safely * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -23,7 +23,7 @@ Welcome to `pyasic`! `pyasic` uses an asynchronous method of communicating with
|
||||
## Installation
|
||||
|
||||
It is recommended to install `pyasic` in a [virtual environment](https://realpython.com/python-virtual-environments-a-primer/#what-other-popular-options-exist-aside-from-venv) to isolate it from the rest of your system. Options include:
|
||||
- [pypoetry](https://python-poetry.org/): the reccommended way, since pyasic already uses it by default
|
||||
- [pypoetry](https://python-poetry.org/): the reccommended way, since pyasic already uses it by default. Use version 2.0+
|
||||
|
||||
```
|
||||
poetry install
|
||||
|
||||
@@ -283,13 +283,17 @@ class MinerConfig(BaseModel):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_vnish(cls, web_settings: dict, web_presets: list[dict]) -> "MinerConfig":
|
||||
def from_vnish(
|
||||
cls, web_settings: dict, web_presets: list[dict], web_perf_summary: dict
|
||||
) -> "MinerConfig":
|
||||
"""Constructs a MinerConfig object from web settings for VNish miners."""
|
||||
return cls(
|
||||
pools=PoolConfig.from_vnish(web_settings),
|
||||
fan_mode=FanModeConfig.from_vnish(web_settings),
|
||||
temperature=TemperatureConfig.from_vnish(web_settings),
|
||||
mining_mode=MiningModeConfig.from_vnish(web_settings, web_presets),
|
||||
mining_mode=MiningModeConfig.from_vnish(
|
||||
web_settings, web_presets, web_perf_summary
|
||||
),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -412,12 +412,18 @@ class MiningModePreset(MinerConfigValue):
|
||||
|
||||
@classmethod
|
||||
def from_vnish(
|
||||
cls, web_overclock_settings: dict, web_presets: list[dict]
|
||||
cls,
|
||||
web_overclock_settings: dict,
|
||||
web_presets: list[dict],
|
||||
web_perf_summary: dict,
|
||||
) -> "MiningModePreset":
|
||||
active_preset = None
|
||||
for preset in web_presets:
|
||||
if preset["name"] == web_overclock_settings["preset"]:
|
||||
active_preset = preset
|
||||
active_preset = web_perf_summary.get("current_preset")
|
||||
|
||||
if active_preset is None:
|
||||
for preset in web_presets:
|
||||
if preset["name"] == web_overclock_settings["preset"]:
|
||||
active_preset = preset
|
||||
|
||||
return cls(
|
||||
active_preset=MiningPreset.from_vnish(active_preset),
|
||||
available_presets=[MiningPreset.from_vnish(p) for p in web_presets],
|
||||
@@ -703,7 +709,9 @@ class MiningModeConfig(MinerConfigOption):
|
||||
return cls.default()
|
||||
|
||||
@classmethod
|
||||
def from_vnish(cls, web_settings: dict, web_presets: list[dict]):
|
||||
def from_vnish(
|
||||
cls, web_settings: dict, web_presets: list[dict], web_perf_summary: dict
|
||||
):
|
||||
try:
|
||||
mode_settings = web_settings["miner"]["overclock"]
|
||||
except KeyError:
|
||||
@@ -712,7 +720,9 @@ class MiningModeConfig(MinerConfigOption):
|
||||
if mode_settings["preset"] == "disabled":
|
||||
return MiningModeManual.from_vnish(mode_settings)
|
||||
else:
|
||||
return MiningModePreset.from_vnish(mode_settings, web_presets)
|
||||
return MiningModePreset.from_vnish(
|
||||
mode_settings, web_presets, web_perf_summary
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_boser(cls, grpc_miner_conf: dict):
|
||||
|
||||
@@ -293,9 +293,12 @@ class VNish(VNishFirmware, BMMiner):
|
||||
try:
|
||||
web_settings = await self.web.settings()
|
||||
web_presets = await self.web.autotune_presets()
|
||||
web_perf_summary = (await self.web.perf_summary()) or {}
|
||||
except APIError:
|
||||
return self.config
|
||||
self.config = MinerConfig.from_vnish(web_settings, web_presets)
|
||||
self.config = MinerConfig.from_vnish(
|
||||
web_settings, web_presets, web_perf_summary
|
||||
)
|
||||
return self.config
|
||||
|
||||
async def set_power_limit(self, wattage: int) -> bool:
|
||||
|
||||
@@ -58,7 +58,7 @@ class VNishWebAPI(BaseWebAPI):
|
||||
allow_warning: bool = True,
|
||||
privileged: bool = False,
|
||||
**parameters: Any,
|
||||
) -> dict:
|
||||
) -> dict | None:
|
||||
post = privileged or not parameters == {}
|
||||
if self.token is None:
|
||||
await self.auth()
|
||||
@@ -126,6 +126,9 @@ class VNishWebAPI(BaseWebAPI):
|
||||
async def summary(self) -> dict:
|
||||
return await self.send_command("summary")
|
||||
|
||||
async def perf_summary(self) -> dict:
|
||||
return await self.send_command("perf-summary")
|
||||
|
||||
async def chips(self) -> dict:
|
||||
return await self.send_command("chips")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user