refactor: move base classes to base.py in their directories, move data locations to miners.data, and rename types to models.

This commit is contained in:
UpstreamData
2024-01-25 14:26:53 -07:00
parent aa1d7c1b6f
commit dd4c087749
261 changed files with 779 additions and 741 deletions

View File

@@ -3,7 +3,7 @@ import importlib
import os import os
import warnings import warnings
from pyasic.miners.miner_factory import MINER_CLASSES, MinerTypes from pyasic.miners.factory import MINER_CLASSES, MinerTypes
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")

View File

@@ -23,10 +23,9 @@ from pyasic.data import (
X19Error, X19Error,
) )
from pyasic.errors import APIError, APIWarning from pyasic.errors import APIError, APIWarning
from pyasic.miners import get_miner from pyasic.miners import AnyMiner, DataOptions, get_miner
from pyasic.miners.base import AnyMiner, DataOptions from pyasic.miners.factory import MinerFactory, miner_factory
from pyasic.miners.miner_factory import MinerFactory, miner_factory from pyasic.miners.listener import MinerListener
from pyasic.miners.miner_listener import MinerListener
from pyasic.network import MinerNetwork from pyasic.network import MinerNetwork
from pyasic.rpc.bmminer import BMMinerRPCAPI from pyasic.rpc.bmminer import BMMinerRPCAPI
from pyasic.rpc.bosminer import BOSMinerRPCAPI from pyasic.rpc.bosminer import BOSMinerRPCAPI

View File

@@ -20,7 +20,7 @@ from typing import List, Union
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners import AnyMiner from pyasic.miners import AnyMiner
from pyasic.miners.backends import AntminerModern, BOSMiner, BTMiner from pyasic.miners.backends import AntminerModern, BOSMiner, BTMiner
from pyasic.miners.types import S9, S17, T17, S17e, S17Plus, S17Pro, T17e, T17Plus from pyasic.miners.models import S9, S17, T17, S17e, S17Plus, S17Pro, T17e, T17Plus
FAN_USAGE = 50 # 50 W per fan FAN_USAGE = 50 # 50 W per fan

View File

