Skip to content

Commit

Permalink
bug: fix MinerConfig default values for 3.11+. Add MinerConfig.as_epi…
Browse files Browse the repository at this point in the history
…c default implementation.
  • Loading branch information
UpstreamData committed Dec 17, 2023
1 parent c5c4bb1 commit d2be68d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 17 additions & 6 deletions pyasic/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License. -
# ------------------------------------------------------------------------------
from copy import deepcopy
from dataclasses import asdict, dataclass
from dataclasses import asdict, dataclass, field

from pyasic.config.fans import FanModeConfig
from pyasic.config.mining import MiningModeConfig
Expand All @@ -25,11 +25,13 @@

@dataclass
class MinerConfig:
pools: PoolConfig = PoolConfig.default()
fan_mode: FanModeConfig = FanModeConfig.default()
temperature: TemperatureConfig = TemperatureConfig.default()
mining_mode: MiningModeConfig = MiningModeConfig.default()
power_scaling: PowerScalingConfig = PowerScalingConfig.default()
pools: PoolConfig = field(default_factory=PoolConfig.default)
fan_mode: FanModeConfig = field(default_factory=FanModeConfig.default)
temperature: TemperatureConfig = field(default_factory=TemperatureConfig.default)
mining_mode: MiningModeConfig = field(default_factory=MiningModeConfig.default)
power_scaling: PowerScalingConfig = field(
default_factory=PowerScalingConfig.default
)

def as_dict(self) -> dict:
return asdict(self)
Expand Down Expand Up @@ -106,6 +108,15 @@ def as_bos_grpc(self, user_suffix: str = None) -> dict:
**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
def from_dict(cls, dict_conf: dict) -> "MinerConfig":
return cls(
Expand Down
6 changes: 6 additions & 0 deletions pyasic/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def as_bosminer(self) -> dict:
def as_bos_grpc(self) -> dict:
return self.value.as_bos_grpc()

def as_epic(self) -> dict:
return self.value.as_epic()

def __call__(self, *args, **kwargs):
return self.value(*args, **kwargs)

Expand Down Expand Up @@ -87,3 +90,6 @@ def as_bosminer(self) -> dict:

def as_bos_grpc(self) -> dict:
return {}

def as_epic(self) -> dict:
return {}

0 comments on commit d2be68d

Please sign in to comment.