mirror of https://github.com/skygpu/skynet.git
Changes to frontend schema for better accuracy on configs
New fix for nonce / request hashing system which had a bug with multi request per user case Add queue command to frontend Better meta info captionsadd-txt2txt-models
parent
25c86b5eaf
commit
c26b4fc468
|
@ -41,9 +41,9 @@ CREATE TABLE IF NOT EXISTS skynet.user_config(
|
||||||
step INT NOT NULL,
|
step INT NOT NULL,
|
||||||
width INT NOT NULL,
|
width INT NOT NULL,
|
||||||
height INT NOT NULL,
|
height INT NOT NULL,
|
||||||
seed BIGINT,
|
seed NUMERIC,
|
||||||
guidance REAL NOT NULL,
|
guidance DECIMAL NOT NULL,
|
||||||
strength REAL NOT NULL,
|
strength DECIMAL NOT NULL,
|
||||||
upscaler VARCHAR(128)
|
upscaler VARCHAR(128)
|
||||||
);
|
);
|
||||||
ALTER TABLE skynet.user_config
|
ALTER TABLE skynet.user_config
|
||||||
|
|
|
@ -325,7 +325,7 @@ async def open_dgpu_node(
|
||||||
binary = await get_input_data(req['binary_data'])
|
binary = await get_input_data(req['binary_data'])
|
||||||
|
|
||||||
hash_str = (
|
hash_str = (
|
||||||
str(await get_user_nonce(req['user']))
|
str(req['nonce'])
|
||||||
+
|
+
|
||||||
req['body']
|
req['body']
|
||||||
+
|
+
|
||||||
|
|
|
@ -7,8 +7,9 @@ import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from decimal import Decimal
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import asks
|
import asks
|
||||||
import docker
|
import docker
|
||||||
|
@ -46,7 +47,7 @@ def build_redo_menu():
|
||||||
return inline_keyboard
|
return inline_keyboard
|
||||||
|
|
||||||
|
|
||||||
def prepare_metainfo_caption(tguser, worker: str, meta: dict) -> str:
|
def prepare_metainfo_caption(tguser, worker: str, reward: str, meta: dict) -> str:
|
||||||
prompt = meta["prompt"]
|
prompt = meta["prompt"]
|
||||||
if len(prompt) > 256:
|
if len(prompt) > 256:
|
||||||
prompt = prompt[:256]
|
prompt = prompt[:256]
|
||||||
|
@ -56,7 +57,9 @@ def prepare_metainfo_caption(tguser, worker: str, meta: dict) -> str:
|
||||||
else:
|
else:
|
||||||
user = f'{tguser.first_name} id: {tguser.id}'
|
user = f'{tguser.first_name} id: {tguser.id}'
|
||||||
|
|
||||||
meta_str = f'<u>by {user}</u> <i>performed by {worker}</i>\n'
|
meta_str = f'<u>by {user}</u>'
|
||||||
|
meta_str += f'<i>performed by {worker}</i>\n'
|
||||||
|
meta_str += f'<b><u>reward: {reward}</u></b>\n'
|
||||||
|
|
||||||
meta_str += f'<code>prompt:</code> {prompt}\n'
|
meta_str += f'<code>prompt:</code> {prompt}\n'
|
||||||
meta_str += f'<code>seed: {meta["seed"]}</code>\n'
|
meta_str += f'<code>seed: {meta["seed"]}</code>\n'
|
||||||
|
@ -68,7 +71,7 @@ def prepare_metainfo_caption(tguser, worker: str, meta: dict) -> str:
|
||||||
if meta['upscaler']:
|
if meta['upscaler']:
|
||||||
meta_str += f'<code>upscaler: {meta["upscaler"]}</code>\n'
|
meta_str += f'<code>upscaler: {meta["upscaler"]}</code>\n'
|
||||||
|
|
||||||
meta_str += f'<b><u>Made with Skynet {VERSION}</u></b>\n'
|
meta_str += f'<b><u>Made with Skynet v{VERSION}</u></b>\n'
|
||||||
meta_str += f'<b>JOIN THE SWARM: @skynetgpu</b>'
|
meta_str += f'<b>JOIN THE SWARM: @skynetgpu</b>'
|
||||||
return meta_str
|
return meta_str
|
||||||
|
|
||||||
|
@ -78,7 +81,8 @@ def generate_reply_caption(
|
||||||
params: dict,
|
params: dict,
|
||||||
ipfs_hash: str,
|
ipfs_hash: str,
|
||||||
tx_hash: str,
|
tx_hash: str,
|
||||||
worker: str
|
worker: str,
|
||||||
|
reward: str
|
||||||
):
|
):
|
||||||
ipfs_link = hlink(
|
ipfs_link = hlink(
|
||||||
'Get your image on IPFS',
|
'Get your image on IPFS',
|
||||||
|
@ -89,7 +93,7 @@ def generate_reply_caption(
|
||||||
f'http://test1.us.telos.net:42001/v2/explore/transaction/{tx_hash}'
|
f'http://test1.us.telos.net:42001/v2/explore/transaction/{tx_hash}'
|
||||||
)
|
)
|
||||||
|
|
||||||
meta_info = prepare_metainfo_caption(tguser, worker, params)
|
meta_info = prepare_metainfo_caption(tguser, worker, reward, params)
|
||||||
|
|
||||||
final_msg = '\n'.join([
|
final_msg = '\n'.join([
|
||||||
'Worker finished your task!',
|
'Worker finished your task!',
|
||||||
|
@ -132,27 +136,36 @@ async def work_request(
|
||||||
binary_data: str = ''
|
binary_data: str = ''
|
||||||
):
|
):
|
||||||
if params['seed'] == None:
|
if params['seed'] == None:
|
||||||
params['seed'] = random.randint(0, 9e18)
|
params['seed'] = random.randint(0, 0xFFFFFFFF)
|
||||||
|
|
||||||
|
sanitized_params = {}
|
||||||
|
for key, val in params.items():
|
||||||
|
if isinstance(val, Decimal):
|
||||||
|
val = int(val)
|
||||||
|
|
||||||
|
sanitized_params[key] = val
|
||||||
|
|
||||||
body = json.dumps({
|
body = json.dumps({
|
||||||
'method': 'diffuse',
|
'method': 'diffuse',
|
||||||
'params': params
|
'params': sanitized_params
|
||||||
})
|
})
|
||||||
request_time = datetime.now().isoformat()
|
request_time = datetime.now().isoformat()
|
||||||
|
|
||||||
|
reward = '20.0000 GPU'
|
||||||
ec, out = cleos.push_action(
|
ec, out = cleos.push_action(
|
||||||
'telos.gpu', 'enqueue', [account, body, binary_data, '20.0000 GPU'], f'{account}@{permission}'
|
'telos.gpu', 'enqueue', [account, body, binary_data, reward], f'{account}@{permission}'
|
||||||
)
|
)
|
||||||
out = collect_stdout(out)
|
out = collect_stdout(out)
|
||||||
if ec != 0:
|
if ec != 0:
|
||||||
await bot.reply_to(message, out)
|
await bot.reply_to(message, out)
|
||||||
return
|
return
|
||||||
|
|
||||||
nonce = await get_user_nonce(cleos, account)
|
request_id, nonce = out.split(':')
|
||||||
request_hash = sha256(
|
|
||||||
(str(nonce) + body + binary_data).encode('utf-8')).hexdigest().upper()
|
|
||||||
|
|
||||||
request_id = int(out)
|
request_hash = sha256(
|
||||||
|
(nonce + body + binary_data).encode('utf-8')).hexdigest().upper()
|
||||||
|
|
||||||
|
request_id = int(request_id)
|
||||||
logging.info(f'{request_id} enqueued.')
|
logging.info(f'{request_id} enqueued.')
|
||||||
|
|
||||||
config = await get_global_config(cleos)
|
config = await get_global_config(cleos)
|
||||||
|
@ -177,6 +190,7 @@ async def work_request(
|
||||||
data = actions[0]['act']['data']
|
data = actions[0]['act']['data']
|
||||||
ipfs_hash = data['ipfs_hash']
|
ipfs_hash = data['ipfs_hash']
|
||||||
worker = data['worker']
|
worker = data['worker']
|
||||||
|
logging.info('Found matching submit!')
|
||||||
break
|
break
|
||||||
|
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
@ -190,7 +204,7 @@ async def work_request(
|
||||||
resp = await get_ipfs_file(ipfs_link)
|
resp = await get_ipfs_file(ipfs_link)
|
||||||
|
|
||||||
caption = generate_reply_caption(
|
caption = generate_reply_caption(
|
||||||
user, params, ipfs_hash, tx_hash, worker)
|
user, params, ipfs_hash, tx_hash, worker, reward)
|
||||||
|
|
||||||
if not resp or resp.status_code != 200:
|
if not resp or resp.status_code != 200:
|
||||||
logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!')
|
logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!')
|
||||||
|
@ -469,6 +483,19 @@ async def run_skynet_telegram(
|
||||||
binary_data=binary
|
binary_data=binary
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['queue'])
|
||||||
|
async def queue(message):
|
||||||
|
an_hour_ago = datetime.now() - timedelta(hours=1)
|
||||||
|
queue = await cleos.aget_table(
|
||||||
|
'telos.gpu', 'telos.gpu', 'queue',
|
||||||
|
index_position=2,
|
||||||
|
key_type='i64',
|
||||||
|
sort='desc',
|
||||||
|
lower_bound=int(an_hour_ago.timestamp())
|
||||||
|
)
|
||||||
|
await bot.reply_to(
|
||||||
|
message, f'Total requests on skynet queue: {len(queue)}')
|
||||||
|
|
||||||
@bot.message_handler(commands=['redo'])
|
@bot.message_handler(commands=['redo'])
|
||||||
async def redo(message):
|
async def redo(message):
|
||||||
await _redo(message)
|
await _redo(message)
|
||||||
|
@ -494,6 +521,7 @@ async def run_skynet_telegram(
|
||||||
async def user_stats(message):
|
async def user_stats(message):
|
||||||
user = message.from_user.id
|
user = message.from_user.id
|
||||||
|
|
||||||
|
await db_call('get_or_create_user', user.id)
|
||||||
generated, joined, role = await db_call('get_user_stats', user)
|
generated, joined, role = await db_call('get_user_stats', user)
|
||||||
|
|
||||||
stats_str = f'generated: {generated}\n'
|
stats_str = f'generated: {generated}\n'
|
||||||
|
|
Loading…
Reference in New Issue