2022-12-11 14:02:55 +00:00
|
|
|
import pytest
|
|
|
|
|
2025-01-10 00:25:00 +00:00
|
|
|
from skynet.config import *
|
2023-09-24 18:23:25 +00:00
|
|
|
from skynet.ipfs import AsyncIPFSHTTP
|
2022-12-11 14:02:55 +00:00
|
|
|
|
|
|
|
|
2023-09-24 18:23:25 +00:00
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
def ipfs_client():
|
2025-02-03 21:48:29 +00:00
|
|
|
yield AsyncIPFSHTTP('http://127.0.0.1:5001')
|
2023-09-24 18:23:25 +00:00
|
|
|
|
2025-02-07 23:24:31 +00:00
|
|
|
|
2022-12-11 14:02:55 +00:00
|
|
|
@pytest.fixture(scope='session')
|
2023-05-22 09:10:51 +00:00
|
|
|
def postgres_db():
|
2025-01-10 00:25:00 +00:00
|
|
|
from skynet.db import open_new_database
|
2023-01-22 15:12:33 +00:00
|
|
|
with open_new_database() as db_params:
|
|
|
|
yield db_params
|
2022-12-11 14:02:55 +00:00
|
|
|
|
2025-02-07 23:24:31 +00:00
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
|
|
def skynet_cleos(cleos_bs):
|
|
|
|
cleos = cleos_bs
|
|
|
|
|
|
|
|
priv, pub = cleos.create_key_pair()
|
|
|
|
cleos.import_key('telos.gpu', priv)
|
|
|
|
cleos.new_account('telos.gpu', ram=4200000, key=pub)
|
|
|
|
|
|
|
|
cleos.deploy_contract_from_path(
|
|
|
|
'telos.gpu',
|
|
|
|
'tests/contracts/telos.gpu',
|
|
|
|
create_account=False
|
|
|
|
)
|
|
|
|
|
|
|
|
cleos.push_action(
|
|
|
|
'telos.gpu',
|
|
|
|
'config',
|
|
|
|
['eosio.token', '4,GPU'],
|
|
|
|
'telos.gpu'
|
|
|
|
)
|
|
|
|
|
|
|
|
yield cleos
|
|
|
|
|
2025-01-10 00:25:00 +00:00
|
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
def dgpu():
|
2025-02-03 21:31:12 +00:00
|
|
|
from skynet.dgpu.network import NetConnector
|
|
|
|
from skynet.dgpu.compute import ModelMngr
|
|
|
|
from skynet.dgpu.daemon import WorkerDaemon
|
2025-01-10 00:25:00 +00:00
|
|
|
|
|
|
|
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']
|
2025-02-03 21:31:12 +00:00
|
|
|
conn = NetConnector(config)
|
|
|
|
mm = ModelMngr(config)
|
|
|
|
daemon = WorkerDaemon(mm, conn, config)
|
2025-01-10 00:25:00 +00:00
|
|
|
|
|
|
|
yield conn, mm, daemon
|