bug: fix MinerConfig default values for 3.11+. Add MinerConfig.as_epic default implementation.
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
# limitations under the License. -
|
# limitations under the License. -
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from dataclasses import asdict, dataclass
|
from dataclasses import asdict, dataclass, field
|
||||||
|
|
||||||
from pyasic.config.fans import FanModeConfig
|
from pyasic.config.fans import FanModeConfig
|
||||||
from pyasic.config.mining import MiningModeConfig
|
from pyasic.config.mining import MiningModeConfig
|
||||||
@@ -25,11 +25,13 @@ from pyasic.config.temperature import TemperatureConfig
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class MinerConfig:
|
class MinerConfig:
|
||||||
pools: PoolConfig = PoolConfig.default()
|
pools: PoolConfig = field(default_factory=PoolConfig.default)
|
||||||
fan_mode: FanModeConfig = FanModeConfig.default()
|
fan_mode: FanModeConfig = field(default_factory=FanModeConfig.default)
|
||||||
temperature: TemperatureConfig = TemperatureConfig.default()
|
temperature: TemperatureConfig = field(default_factory=TemperatureConfig.default)
|
||||||
mining_mode: MiningModeConfig = MiningModeConfig.default()
|
mining_mode: MiningModeConfig = field(default_factory=MiningModeConfig.default)
|
||||||
power_scaling: PowerScalingConfig = PowerScalingConfig.default()
|
power_scaling: PowerScalingConfig = field(
|
||||||
|
default_factory=PowerScalingConfig.default
|
||||||
|
)
|
||||||
|
|
||||||
def as_dict(self) -> dict:
|
def as_dict(self) -> dict:
|
||||||
return asdict(self)
|
return asdict(self)
|
||||||
@@ -106,6 +108,15 @@ class MinerConfig:
|
|||||||
**self.power_scaling.as_bos_grpc(),
|
**self.power_scaling.as_bos_grpc(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def as_epic(self, user_suffix: str = None) -> dict:
|
||||||
|
return {
|
||||||
|
**self.fan_mode.as_epic(),
|
||||||
|
**self.temperature.as_epic(),
|
||||||
|
**self.mining_mode.as_epic(),
|
||||||
|
**self.pools.as_epic(user_suffix=user_suffix),
|
||||||
|
**self.power_scaling.as_epic(),
|
||||||
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, dict_conf: dict) -> "MinerConfig":
|
def from_dict(cls, dict_conf: dict) -> "MinerConfig":
|
||||||
return cls(
|
return cls(
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ class MinerConfigOption(Enum):
|
|||||||
def as_bos_grpc(self) -> dict:
|
def as_bos_grpc(self) -> dict:
|
||||||
return self.value.as_bos_grpc()
|
return self.value.as_bos_grpc()
|
||||||
|
|
||||||
|
def as_epic(self) -> dict:
|
||||||
|
return self.value.as_epic()
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
return self.value(*args, **kwargs)
|
return self.value(*args, **kwargs)
|
||||||
|
|
||||||
@@ -87,3 +90,6 @@ class MinerConfigValue:
|
|||||||
|
|
||||||
def as_bos_grpc(self) -> dict:
|
def as_bos_grpc(self) -> dict:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def as_epic(self) -> dict:
|
||||||
|
return {}
|
||||||
|
|||||||
Reference in New Issue
Block a user