fixes, changes, and formatting

This commit is contained in:
John-Paul Compagnone
2023-12-23 15:01:42 -05:00
parent 07f92557c6
commit 2e28060e05
10 changed files with 166 additions and 121 deletions

View File

@@ -160,13 +160,15 @@ class MinerConfig:
temperature=TemperatureConfig.from_bosminer(toml_conf),
power_scaling=PowerScalingConfig.from_bosminer(toml_conf),
)
@classmethod
def from_epic(cls, web_conf: dict) -> "MinerConfig":
return cls(pools=PoolConfig.from_epic(web_conf),
fan_mode=FanModeConfig.from_epic(web_conf),
temperature=TemperatureConfig.from_epic(web_conf),
mining_mode=MiningModeConfig.from_epic(web_conf))
return cls(
pools=PoolConfig.from_epic(web_conf),
fan_mode=FanModeConfig.from_epic(web_conf),
temperature=TemperatureConfig.from_epic(web_conf),
mining_mode=MiningModeConfig.from_epic(web_conf),
)
def merge(a: dict, b: dict) -> dict:

View File

@@ -115,16 +115,16 @@ class FanModeConfig(MinerConfigOption):
return cls.normal()
else:
return cls.default()
@classmethod
def from_epic(cls, web_conf: dict):
if web_conf.get("Fans") is not None:
try:
fan_mode = web_conf["Fans"]["Fan Mode"]
if fan_mode.get("Manual") is not None:
return cls.manual(speed=fan_mode.get("Manual"))
else:
return cls.normal()
else:
except KeyError:
return cls.default()
@classmethod

View File

@@ -185,19 +185,29 @@ class MiningModeConfig(MinerConfigOption):
elif int(work_mode) == 3:
return cls.low()
return cls.default()
@classmethod
def from_epic(cls, web_conf: dict):
if web_conf.get("PerpetualTune") is not None:
work_mode = web_conf["PerpetualTune"]
if work_mode["Running"] == True:
if web_conf["PerpetualTune"]["Algorithm"].get("VoltageOptimizer") is not None:
return cls.hashrate_tuning(web_conf["PerpetualTune"]["Algorithm"]["VoltageOptimizer"].get("Target"))
try:
work_mode = web_conf["PerpetualTune"]["Running"]
if work_mode:
if (
web_conf["PerpetualTune"]["Algorithm"].get("VoltageOptimizer")
is not None
):
return cls.hashrate_tuning(
web_conf["PerpetualTune"]["Algorithm"]["VoltageOptimizer"][
"Target"
]
)
else:
return cls.hashrate_tuning(web_conf["PerpetualTune"]["Algorithm"]["ChipTune"].get("Target"))
return cls.hashrate_tuning(
web_conf["PerpetualTune"]["Algorithm"]["ChipTune"]["Target"]
)
else:
return cls.normal()
return cls.default()
except KeyError:
return cls.default()
@classmethod
def from_bosminer(cls, toml_conf: dict):

View File

@@ -107,10 +107,12 @@ class Pool(MinerConfigValue):
@classmethod
def from_api(cls, api_pool: dict) -> "Pool":
return cls(url=api_pool["URL"], user=api_pool["User"], password="x")
@classmethod
def from_epic(cls, api_pool: dict) -> "Pool":
return cls(url=api_pool["pool"].replace("stratum+tcp://", ""), user=api_pool["login"], password=api_pool["password"])
return cls(
url=api_pool["pool"], user=api_pool["login"], password=api_pool["password"]
)
@classmethod
def from_am_modern(cls, web_pool: dict) -> "Pool":
@@ -240,7 +242,7 @@ class PoolGroup(MinerConfigValue):
for pool in api_pool_list:
pools.append(Pool.from_api(pool))
return cls(pools=pools)
@classmethod
def from_epic(cls, api_pool_list: list) -> "PoolGroup":
pools = []
@@ -344,7 +346,7 @@ class PoolConfig(MinerConfigValue):
pool_data = sorted(pool_data, key=lambda x: int(x["POOL"]))
return cls([PoolGroup.from_api(pool_data)])
@classmethod
def from_epic(cls, web_conf: dict) -> "PoolConfig":
pool_data = web_conf["StratumConfigs"]

View File

@@ -56,21 +56,18 @@ class TemperatureConfig(MinerConfigValue):
hot=temp_control.get("hot_temp"),
danger=temp_control.get("dangerous_temp"),
)
@classmethod
def from_epic(cls, web_conf: dict) -> "TemperatureConfig":
## we only have a target temp if we are in auto-fan mode, so
## we need to check for that
if web_conf.get("Misc") is not None:
target_temp = web_conf["Misc"]["Shutdown Temp"]
dangerous_temp = None
try:
hot_temp = web_conf["Misc"]["Shutdown Temp"]
dangerous_temp = web_conf["Misc"]["Shutdown Temp"]
if web_conf["Fans"]["Fan Mode"].get("Auto") is not None:
except KeyError:
hot_temp = None
# Need to do this in two blocks to avoid KeyError if one is missing
try:
target_temp = web_conf["Fans"]["Fan Mode"]["Auto"]["Target Temperature"]
except KeyError:
target_temp = None
if web_conf.get("Misc") is not None:
return cls(
target=target_temp,
hot=hot_temp,
danger=dangerous_temp
)
return cls(target=target_temp, hot=hot_temp, danger=dangerous_temp)