mirror of https://github.com/skygpu/skynet.git
Doc and type `skynet.dgpu` pkg mod
parent
2e50b1a542
commit
c0ac6298a9
|
@ -4,27 +4,36 @@ import trio
|
||||||
|
|
||||||
from hypercorn.config import Config
|
from hypercorn.config import Config
|
||||||
from hypercorn.trio import serve
|
from hypercorn.trio import serve
|
||||||
|
from quart_trio import QuartTrio as Quart
|
||||||
|
|
||||||
from skynet.dgpu.compute import SkynetMM
|
from skynet.dgpu.compute import SkynetMM
|
||||||
from skynet.dgpu.daemon import SkynetDGPUDaemon
|
from skynet.dgpu.daemon import SkynetDGPUDaemon
|
||||||
from skynet.dgpu.network import SkynetGPUConnector
|
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)
|
conn = SkynetGPUConnector(config)
|
||||||
mm = SkynetMM(config)
|
mm = SkynetMM(config)
|
||||||
daemon = SkynetDGPUDaemon(mm, conn, config)
|
daemon = SkynetDGPUDaemon(mm, conn, config)
|
||||||
|
|
||||||
api = None
|
api: Quart|None = None
|
||||||
if 'api_bind' in config:
|
if 'api_bind' in config:
|
||||||
api_conf = Config()
|
api_conf = Config()
|
||||||
api_conf.bind = [config['api_bind']]
|
api_conf.bind = [config['api_bind']]
|
||||||
api = await daemon.generate_api()
|
api: Quart = await daemon.generate_api()
|
||||||
|
|
||||||
async with trio.open_nursery() as n:
|
tn: trio.Nursery
|
||||||
n.start_soon(daemon.snap_updater_task)
|
async with trio.open_nursery() as tn:
|
||||||
|
tn.start_soon(daemon.snap_updater_task)
|
||||||
|
|
||||||
if api:
|
if api:
|
||||||
n.start_soon(serve, api, api_conf)
|
tn.start_soon(serve, api, api_conf)
|
||||||
|
|
||||||
|
# block until cancelled
|
||||||
await daemon.serve_forever()
|
await daemon.serve_forever()
|
||||||
|
|
Loading…
Reference in New Issue