@@ -18,7 +18,8 @@ import ipaddress
from typing import Union from typing import Union
from pyasic.miners.base import AnyMiner, BaseMiner from pyasic.miners.base import AnyMiner, BaseMiner
from pyasic.miners.miner_factory import miner_factory from pyasic.miners.data import DataOptions
from pyasic.miners.factory import miner_factory
# abstracted version of get miner that is easier to access # abstracted version of get miner that is easier to access

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerOld from pyasic.miners.backends import AntminerOld
from pyasic.miners.types import S17, S17e, S17Plus, S17Pro from pyasic.miners.models import S17, S17e, S17Plus, S17Pro
class BMMinerS17(AntminerOld, S17): class BMMinerS17(AntminerOld, S17):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerOld from pyasic.miners.backends import AntminerOld
from pyasic.miners.types import T17, T17e, T17Plus from pyasic.miners.models import T17, T17e, T17Plus
class BMMinerT17(AntminerOld, T17): class BMMinerT17(AntminerOld, T17):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerModern from pyasic.miners.backends import AntminerModern
from pyasic.miners.types import ( from pyasic.miners.models import (
S19, S19,
S19L, S19L,
S19XP, S19XP,

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerModern from pyasic.miners.backends import AntminerModern
from pyasic.miners.types import T19 from pyasic.miners.models import T19
class BMMinerT19(AntminerModern, T19): class BMMinerT19(AntminerModern, T19):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerModern from pyasic.miners.backends import AntminerModern
from pyasic.miners.types import HS3 from pyasic.miners.models import HS3
class BMMinerHS3(AntminerModern, HS3): class BMMinerHS3(AntminerModern, HS3):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerOld from pyasic.miners.backends import AntminerOld
from pyasic.miners.types import L3Plus from pyasic.miners.models import L3Plus
class BMMinerL3Plus(AntminerOld, L3Plus): class BMMinerL3Plus(AntminerOld, L3Plus):

View File

@@ -14,7 +14,7 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerModern from pyasic.miners.backends import AntminerModern
from pyasic.miners.types import L7 from pyasic.miners.models import L7
class BMMinerL7(AntminerModern, L7): class BMMinerL7(AntminerModern, L7):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerModern from pyasic.miners.backends import AntminerModern
from pyasic.miners.types import E9Pro from pyasic.miners.models import E9Pro
class BMMinerE9Pro(AntminerModern, E9Pro): class BMMinerE9Pro(AntminerModern, E9Pro):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import BMMiner from pyasic.miners.backends import BMMiner
from pyasic.miners.types import S9, S9i, S9j from pyasic.miners.models import S9, S9i, S9j
class BMMinerS9(BMMiner, S9): class BMMinerS9(BMMiner, S9):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import BMMiner from pyasic.miners.backends import BMMiner
from pyasic.miners.types import T9 from pyasic.miners.models import T9
class BMMinerT9(BMMiner, T9): class BMMinerT9(BMMiner, T9):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import BOSer from pyasic.miners.backends import BOSer
from pyasic.miners.types import S17, S17e, S17Plus, S17Pro from pyasic.miners.models import S17, S17e, S17Plus, S17Pro
class BOSMinerS17(BOSer, S17): class BOSMinerS17(BOSer, S17):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import BOSer from pyasic.miners.backends import BOSer
from pyasic.miners.types import T17, T17e, T17Plus from pyasic.miners.models import T17, T17e, T17Plus
class BOSMinerT17(BOSer, T17): class BOSMinerT17(BOSer, T17):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import BOSer from pyasic.miners.backends import BOSer
from pyasic.miners.types import ( from pyasic.miners.models import (
S19, S19,
S19XP, S19XP,
S19a, S19a,

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import BOSer from pyasic.miners.backends import BOSer
from pyasic.miners.types import T19 from pyasic.miners.models import T19
class BOSMinerT19(BOSer, T19): class BOSMinerT19(BOSer, T19):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import BOSMiner from pyasic.miners.backends import BOSMiner
from pyasic.miners.types import S9 from pyasic.miners.models import S9
class BOSMinerS9(BOSMiner, S9): class BOSMinerS9(BOSMiner, S9):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerOld from pyasic.miners.backends import AntminerOld
from pyasic.miners.types import Z15 from pyasic.miners.models import Z15
class CGMinerZ15(AntminerOld, Z15): class CGMinerZ15(AntminerOld, Z15):

View File

@@ -14,7 +14,7 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerOld from pyasic.miners.backends import AntminerOld
from pyasic.miners.types import D3 from pyasic.miners.models import D3
class CGMinerD3(AntminerOld, D3): class CGMinerD3(AntminerOld, D3):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AntminerOld from pyasic.miners.backends import AntminerOld
from pyasic.miners.types import DR5 from pyasic.miners.models import DR5
class CGMinerDR5(AntminerOld, DR5): class CGMinerDR5(AntminerOld, DR5):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import ePIC from pyasic.miners.backends import ePIC
from pyasic.miners.types import S19, S19XP, S19j, S19jPro, S19jProPlus, S19kPro, S19Pro from pyasic.miners.models import S19, S19XP, S19j, S19jPro, S19jProPlus, S19kPro, S19Pro
class ePICS19(ePIC, S19): class ePICS19(ePIC, S19):

View File

@@ -21,8 +21,8 @@ import asyncssh
from pyasic.data import HashBoard from pyasic.data import HashBoard
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.backends import Hiveon from pyasic.miners.backends import Hiveon
from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPICommand from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
from pyasic.miners.types import T9 from pyasic.miners.models import T9
HIVEON_T9_DATA_LOC = DataLocations( HIVEON_T9_DATA_LOC = DataLocations(
**{ **{

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import LUXMiner from pyasic.miners.backends import LUXMiner
from pyasic.miners.types import S9 from pyasic.miners.models import S9
class LUXMinerS9(LUXMiner, S9): class LUXMinerS9(LUXMiner, S9):

View File

@@ -14,7 +14,7 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import VNish from pyasic.miners.backends import VNish
from pyasic.miners.types import S17Plus, S17Pro from pyasic.miners.models import S17Plus, S17Pro
class VNishS17Plus(VNish, S17Plus): class VNishS17Plus(VNish, S17Plus):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import VNish from pyasic.miners.backends import VNish
from pyasic.miners.types import ( from pyasic.miners.models import (
S19, S19,
S19XP, S19XP,
S19a, S19a,

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import VNish from pyasic.miners.backends import VNish
from pyasic.miners.types import T19 from pyasic.miners.models import T19
class VNishT19(VNish, T19): class VNishT19(VNish, T19):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import VNish from pyasic.miners.backends import VNish
from pyasic.miners.types import L3Plus from pyasic.miners.models import L3Plus
class VnishL3Plus(VNish, L3Plus): class VnishL3Plus(VNish, L3Plus):

View File

@@ -1,5 +1,5 @@
from pyasic.miners.backends import Auradine from pyasic.miners.backends import Auradine
from pyasic.miners.types import AuradineAT1500 from pyasic.miners.models import AuradineAT1500
class AuradineFluxAT1500(AuradineAT1500, Auradine): class AuradineFluxAT1500(AuradineAT1500, Auradine):

View File

@@ -1,5 +1,5 @@
from pyasic.miners.backends import Auradine from pyasic.miners.backends import Auradine
from pyasic.miners.types import AuradineAT2860, AuradineAT2880 from pyasic.miners.models import AuradineAT2860, AuradineAT2880
class AuradineFluxAT2860(AuradineAT2860, Auradine): class AuradineFluxAT2860(AuradineAT2860, Auradine):

View File

@@ -1,5 +1,5 @@
from pyasic.miners.backends import Auradine from pyasic.miners.backends import Auradine
from pyasic.miners.types import AuradineAI2500 from pyasic.miners.models import AuradineAI2500
class AuradineFluxAI2500(AuradineAI2500, Auradine): class AuradineFluxAI2500(AuradineAI2500, Auradine):

View File

@@ -1,5 +1,5 @@
from pyasic.miners.backends import Auradine from pyasic.miners.backends import Auradine
from pyasic.miners.types import AuradineAI3680 from pyasic.miners.models import AuradineAI3680
class AuradineFluxAI3680(AuradineAI3680, Auradine): class AuradineFluxAI3680(AuradineAI3680, Auradine):

View File

@@ -1,5 +1,5 @@
from pyasic.miners.backends import Auradine from pyasic.miners.backends import Auradine
from pyasic.miners.types import AuradineAD2500 from pyasic.miners.models import AuradineAD2500
class AuradineFluxAD2500(AuradineAD2500, Auradine): class AuradineFluxAD2500(AuradineAD2500, Auradine):

View File

@@ -1,5 +1,5 @@
from pyasic.miners.backends import Auradine from pyasic.miners.backends import Auradine
from pyasic.miners.types import AuradineAD3500 from pyasic.miners.models import AuradineAD3500
class AuradineFluxAD3500(AuradineAD3500, Auradine): class AuradineFluxAD3500(AuradineAD3500, Auradine):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon1026 from pyasic.miners.models import Avalon1026
class CGMinerAvalon1026(AvalonMiner, Avalon1026): class CGMinerAvalon1026(AvalonMiner, Avalon1026):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon1047 from pyasic.miners.models import Avalon1047
class CGMinerAvalon1047(AvalonMiner, Avalon1047): class CGMinerAvalon1047(AvalonMiner, Avalon1047):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon1066 from pyasic.miners.models import Avalon1066
class CGMinerAvalon1066(AvalonMiner, Avalon1066): class CGMinerAvalon1066(AvalonMiner, Avalon1066):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon1166Pro from pyasic.miners.models import Avalon1166Pro
class CGMinerAvalon1166Pro(AvalonMiner, Avalon1166Pro): class CGMinerAvalon1166Pro(AvalonMiner, Avalon1166Pro):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon1246 from pyasic.miners.models import Avalon1246
class CGMinerAvalon1246(AvalonMiner, Avalon1246): class CGMinerAvalon1246(AvalonMiner, Avalon1246):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon721 from pyasic.miners.models import Avalon721
class CGMinerAvalon721(AvalonMiner, Avalon721): class CGMinerAvalon721(AvalonMiner, Avalon721):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon741 from pyasic.miners.models import Avalon741
class CGMinerAvalon741(AvalonMiner, Avalon741): class CGMinerAvalon741(AvalonMiner, Avalon741):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon761 from pyasic.miners.models import Avalon761
class CGMinerAvalon761(AvalonMiner, Avalon761): class CGMinerAvalon761(AvalonMiner, Avalon761):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon821 from pyasic.miners.models import Avalon821
class CGMinerAvalon821(AvalonMiner, Avalon821): class CGMinerAvalon821(AvalonMiner, Avalon821):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon841 from pyasic.miners.models import Avalon841
class CGMinerAvalon841(AvalonMiner, Avalon841): class CGMinerAvalon841(AvalonMiner, Avalon841):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon851 from pyasic.miners.models import Avalon851
class CGMinerAvalon851(AvalonMiner, Avalon851): class CGMinerAvalon851(AvalonMiner, Avalon851):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import AvalonMiner from pyasic.miners.backends import AvalonMiner
from pyasic.miners.types import Avalon921 from pyasic.miners.models import Avalon921
class CGMinerAvalon921(AvalonMiner, Avalon921): class CGMinerAvalon921(AvalonMiner, Avalon921):

View File

@@ -19,16 +19,16 @@ from typing import List, Optional, Union
from pyasic.config import MinerConfig, MiningModeConfig from pyasic.config import MinerConfig, MiningModeConfig
from pyasic.data import Fan, HashBoard from pyasic.data import Fan, HashBoard
from pyasic.data.error_codes import MinerErrorData, X19Error from pyasic.data.error_codes import MinerErrorData, X19Error
from pyasic.errors import APIError
from pyasic.miners.backends.bmminer import BMMiner from pyasic.miners.backends.bmminer import BMMiner
from pyasic.miners.backends.cgminer import CGMiner from pyasic.miners.backends.cgminer import CGMiner
from pyasic.miners.base import ( from pyasic.miners.data import (
DataFunction, DataFunction,
DataLocations, DataLocations,
DataOptions, DataOptions,
RPCAPICommand, RPCAPICommand,
WebAPICommand, WebAPICommand,
) )
from pyasic.rpc import APIError
from pyasic.ssh.antminer import AntminerModernSSH from pyasic.ssh.antminer import AntminerModernSSH
from pyasic.web.antminer import AntminerModernWebAPI, AntminerOldWebAPI from pyasic.web.antminer import AntminerModernWebAPI, AntminerOldWebAPI

View File

@@ -17,10 +17,11 @@ import logging
from enum import Enum from enum import Enum
from typing import List, Optional from typing import List, Optional
from pyasic import APIError, MinerConfig from pyasic.config import MinerConfig
from pyasic.data import Fan, HashBoard from pyasic.data import Fan, HashBoard
from pyasic.miners.base import ( from pyasic.errors import APIError
BaseMiner, from pyasic.miners.base import BaseMiner
from pyasic.miners.data import (
DataFunction, DataFunction,
DataLocations, DataLocations,
DataOptions, DataOptions,
@@ -28,7 +29,7 @@ from pyasic.miners.base import (
WebAPICommand, WebAPICommand,
) )
from pyasic.rpc.gcminer import GCMinerRPCAPI from pyasic.rpc.gcminer import GCMinerRPCAPI
from pyasic.web.auradine import FluxWebAPI from pyasic.web.auradine import AuradineWebAPI
AURADINE_DATA_LOC = DataLocations( AURADINE_DATA_LOC = DataLocations(
**{ **{
@@ -117,8 +118,8 @@ class Auradine(BaseMiner):
_api_cls = GCMinerRPCAPI _api_cls = GCMinerRPCAPI
api: GCMinerRPCAPI api: GCMinerRPCAPI
_web_cls = FluxWebAPI _web_cls = AuradineWebAPI
web: FluxWebAPI web: AuradineWebAPI
data_locations = AURADINE_DATA_LOC data_locations = AURADINE_DATA_LOC

View File

@@ -20,7 +20,7 @@ from typing import List, Optional
from pyasic.data import Fan, HashBoard from pyasic.data import Fan, HashBoard
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.backends.cgminer import CGMiner from pyasic.miners.backends.cgminer import CGMiner
from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPICommand from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
AVALON_DATA_LOC = DataLocations( AVALON_DATA_LOC = DataLocations(
**{ **{

View File

@@ -19,13 +19,8 @@ from typing import List, Optional
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import Fan, HashBoard from pyasic.data import Fan, HashBoard
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.base import ( from pyasic.miners.base import BaseMiner
BaseMiner, from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
DataFunction,
DataLocations,
DataOptions,
RPCAPICommand,
)
from pyasic.rpc.bfgminer import BFGMinerRPCAPI from pyasic.rpc.bfgminer import BFGMinerRPCAPI
BFGMINER_DATA_LOC = DataLocations( BFGMINER_DATA_LOC = DataLocations(

View File

@@ -19,13 +19,8 @@ from typing import List, Optional
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import Fan, HashBoard from pyasic.data import Fan, HashBoard
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.base import ( from pyasic.miners.base import BaseMiner
BaseMiner, from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
DataFunction,
DataLocations,
DataOptions,
RPCAPICommand,
)
from pyasic.rpc.bmminer import BMMinerRPCAPI from pyasic.rpc.bmminer import BMMinerRPCAPI
BMMINER_DATA_LOC = DataLocations( BMMINER_DATA_LOC = DataLocations(

View File

@@ -24,8 +24,8 @@ from pyasic.config.mining import MiningModePowerTune
from pyasic.data import Fan, HashBoard from pyasic.data import Fan, HashBoard
from pyasic.data.error_codes import BraiinsOSError, MinerErrorData from pyasic.data.error_codes import BraiinsOSError, MinerErrorData
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.base import ( from pyasic.miners.base import BaseMiner
BaseMiner, from pyasic.miners.data import (
DataFunction, DataFunction,
DataLocations, DataLocations,
DataOptions, DataOptions,

View File

@@ -21,13 +21,8 @@ from pyasic.config import MinerConfig, MiningModeConfig
from pyasic.data import Fan, HashBoard from pyasic.data import Fan, HashBoard
from pyasic.data.error_codes import MinerErrorData, WhatsminerError from pyasic.data.error_codes import MinerErrorData, WhatsminerError
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.base import ( from pyasic.miners.base import BaseMiner
BaseMiner, from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
DataFunction,
DataLocations,
DataOptions,
RPCAPICommand,
)
from pyasic.rpc.btminer import BTMinerRPCAPI from pyasic.rpc.btminer import BTMinerRPCAPI
BTMINER_DATA_LOC = DataLocations( BTMINER_DATA_LOC = DataLocations(

View File

@@ -18,13 +18,8 @@ from typing import Optional
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.base import ( from pyasic.miners.base import BaseMiner
BaseMiner, from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
DataFunction,
DataLocations,
DataOptions,
RPCAPICommand,
)
from pyasic.rpc.cgminer import CGMinerRPCAPI from pyasic.rpc.cgminer import CGMinerRPCAPI
CGMINER_DATA_LOC = DataLocations( CGMINER_DATA_LOC = DataLocations(

View File

@@ -21,13 +21,8 @@ from pyasic.data import Fan, HashBoard
from pyasic.data.error_codes import MinerErrorData, X19Error from pyasic.data.error_codes import MinerErrorData, X19Error
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.logger import logger from pyasic.logger import logger
from pyasic.miners.base import ( from pyasic.miners.base import BaseMiner
BaseMiner, from pyasic.miners.data import DataFunction, DataLocations, DataOptions, WebAPICommand
DataFunction,
DataLocations,
DataOptions,
WebAPICommand,
)
from pyasic.web.epic import ePICWebAPI from pyasic.web.epic import ePICWebAPI
EPIC_DATA_LOC = DataLocations( EPIC_DATA_LOC = DataLocations(

View File

@@ -20,7 +20,7 @@ from pyasic.data import HashBoard
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.logger import logger from pyasic.logger import logger
from pyasic.miners.backends import BFGMiner from pyasic.miners.backends import BFGMiner
from pyasic.miners.base import ( from pyasic.miners.data import (
DataFunction, DataFunction,
DataLocations, DataLocations,
DataOptions, DataOptions,

View File

@@ -21,7 +21,7 @@ from pyasic.data.error_codes import MinerErrorData
from pyasic.data.error_codes.innosilicon import InnosiliconError from pyasic.data.error_codes.innosilicon import InnosiliconError
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.backends import CGMiner from pyasic.miners.backends import CGMiner
from pyasic.miners.base import ( from pyasic.miners.data import (
DataFunction, DataFunction,
DataLocations, DataLocations,
DataOptions, DataOptions,

View File

@@ -18,13 +18,8 @@ from typing import List, Optional
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import Fan, HashBoard from pyasic.data import Fan, HashBoard
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.base import ( from pyasic.miners.base import BaseMiner
BaseMiner, from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
DataFunction,
DataLocations,
DataOptions,
RPCAPICommand,
)
from pyasic.rpc.luxminer import LUXMinerRPCAPI from pyasic.rpc.luxminer import LUXMinerRPCAPI
LUXMINER_DATA_LOC = DataLocations( LUXMINER_DATA_LOC = DataLocations(

View File

@@ -1,18 +1,16 @@
# ------------------------------------------------------------------------------ # Copyright 2022 Upstream Data Inc
# Copyright 2022 Upstream Data Inc - #
# - # Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License"); - # you may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License. - # You may obtain a copy of the License at
# You may obtain a copy of the License at - #
# - # http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0 - #
# - # Unless required by applicable law or agreed to in writing, software
# Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS,
# distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and - # limitations under the License.
# limitations under the License. -
# ------------------------------------------------------------------------------
from typing import List, Optional, Tuple from typing import List, Optional, Tuple

View File

@@ -19,7 +19,7 @@ from typing import Optional
from pyasic import MinerConfig from pyasic import MinerConfig
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.backends.bmminer import BMMiner from pyasic.miners.backends.bmminer import BMMiner
from pyasic.miners.base import ( from pyasic.miners.data import (
DataFunction, DataFunction,
DataLocations, DataLocations,
DataOptions, DataOptions,

View File

@@ -16,8 +16,6 @@
import asyncio import asyncio
import ipaddress import ipaddress
import warnings import warnings
from dataclasses import dataclass, field, make_dataclass
from enum import Enum
from typing import List, Optional, Protocol, Tuple, Type, TypeVar, Union from typing import List, Optional, Protocol, Tuple, Type, TypeVar, Union
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
@@ -25,79 +23,7 @@ from pyasic.data import Fan, HashBoard, MinerData
from pyasic.data.error_codes import MinerErrorData from pyasic.data.error_codes import MinerErrorData
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.logger import logger from pyasic.logger import logger
from pyasic.miners.data import DataLocations, DataOptions, RPCAPICommand, WebAPICommand
class DataOptions(Enum):
MAC = "mac"
API_VERSION = "api_ver"
FW_VERSION = "fw_ver"
HOSTNAME = "hostname"
HASHRATE = "hashrate"
EXPECTED_HASHRATE = "expected_hashrate"
HASHBOARDS = "hashboards"
ENVIRONMENT_TEMP = "env_temp"
WATTAGE = "wattage"
WATTAGE_LIMIT = "wattage_limit"
FANS = "fans"
FAN_PSU = "fan_psu"
ERRORS = "errors"
FAULT_LIGHT = "fault_light"
IS_MINING = "is_mining"
UPTIME = "uptime"
CONFIG = "config"
def __str__(self):
return self.value
def default_command(self):
if str(self.value) == "config":
return "get_config"
elif str(self.value) == "is_mining":
return "_is_mining"
else:
return f"_get_{str(self.value)}"
@dataclass
class RPCAPICommand:
name: str
cmd: str
@dataclass
class WebAPICommand:
name: str
cmd: str
@dataclass
class GRPCCommand(WebAPICommand):
name: str
cmd: str
@dataclass
class DataFunction:
cmd: str
kwargs: List[Union[RPCAPICommand, WebAPICommand, GRPCCommand]] = field(
default_factory=list
)
def __call__(self, *args, **kwargs):
return self
DataLocations = make_dataclass(
"DataLocations",
[
(
enum_value.value,
DataFunction,
field(default_factory=DataFunction(enum_value.default_command())),
)
for enum_value in DataOptions
],
)
class MinerProtocol(Protocol): class MinerProtocol(Protocol):

84
pyasic/miners/data.py Normal file
View File

@@ -0,0 +1,84 @@
# ------------------------------------------------------------------------------
# Copyright 2022 Upstream Data Inc -
# -
# Licensed under the Apache License, Version 2.0 (the "License"); -
# you may not use this file except in compliance with the License. -
# You may obtain a copy of the License at -
# -
# http://www.apache.org/licenses/LICENSE-2.0 -
# -
# Unless required by applicable law or agreed to in writing, software -
# distributed under the License is distributed on an "AS IS" BASIS, -
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
# See the License for the specific language governing permissions and -
# limitations under the License. -
# ------------------------------------------------------------------------------
from dataclasses import dataclass, field, make_dataclass
from enum import Enum
from typing import List, Union
class DataOptions(Enum):
MAC = "mac"
API_VERSION = "api_ver"
FW_VERSION = "fw_ver"
HOSTNAME = "hostname"
HASHRATE = "hashrate"
EXPECTED_HASHRATE = "expected_hashrate"
HASHBOARDS = "hashboards"
ENVIRONMENT_TEMP = "env_temp"
WATTAGE = "wattage"
WATTAGE_LIMIT = "wattage_limit"
FANS = "fans"
FAN_PSU = "fan_psu"
ERRORS = "errors"
FAULT_LIGHT = "fault_light"
IS_MINING = "is_mining"
UPTIME = "uptime"
CONFIG = "config"
def __str__(self):
return self.value
def default_command(self):
if str(self.value) == "config":
return "get_config"
elif str(self.value) == "is_mining":
return "_is_mining"
else:
return f"_get_{str(self.value)}"
@dataclass
class RPCAPICommand:
name: str
cmd: str
@dataclass
class WebAPICommand:
name: str
cmd: str
@dataclass
class DataFunction:
cmd: str
kwargs: List[Union[RPCAPICommand, WebAPICommand]] = field(default_factory=list)
def __call__(self, *args, **kwargs):
return self
DataLocations = make_dataclass(
"DataLocations",
[
(
enum_value.value,
DataFunction,
field(default_factory=DataFunction(enum_value.default_command())),
)
for enum_value in DataOptions
],
)

View File

@@ -25,6 +25,7 @@ import httpx
from pyasic import settings from pyasic import settings
from pyasic.logger import logger from pyasic.logger import logger
from pyasic.miners import AnyMiner
from pyasic.miners.antminer import * from pyasic.miners.antminer import *
from pyasic.miners.auradine import * from pyasic.miners.auradine import *
from pyasic.miners.avalonminer import * from pyasic.miners.avalonminer import *
@@ -41,10 +42,9 @@ from pyasic.miners.backends import (
VNish, VNish,
ePIC, ePIC,
) )
from pyasic.miners.base import AnyMiner from pyasic.miners.backends.unknown import UnknownMiner
from pyasic.miners.goldshell import * from pyasic.miners.goldshell import *
from pyasic.miners.innosilicon import * from pyasic.miners.innosilicon import *
from pyasic.miners.unknown import UnknownMiner
from pyasic.miners.whatsminer import * from pyasic.miners.whatsminer import *

View File

@@ -14,7 +14,7 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import GoldshellMiner from pyasic.miners.backends import GoldshellMiner
from pyasic.miners.types import CK5 from pyasic.miners.models import CK5
class GoldshellCK5(GoldshellMiner, CK5): class GoldshellCK5(GoldshellMiner, CK5):

View File

@@ -14,7 +14,7 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import GoldshellMiner from pyasic.miners.backends import GoldshellMiner
from pyasic.miners.types import HS5 from pyasic.miners.models import HS5
class GoldshellHS5(GoldshellMiner, HS5): class GoldshellHS5(GoldshellMiner, HS5):

View File

@@ -14,7 +14,7 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import GoldshellMiner from pyasic.miners.backends import GoldshellMiner
from pyasic.miners.types import KD5 from pyasic.miners.models import KD5
class GoldshellKD5(GoldshellMiner, KD5): class GoldshellKD5(GoldshellMiner, KD5):

View File

@@ -14,7 +14,7 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends import GoldshellMiner from pyasic.miners.backends import GoldshellMiner
from pyasic.miners.types import KDMax from pyasic.miners.models import KDMax
class GoldshellKDMax(GoldshellMiner, KDMax): class GoldshellKDMax(GoldshellMiner, KDMax):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends.innosilicon import Innosilicon from pyasic.miners.backends.innosilicon import Innosilicon
from pyasic.miners.types import A10X from pyasic.miners.models import A10X
class InnosiliconA10X(Innosilicon, A10X): class InnosiliconA10X(Innosilicon, A10X):

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from pyasic.miners.backends.innosilicon import Innosilicon from pyasic.miners.backends.innosilicon import Innosilicon
from pyasic.miners.types import T3HPlus from pyasic.miners.models import T3HPlus
class InnosiliconT3HPlus(Innosilicon, T3HPlus): class InnosiliconT3HPlus(Innosilicon, T3HPlus):

Some files were not shown because too many files have changed in this diff Show More