mirror of https://github.com/skygpu/skynet.git
				
				
				
			Doc and type `skynet.dgpu` pkg mod
							parent
							
								
									802af99c39
								
							
						
					
					
						commit
						01e6bfe252
					
				| 
						 | 
				
			
			@ -4,27 +4,36 @@ import trio
 | 
			
		|||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def open_dgpu_node(config: dict):
 | 
			
		||||
async def open_dgpu_node(config: dict) -> None:
 | 
			
		||||
    '''
 | 
			
		||||
    Open a top level "GPU mgmt daemon", keep the
 | 
			
		||||
    `SkynetDGPUDaemon._snap: dict[str, list|dict]` table and *maybe*
 | 
			
		||||
    serve a `hypercorn` web API.
 | 
			
		||||
 | 
			
		||||
    '''
 | 
			
		||||
    conn = SkynetGPUConnector(config)
 | 
			
		||||
    mm = SkynetMM(config)
 | 
			
		||||
    daemon = SkynetDGPUDaemon(mm, conn, config)
 | 
			
		||||
 | 
			
		||||
    api = None
 | 
			
		||||
    api: Quart|None = None
 | 
			
		||||
    if 'api_bind' in config:
 | 
			
		||||
        api_conf = Config()
 | 
			
		||||
        api_conf.bind = [config['api_bind']]
 | 
			
		||||
        api = await daemon.generate_api()
 | 
			
		||||
        api: Quart = await daemon.generate_api()
 | 
			
		||||
 | 
			
		||||
    async with trio.open_nursery() as n:
 | 
			
		||||
        n.start_soon(daemon.snap_updater_task)
 | 
			
		||||
    tn: trio.Nursery
 | 
			
		||||
    async with trio.open_nursery() as tn:
 | 
			
		||||
        tn.start_soon(daemon.snap_updater_task)
 | 
			
		||||
 | 
			
		||||
        if api:
 | 
			
		||||
            n.start_soon(serve, api, api_conf)
 | 
			
		||||
            tn.start_soon(serve, api, api_conf)
 | 
			
		||||
 | 
			
		||||
        # block until cancelled
 | 
			
		||||
        await daemon.serve_forever()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue