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