From 88ab4d0eae65259682ef9af19c7c9f57aa4dc0ab Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Mon, 3 Feb 2025 18:31:12 -0300 Subject: [PATCH] Change dgpu submodules classes name per fomos suggestion --- skynet/dgpu/__init__.py | 14 +++++++------- skynet/dgpu/compute.py | 3 +-- skynet/dgpu/daemon.py | 19 +++++++++---------- skynet/dgpu/network.py | 5 +---- tests/conftest.py | 12 ++++++------ tests/test_reqs.py | 2 +- 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/skynet/dgpu/__init__.py b/skynet/dgpu/__init__.py index e906418..eb93697 100755 --- a/skynet/dgpu/__init__.py +++ b/skynet/dgpu/__init__.py @@ -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: diff --git a/skynet/dgpu/compute.py b/skynet/dgpu/compute.py index f069e60..085b2a3 100755 --- a/skynet/dgpu/compute.py +++ b/skynet/dgpu/compute.py @@ -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. diff --git a/skynet/dgpu/daemon.py b/skynet/dgpu/daemon.py index 0f49ff7..a709d0b 100755 --- a/skynet/dgpu/daemon.py +++ b/skynet/dgpu/daemon.py @@ -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 diff --git a/skynet/dgpu/network.py b/skynet/dgpu/network.py index 21ddfd8..19d78f5 100755 --- a/skynet/dgpu/network.py +++ b/skynet/dgpu/network.py @@ -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. diff --git a/tests/conftest.py b/tests/conftest.py index 34309dd..f990935 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 diff --git a/tests/test_reqs.py b/tests/test_reqs.py index d55c940..48ca886 100644 --- a/tests/test_reqs.py +++ b/tests/test_reqs.py @@ -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 *