mirror of https://github.com/skygpu/skynet.git
Change dgpu submodules classes name per fomos suggestion
parent
933063f766
commit
88ab4d0eae
|
@ -4,21 +4,21 @@ from hypercorn.config import Config
|
|||
from hypercorn.trio import serve
|
||||
from quart_trio import QuartTrio as Quart
|
||||
|
||||
from skynet.dgpu.compute import SkynetMM
|
||||
from skynet.dgpu.daemon import SkynetDGPUDaemon
|
||||
from skynet.dgpu.network import SkynetGPUConnector
|
||||
from skynet.dgpu.compute import ModelMngr
|
||||
from skynet.dgpu.daemon import WorkerDaemon
|
||||
from skynet.dgpu.network import NetConnector
|
||||
|
||||
|
||||
async def open_dgpu_node(config: dict) -> None:
|
||||
'''
|
||||
Open a top level "GPU mgmt daemon", keep the
|
||||
`SkynetDGPUDaemon._snap: dict[str, list|dict]` table
|
||||
`WorkerDaemon._snap: dict[str, list|dict]` table
|
||||
and *maybe* serve a `hypercorn` web API.
|
||||
|
||||
'''
|
||||
conn = SkynetGPUConnector(config)
|
||||
mm = SkynetMM(config)
|
||||
daemon = SkynetDGPUDaemon(mm, conn, config)
|
||||
conn = NetConnector(config)
|
||||
mm = ModelMngr(config)
|
||||
daemon = WorkerDaemon(mm, conn, config)
|
||||
|
||||
api: Quart|None = None
|
||||
if 'api_bind' in config:
|
||||
|
|
|
@ -66,8 +66,7 @@ def prepare_params_for_diffuse(
|
|||
)
|
||||
|
||||
|
||||
# TODO, yet again - drop the redundant prefix ;)
|
||||
class SkynetMM:
|
||||
class ModelMngr:
|
||||
'''
|
||||
(AI algo) Model manager for loading models, computing outputs,
|
||||
checking load state, and unloading when no-longer-needed/finished.
|
||||
|
|
|
@ -17,8 +17,8 @@ from skynet.constants import (
|
|||
from skynet.dgpu.errors import (
|
||||
DGPUComputeError,
|
||||
)
|
||||
from skynet.dgpu.compute import SkynetMM
|
||||
from skynet.dgpu.network import SkynetGPUConnector
|
||||
from skynet.dgpu.compute import ModelMngr
|
||||
from skynet.dgpu.network import NetConnector
|
||||
|
||||
|
||||
def convert_reward_to_int(reward_str):
|
||||
|
@ -29,8 +29,7 @@ def convert_reward_to_int(reward_str):
|
|||
return int(int_part + decimal_part)
|
||||
|
||||
|
||||
# prolly don't need the `Skynet` prefix since that's kinda implied ;p
|
||||
class SkynetDGPUDaemon:
|
||||
class WorkerDaemon:
|
||||
'''
|
||||
The root "GPU daemon".
|
||||
|
||||
|
@ -40,12 +39,12 @@ class SkynetDGPUDaemon:
|
|||
'''
|
||||
def __init__(
|
||||
self,
|
||||
mm: SkynetMM,
|
||||
conn: SkynetGPUConnector,
|
||||
mm: ModelMngr,
|
||||
conn: NetConnector,
|
||||
config: dict
|
||||
):
|
||||
self.mm: SkynetMM = mm
|
||||
self.conn: SkynetGPUConnector = conn
|
||||
self.mm: ModelMngr = mm
|
||||
self.conn: NetConnector = conn
|
||||
self.auto_withdraw = (
|
||||
config['auto_withdraw']
|
||||
if 'auto_withdraw' in config else False
|
||||
|
@ -147,7 +146,7 @@ class SkynetDGPUDaemon:
|
|||
|
||||
# TODO? this func is kinda big and maybe is better at module
|
||||
# level to reduce indentation?
|
||||
# -[ ] just pass `daemon: SkynetDGPUDaemon` vs. `self`
|
||||
# -[ ] just pass `daemon: WorkerDaemon` vs. `self`
|
||||
async def maybe_serve_one(
|
||||
self,
|
||||
req: dict,
|
||||
|
@ -271,7 +270,7 @@ class SkynetDGPUDaemon:
|
|||
|
||||
# TODO, as per above on `.maybe_serve_one()`, it's likely a bit
|
||||
# more *trionic* to define this all as a module level task-func
|
||||
# which operates on a `daemon: SkynetDGPUDaemon`?
|
||||
# which operates on a `daemon: WorkerDaemon`?
|
||||
#
|
||||
# -[ ] keeps tasks-as-funcs style prominent
|
||||
# -[ ] avoids so much indentation due to methods
|
||||
|
|
|
@ -46,10 +46,7 @@ async def failable(fn: partial, ret_fail=None):
|
|||
return o.unwrap()
|
||||
|
||||
|
||||
# TODO, again the prefix XD
|
||||
# -[ ] better name then `GPUConnector` ??
|
||||
# |_ `Compute[Net]IO[Mngr]`
|
||||
class SkynetGPUConnector:
|
||||
class NetConnector:
|
||||
'''
|
||||
An API for connecting to and conducting various "high level"
|
||||
network-service operations in the skynet.
|
||||
|
|
|
@ -24,17 +24,17 @@ def cleos():
|
|||
|
||||
@pytest.fixture(scope='session')
|
||||
def dgpu():
|
||||
from skynet.dgpu.network import SkynetGPUConnector
|
||||
from skynet.dgpu.compute import SkynetMM
|
||||
from skynet.dgpu.daemon import SkynetDGPUDaemon
|
||||
from skynet.dgpu.network import NetConnector
|
||||
from skynet.dgpu.compute import ModelMngr
|
||||
from skynet.dgpu.daemon import WorkerDaemon
|
||||
|
||||
config = load_skynet_toml(file_path='skynet.toml')
|
||||
hf_token = load_key(config, 'skynet.dgpu.hf_token')
|
||||
hf_home = load_key(config, 'skynet.dgpu.hf_home')
|
||||
set_hf_vars(hf_token, hf_home)
|
||||
config = config['skynet']['dgpu']
|
||||
conn = SkynetGPUConnector(config)
|
||||
mm = SkynetMM(config)
|
||||
daemon = SkynetDGPUDaemon(mm, conn, config)
|
||||
conn = NetConnector(config)
|
||||
mm = ModelMngr(config)
|
||||
daemon = WorkerDaemon(mm, conn, config)
|
||||
|
||||
yield conn, mm, daemon
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
|
||||
from skynet.dgpu.compute import SkynetMM
|
||||
from skynet.dgpu.compute import ModelMngr
|
||||
from skynet.constants import *
|
||||
from skynet.config import *
|
||||
|
||||
|
|
Loading…
Reference in New Issue