2022-12-11 14:02:55 +00:00
|
|
|
import pytest
|
|
|
|
|
2023-09-24 18:23:25 +00:00
|
|
|
from skynet.ipfs import AsyncIPFSHTTP
|
2025-02-11 20:07:55 +00:00
|
|
|
from skynet._testing import override_dgpu_config
|
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
|
|
|
|
|
2025-02-11 19:20:26 +00:00
|
|
|
# priv, pub = cleos.create_key_pair()
|
|
|
|
# cleos.import_key('gpu.scd', priv)
|
|
|
|
cleos.new_account('gpu.scd', ram=4200000)
|
2025-02-07 23:24:31 +00:00
|
|
|
|
|
|
|
cleos.deploy_contract_from_path(
|
2025-02-11 17:08:17 +00:00
|
|
|
'gpu.scd',
|
|
|
|
'tests/contracts/gpu.scd',
|
2025-02-07 23:24:31 +00:00
|
|
|
create_account=False
|
|
|
|
)
|
|
|
|
|
|
|
|
cleos.push_action(
|
2025-02-11 17:08:17 +00:00
|
|
|
'gpu.scd',
|
2025-02-07 23:24:31 +00:00
|
|
|
'config',
|
2025-02-11 17:08:17 +00:00
|
|
|
['eosio.token', '4,TLOS'],
|
|
|
|
'gpu.scd'
|
2025-02-07 23:24:31 +00:00
|
|
|
)
|
|
|
|
|
2025-02-11 19:20:26 +00:00
|
|
|
cleos.new_account('testworker')
|
|
|
|
|
2025-02-07 23:24:31 +00:00
|
|
|
yield cleos
|
|
|
|
|
2025-01-10 00:25:00 +00:00
|
|
|
|
2025-02-08 01:01:00 +00:00
|
|
|
@pytest.fixture
|
|
|
|
def inject_mockers():
|
2025-02-11 17:08:17 +00:00
|
|
|
from skynet.constants import MODELS
|
2025-02-11 20:07:55 +00:00
|
|
|
from skynet.types import ModelDesc, ModelMode
|
2025-02-08 01:01:00 +00:00
|
|
|
|
2025-02-11 20:07:55 +00:00
|
|
|
MODELS['skygpu/mocker'] = ModelDesc(
|
2025-02-08 01:01:00 +00:00
|
|
|
short='tester',
|
|
|
|
mem=0.01,
|
|
|
|
attrs={},
|
2025-02-11 20:07:55 +00:00
|
|
|
tags=[
|
|
|
|
ModelMode.TXT2IMG,
|
|
|
|
ModelMode.IMG2IMG,
|
|
|
|
ModelMode.INPAINT
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
MODELS['skygpu/mocker-upscale'] = ModelDesc(
|
|
|
|
short='tester-upscale',
|
|
|
|
mem=0.01,
|
|
|
|
attrs={},
|
|
|
|
tags=[
|
|
|
|
ModelMode.UPSCALE
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
override_dgpu_config(
|
|
|
|
account='testworker1',
|
|
|
|
permission='active',
|
|
|
|
key='',
|
|
|
|
node_url='',
|
|
|
|
ipfs_url='http://127.0.0.1:5001',
|
|
|
|
hf_token=''
|
2025-02-08 01:01:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
yield
|
2025-02-11 19:20:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
def ipfs_node(dockerctl):
|
|
|
|
rpc_port = 15001
|
|
|
|
with dockerctl.run(
|
|
|
|
'ipfs/go-ipfs:latest',
|
|
|
|
name='skynet-ipfs',
|
|
|
|
ports={
|
|
|
|
'8080/tcp': 18080,
|
|
|
|
'4001/tcp': 14001,
|
|
|
|
'5001/tcp': ('127.0.0.1', rpc_port)
|
2025-02-11 19:25:40 +00:00
|
|
|
},
|
|
|
|
timeout=60
|
2025-02-11 19:20:26 +00:00
|
|
|
) as cntr:
|
|
|
|
yield cntr, AsyncIPFSHTTP(f'http://127.0.0.1:{rpc_port}')
|