feature: add __getitem__ to config.
This commit is contained in:
@@ -36,6 +36,12 @@ class MinerConfig:
|
||||
default_factory=PowerScalingConfig.default
|
||||
)
|
||||
|
||||
def __getitem__(self, item):
|
||||
try:
|
||||
return getattr(self, item)
|
||||
except AttributeError:
|
||||
raise KeyError
|
||||
|
||||
def as_dict(self) -> dict:
|
||||
"""Converts the MinerConfig object to a dictionary."""
|
||||
return asdict(self)
|
||||
|
||||
@@ -67,6 +67,13 @@ class MinerConfigOption(Enum):
|
||||
def default(cls):
|
||||
pass
|
||||
|
||||
def __getitem__(self, item):
|
||||
try:
|
||||
return getattr(self, item)
|
||||
except AttributeError:
|
||||
raise KeyError
|
||||
|
||||
|
||||
|
||||
@dataclass
|
||||
class MinerConfigValue:
|
||||
@@ -112,3 +119,9 @@ class MinerConfigValue:
|
||||
|
||||
def as_mara(self) -> dict:
|
||||
return {}
|
||||
|
||||
def __getitem__(self, item):
|
||||
try:
|
||||
return getattr(self, item)
|
||||
except AttributeError:
|
||||
raise KeyError
|
||||
|
||||
Reference in New Issue
Block a user