From 257e987fe2bc7a68f6679a035f0cf7ce1190e4fb Mon Sep 17 00:00:00 2001 From: Konstantine Tsafatinos Date: Fri, 13 Oct 2023 23:21:57 -0400 Subject: [PATCH 1/9] edit discord init --- skynet/frontend/discord/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skynet/frontend/discord/__init__.py b/skynet/frontend/discord/__init__.py index b083942..d68dca1 100644 --- a/skynet/frontend/discord/__init__.py +++ b/skynet/frontend/discord/__init__.py @@ -66,7 +66,7 @@ class SkynetDiscordFrontend: self.bot = DiscordBot(self) self.cleos = CLEOS(None, None, url=node_url, remote=node_url) self.hyperion = HyperionAPI(hyperion_url) - self.ipfs_node = AsyncIPFSHTTP(ipfs_node) + self.ipfs_node = AsyncIPFSHTTP(ipfs_url) self._exit_stack = ExitStack() self._async_exit_stack = AsyncExitStack() From aeb595ce9abc13a04bd99b813de669e78d676b00 Mon Sep 17 00:00:00 2001 From: Konstantine Tsafatinos Date: Fri, 13 Oct 2023 23:27:16 -0400 Subject: [PATCH 2/9] edit discord init to change default domain to explorer domain --- skynet/frontend/discord/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skynet/frontend/discord/__init__.py b/skynet/frontend/discord/__init__.py index d68dca1..4560e72 100644 --- a/skynet/frontend/discord/__init__.py +++ b/skynet/frontend/discord/__init__.py @@ -234,7 +234,7 @@ class SkynetDiscordFrontend: await message.edit(embed=embed) return False - tx_link = f'[**Your result on Skynet Explorer**](https://explorer.{DEFAULT_DOMAIN}/v2/explore/transaction/{tx_hash})' + tx_link = f'[**Your result on Skynet Explorer**](https://{self.explorer_domain}/v2/explore/transaction/{tx_hash})' msg_text += f'**request processed!**\n{tx_link}\n[{timestamp_pretty()}] *trying to download image...*\n ' embed = discord.Embed( From 995ab6c5544a4c02f671c9b99c635dddefe06aa8 Mon Sep 17 00:00:00 2001 From: Konstantine Tsafatinos Date: Fri, 13 Oct 2023 23:30:21 -0400 Subject: [PATCH 3/9] add import dependency to init --- skynet/frontend/discord/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/skynet/frontend/discord/__init__.py b/skynet/frontend/discord/__init__.py index 4560e72..66bde29 100644 --- a/skynet/frontend/discord/__init__.py +++ b/skynet/frontend/discord/__init__.py @@ -18,6 +18,7 @@ from leap.hyperion import HyperionAPI import discord import io +from PIL import Image, UnidentifiedImageError from skynet.db import open_database_connection from skynet.ipfs import get_ipfs_file, AsyncIPFSHTTP From 1234d6c55555c3701a689a5da3d2b1e0761882fe Mon Sep 17 00:00:00 2001 From: zoltan Date: Sat, 14 Oct 2023 03:53:59 +0000 Subject: [PATCH 4/9] change work request function to work with new ipfs logic --- skynet/frontend/discord/__init__.py | 40 ++++++++++++----------------- skynet/frontend/discord/utils.py | 11 +++++--- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/skynet/frontend/discord/__init__.py b/skynet/frontend/discord/__init__.py index 66bde29..74675d7 100644 --- a/skynet/frontend/discord/__init__.py +++ b/skynet/frontend/discord/__init__.py @@ -265,7 +265,8 @@ class SkynetDiscordFrontend: results[link] = png_img except UnidentifiedImageError: - logging.warning(f'couldn\'t get ipfs binary data at {link}!') + logging.warning( + f'couldn\'t get ipfs binary data at {link}!') tasks = [ get_and_set_results(ipfs_link), @@ -281,32 +282,25 @@ class SkynetDiscordFrontend: png_img = results[ipfs_link] if not png_img: - await self.update_status_message( - status_msg, - caption, - reply_markup=build_redo_menu(), - parse_mode='HTML' - ) + logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!') + embed.add_field( + name='Error', value=f'couldn\'t get ipfs hosted image [**here**]({ipfs_link})!') + await message.edit(embed=embed, view=SkynetView(self)) return True # reword this function, may not need caption caption, embed = generate_reply_caption( - user, params, tx_hash, worker, reward) + user, params, tx_hash, worker, reward, self.explorer_domain) - if not resp or resp.status_code != 200: - logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!') - embed.add_field(name='Error', value=f'couldn\'t get ipfs hosted image [**here**]({ipfs_link})!') - await message.edit(embed=embed, view=SkynetView(self)) - else: - logging.info(f'success! sending generated image') - await message.delete() - if file_id: # img2img - embed.set_thumbnail( - url='https://ipfs.skygpu.net/ipfs/' + binary_data + '/image.png') - embed.set_image(url=ipfs_link) - await send(embed=embed, view=SkynetView(self)) - else: # txt2img - embed.set_image(url=ipfs_link) - await send(embed=embed, view=SkynetView(self)) + logging.info(f'success! sending generated image') + await message.delete() + if file_id: # img2img + embed.set_thumbnail( + url='https://ipfs.skygpu.net/ipfs/' + binary_data + '/image.png') + embed.set_image(url=ipfs_link) + await send(embed=embed, view=SkynetView(self)) + else: # txt2img + embed.set_image(url=ipfs_link) + await send(embed=embed, view=SkynetView(self)) return True diff --git a/skynet/frontend/discord/utils.py b/skynet/frontend/discord/utils.py index 6156384..36ac820 100644 --- a/skynet/frontend/discord/utils.py +++ b/skynet/frontend/discord/utils.py @@ -32,7 +32,8 @@ class SKYExceptionHandler(ExceptionHandler): def build_redo_menu(): - btn_redo = InlineKeyboardButton("Redo", callback_data=json.dumps({'method': 'redo'})) + btn_redo = InlineKeyboardButton( + "Redo", callback_data=json.dumps({'method': 'redo'})) inline_keyboard = InlineKeyboardMarkup() inline_keyboard.add(btn_redo) return inline_keyboard @@ -42,7 +43,7 @@ def prepare_metainfo_caption(user, worker: str, reward: str, meta: dict, embed) prompt = meta["prompt"] if len(prompt) > 256: prompt = prompt[:256] - + gen_str = f'generated by {user.name}\n' gen_str += f'performed by {worker}\n' gen_str += f'reward: {reward}\n' @@ -89,7 +90,8 @@ def generate_reply_caption( url=f'https://{explorer_domain}/v2/explore/transaction/{tx_hash}', color=discord.Color.blue()) - meta_info = prepare_metainfo_caption(user, worker, reward, params, explorer_link) + meta_info = prepare_metainfo_caption( + user, worker, reward, params, explorer_link) # why do we have this? final_msg = '\n'.join([ @@ -98,7 +100,7 @@ def generate_reply_caption( f'PARAMETER INFO:\n{meta_info}' ]) - final_msg = '\n'.join([ + final_msg += '\n'.join([ # f'***{explorer_link}***', f'{meta_info}' ]) @@ -112,6 +114,7 @@ async def get_global_config(cleos): return (await cleos.aget_table( 'telos.gpu', 'telos.gpu', 'config'))[0] + async def get_user_nonce(cleos, user: str): return (await cleos.aget_table( 'telos.gpu', 'telos.gpu', 'users', From 9821aac16abe7613f063594529b500b35f1ba24f Mon Sep 17 00:00:00 2001 From: zoltan Date: Sat, 14 Oct 2023 03:58:38 +0000 Subject: [PATCH 5/9] change log info for caption --- skynet/frontend/discord/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skynet/frontend/discord/utils.py b/skynet/frontend/discord/utils.py index 36ac820..e7ae885 100644 --- a/skynet/frontend/discord/utils.py +++ b/skynet/frontend/discord/utils.py @@ -100,10 +100,10 @@ def generate_reply_caption( f'PARAMETER INFO:\n{meta_info}' ]) - final_msg += '\n'.join([ - # f'***{explorer_link}***', - f'{meta_info}' - ]) + # final_msg += '\n'.join([ + # # f'***{explorer_link}***', + # f'{meta_info}' + # ]) logging.info(final_msg) From d3cf3bc6f2d2504aaaed2e74b8e11a61cb28872a Mon Sep 17 00:00:00 2001 From: zoltan Date: Thu, 25 Jan 2024 19:06:04 +0000 Subject: [PATCH 6/9] fix img to img bug --- skynet/frontend/discord/__init__.py | 17 +++++++-- skynet/frontend/discord/bot.py | 2 +- skynet/frontend/discord/handlers.py | 32 ++++++++-------- skynet/frontend/discord/ui.py | 58 ++++++++++++++++++----------- 4 files changed, 67 insertions(+), 42 deletions(-) diff --git a/skynet/frontend/discord/__init__.py b/skynet/frontend/discord/__init__.py index 74675d7..4c5bf31 100644 --- a/skynet/frontend/discord/__init__.py +++ b/skynet/frontend/discord/__init__.py @@ -17,6 +17,7 @@ from leap.hyperion import HyperionAPI # from telebot.types import InputMediaPhoto import discord +import requests import io from PIL import Image, UnidentifiedImageError @@ -295,10 +296,20 @@ class SkynetDiscordFrontend: logging.info(f'success! sending generated image') await message.delete() if file_id: # img2img - embed.set_thumbnail( - url='https://ipfs.skygpu.net/ipfs/' + binary_data + '/image.png') embed.set_image(url=ipfs_link) - await send(embed=embed, view=SkynetView(self)) + orig_url = f'https://{self.ipfs_domain}/ipfs/' + binary_data + res = requests.get(orig_url, stream=True) + if res.status_code == 200: + with io.BytesIO(res.content) as img: + file = discord.File(img, filename='image.png') + embed.set_thumbnail(url='attachment://image.png') + await send(embed=embed, view=SkynetView(self), file=file) + # orig_url = f'https://{self.ipfs_domain}/ipfs/' \ + # + binary_data + '/image.png' + # embed.set_thumbnail( + # url=orig_url) + else: + await send(embed=embed, view=SkynetView(self)) else: # txt2img embed.set_image(url=ipfs_link) await send(embed=embed, view=SkynetView(self)) diff --git a/skynet/frontend/discord/bot.py b/skynet/frontend/discord/bot.py index accc926..3f1b654 100644 --- a/skynet/frontend/discord/bot.py +++ b/skynet/frontend/discord/bot.py @@ -44,7 +44,7 @@ class DiscordBot(commands.Bot): await channel.send('Skynet bot online', view=SkynetView(self.bot)) # intro_msg = await channel.send('Welcome to the Skynet discord bot.\nSkynet is a decentralized compute layer, focused on supporting AI paradigms. Skynet leverages blockchain technology to manage work requests and fills. We are currently featuring image generation and support 11 different models. Get started with the /help command, or just click on some buttons. Here is an example command to generate an image:\n/txt2img a big red tractor in a giant field of corn') intro_msg = await channel.send("Welcome to Skynet's Discord Bot,\n\nSkynet operates as a decentralized compute layer, offering a wide array of support for diverse AI paradigms through the use of blockchain technology. Our present focus is image generation, powered by 11 distinct models.\n\nTo begin exploring, use the '/help' command or directly interact with the provided buttons. Here is an example command to generate an image:\n\n'/txt2img a big red tractor in a giant field of corn'") - await intro_msg.pin() + # await intro_msg.pin() print("\n==============") print("Logged in as") diff --git a/skynet/frontend/discord/handlers.py b/skynet/frontend/discord/handlers.py index 5b68892..27da3cd 100644 --- a/skynet/frontend/discord/handlers.py +++ b/skynet/frontend/discord/handlers.py @@ -42,6 +42,7 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): await ctx.reply(content=reply_txt, view=SkynetView(frontend)) bot.remove_command('help') + @bot.command(name='help', help='Responds with a help') async def help(ctx): splt_msg = ctx.message.content.split(' ') @@ -62,7 +63,7 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): clean_cool_word = '\n'.join(CLEAN_COOL_WORDS) await ctx.send(content=f'```{clean_cool_word}```', view=SkynetView(frontend)) - @bot.command(name='stats', help='See user statistics' ) + @bot.command(name='stats', help='See user statistics') async def user_stats(ctx): user = ctx.author @@ -96,9 +97,8 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): prompt = ' '.join(ctx.message.content.split(' ')[1:]) if len(prompt) == 0: - await status_msg.edit(content= - 'Empty text prompt ignored.' - ) + await status_msg.edit(content='Empty text prompt ignored.' + ) await db_call('update_user_request', status_msg.id, 'Empty text prompt ignored.') return @@ -209,14 +209,23 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): file_id = str(file.id) # file bytes image_raw = await file.read() + + user_config = {**user_row} + del user_config['id'] with Image.open(io.BytesIO(image_raw)) as image: w, h = image.size - if w > 512 or h > 512: + if w > user_config['width'] or h > user_config['height']: logging.warning(f'user sent img of size {image.size}') - image.thumbnail((512, 512)) + image.thumbnail( + (user_config['width'], user_config['height'])) logging.warning(f'resized it to {image.size}') + # if w > 512 or h > 512: + # logging.warning(f'user sent img of size {image.size}') + # image.thumbnail((512, 512)) + # logging.warning(f'resized it to {image.size}') + # image.save(f'ipfs-docker-staging/image.png', format='PNG') image_loc = 'ipfs-staging/image.png' image.save(image_loc, format='PNG') @@ -228,9 +237,6 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): logging.info(f'mid: {ctx.message.id}') - user_config = {**user_row} - del user_config['id'] - params = { 'prompt': prompt, **user_config @@ -240,8 +246,8 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): 'update_user_stats', user.id, 'img2img', - last_file=file_id, last_prompt=prompt, + last_file=file_id, last_binary=ipfs_hash ) @@ -254,8 +260,6 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): if success: await db_call('increment_generated', user.id) - - # TODO: DELETE BELOW # user = 'testworker3' # status_msg = 'status' @@ -314,7 +318,6 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): # await bot.reply_to( # message, f'Total requests on skynet queue: {len(queue)}') - # @bot.message_handler(commands=['config']) # async def set_config(message): # user = message.from_user.id @@ -361,7 +364,6 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): # # await bot.send_message(GROUP_ID, message.text[4:]) - # generic txt2img handler # async def _generic_txt2img(message_or_query): @@ -562,7 +564,6 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): # binary_data=binary # ) - # "proxy" handlers just request routers # @bot.message_handler(commands=['txt2img']) @@ -594,7 +595,6 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): # case 'redo': # await _redo(call) - # catch all handler for things we dont support # @bot.message_handler(func=lambda message: True) diff --git a/skynet/frontend/discord/ui.py b/skynet/frontend/discord/ui.py index 1e6fd97..2e6351a 100644 --- a/skynet/frontend/discord/ui.py +++ b/skynet/frontend/discord/ui.py @@ -11,14 +11,22 @@ class SkynetView(discord.ui.View): def __init__(self, bot): self.bot = bot super().__init__(timeout=None) - self.add_item(RedoButton('redo', discord.ButtonStyle.primary, self.bot)) - self.add_item(Txt2ImgButton('txt2img', discord.ButtonStyle.primary, self.bot)) - self.add_item(Img2ImgButton('img2img', discord.ButtonStyle.primary, self.bot)) - self.add_item(StatsButton('stats', discord.ButtonStyle.secondary, self.bot)) - self.add_item(DonateButton('donate', discord.ButtonStyle.secondary, self.bot)) - self.add_item(ConfigButton('config', discord.ButtonStyle.secondary, self.bot)) - self.add_item(HelpButton('help', discord.ButtonStyle.secondary, self.bot)) - self.add_item(CoolButton('cool', discord.ButtonStyle.secondary, self.bot)) + self.add_item(RedoButton( + 'redo', discord.ButtonStyle.primary, self.bot)) + self.add_item(Txt2ImgButton( + 'txt2img', discord.ButtonStyle.primary, self.bot)) + self.add_item(Img2ImgButton( + 'img2img', discord.ButtonStyle.primary, self.bot)) + self.add_item(StatsButton( + 'stats', discord.ButtonStyle.secondary, self.bot)) + self.add_item(DonateButton( + 'donate', discord.ButtonStyle.secondary, self.bot)) + self.add_item(ConfigButton( + 'config', discord.ButtonStyle.secondary, self.bot)) + self.add_item(HelpButton( + 'help', discord.ButtonStyle.secondary, self.bot)) + self.add_item(CoolButton( + 'cool', discord.ButtonStyle.secondary, self.bot)) class Txt2ImgButton(discord.ui.Button): @@ -44,9 +52,8 @@ class Txt2ImgButton(discord.ui.Button): prompt = msg.content if len(prompt) == 0: - await status_msg.edit(content= - 'Empty text prompt ignored.' - ) + await status_msg.edit(content='Empty text prompt ignored.' + ) await db_call('update_user_request', status_msg.id, 'Empty text prompt ignored.') return @@ -111,26 +118,35 @@ class Img2ImgButton(discord.ui.Button): file_id = str(file.id) # file bytes image_raw = await file.read() + + user_config = {**user_row} + del user_config['id'] + with Image.open(io.BytesIO(image_raw)) as image: w, h = image.size - if w > 512 or h > 512: + if w > user_config['width'] or h > user_config['height']: logging.warning(f'user sent img of size {image.size}') - image.thumbnail((512, 512)) + image.thumbnail( + (user_config['width'], user_config['height'])) logging.warning(f'resized it to {image.size}') - image.save(f'ipfs-docker-staging/image.png', format='PNG') + # if w > 512 or h > 512: + # logging.warning(f'user sent img of size {image.size}') + # image.thumbnail((512, 512)) + # logging.warning(f'resized it to {image.size}') + # image.save(f'ipfs-docker-staging/image.png', format='PNG') + image_loc = 'ipfs-staging/image.png' + image.save(image_loc, format='PNG') - ipfs_hash = ipfs_node.add('image.png') - ipfs_node.pin(ipfs_hash) + ipfs_info = await ipfs_node.add(image_loc) + ipfs_hash = ipfs_info['Hash'] + await ipfs_node.pin(ipfs_hash) logging.info(f'published input image {ipfs_hash} on ipfs') logging.info(f'mid: {msg.id}') - user_config = {**user_row} - del user_config['id'] - params = { 'prompt': prompt, **user_config @@ -140,8 +156,8 @@ class Img2ImgButton(discord.ui.Button): 'update_user_stats', user.id, 'img2img', - last_file=file_id, last_prompt=prompt, + last_file=file_id, last_binary=ipfs_hash ) @@ -307,5 +323,3 @@ async def grab(prompt, interaction): await interaction.response.send_message(prompt, ephemeral=True) message = await interaction.client.wait_for('message', check=vet) return message - - From 7f62bf00444d2714a91c01ba14f6d795df879d9c Mon Sep 17 00:00:00 2001 From: zoltan Date: Wed, 19 Jun 2024 22:04:26 +0000 Subject: [PATCH 7/9] update discord link --- skynet/frontend/discord/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skynet/frontend/discord/utils.py b/skynet/frontend/discord/utils.py index e7ae885..ac73646 100644 --- a/skynet/frontend/discord/utils.py +++ b/skynet/frontend/discord/utils.py @@ -70,7 +70,7 @@ def prepare_metainfo_caption(user, worker: str, reward: str, meta: dict, embed) embed.add_field(name='Parameters', value=f'```{meta_str}```', inline=False) foot_str = f'Made with Skynet v{VERSION}\n' - foot_str += f'JOIN THE SWARM: https://discord.gg/JYM4YPMgK' + foot_str += f'JOIN THE SWARM: https://discord.gg/PAabjJtZAF' embed.set_footer(text=foot_str) From 3eab407c00598b5d027f52866addc31ec7e69bb9 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Tue, 26 Nov 2024 21:40:13 -0300 Subject: [PATCH 8/9] Switch to gpu.scd in all relevant segments --- skynet/cli.py | 20 ++++++++++---------- skynet/dgpu/network.py | 18 +++++++++--------- skynet/frontend/discord/__init__.py | 4 ++-- skynet/frontend/discord/handlers.py | 2 +- skynet/frontend/discord/utils.py | 4 ++-- skynet/frontend/telegram/__init__.py | 4 ++-- skynet/frontend/telegram/handlers.py | 2 +- skynet/frontend/telegram/utils.py | 4 ++-- skynet/ipfs/pinner.py | 8 ++++---- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/skynet/cli.py b/skynet/cli.py index 9dec928..859e2b6 100755 --- a/skynet/cli.py +++ b/skynet/cli.py @@ -141,7 +141,7 @@ def enqueue( }) res = await cleos.a_push_action( - 'telos.gpu', + 'gpu.scd', 'enqueue', { 'user': Name(account), @@ -176,7 +176,7 @@ def clean( trio.run( partial( cleos.a_push_action, - 'telos.gpu', + 'gpu.scd', 'clean', {}, account, key, permission=permission @@ -191,9 +191,9 @@ def queue(): resp = requests.post( f'{node_url}/v1/chain/get_table_rows', json={ - 'code': 'telos.gpu', + 'code': 'gpu.scd', 'table': 'queue', - 'scope': 'telos.gpu', + 'scope': 'gpu.scd', 'json': True } ) @@ -208,7 +208,7 @@ def status(request_id: int): resp = requests.post( f'{node_url}/v1/chain/get_table_rows', json={ - 'code': 'telos.gpu', + 'code': 'gpu.scd', 'table': 'status', 'scope': request_id, 'json': True @@ -232,7 +232,7 @@ def dequeue(request_id: int): res = trio.run( partial( cleos.a_push_action, - 'telos.gpu', + 'gpu.scd', 'dequeue', { 'user': Name(account), @@ -267,7 +267,7 @@ def config( res = trio.run( partial( cleos.a_push_action, - 'telos.gpu', + 'gpu.scd', 'config', { 'token_contract': token_contract, @@ -296,13 +296,13 @@ def deposit(quantity: str): res = trio.run( partial( cleos.a_push_action, - 'telos.gpu', + 'gpu.scd', 'transfer', { 'sender': Name(account), - 'recipient': Name('telos.gpu'), + 'recipient': Name('gpu.scd'), 'amount': asset_from_str(quantity), - 'memo': f'{account} transferred {quantity} to telos.gpu' + 'memo': f'{account} transferred {quantity} to gpu.scd' }, account, key, permission=permission ) diff --git a/skynet/dgpu/network.py b/skynet/dgpu/network.py index 276d187..dfe4d67 100644 --- a/skynet/dgpu/network.py +++ b/skynet/dgpu/network.py @@ -72,7 +72,7 @@ class SkynetGPUConnector: return await failable( partial( self.cleos.aget_table, - 'telos.gpu', 'telos.gpu', 'queue', + 'gpu.scd', 'gpu.scd', 'queue', index_position=2, key_type='i64', lower_bound=int(time.time()) - 3600 @@ -83,14 +83,14 @@ class SkynetGPUConnector: return await failable( partial( self.cleos.aget_table, - 'telos.gpu', request_id, 'status'), ret_fail=[]) + 'gpu.scd', request_id, 'status'), ret_fail=[]) async def get_global_config(self): logging.info('get_global_config') rows = await failable( partial( self.cleos.aget_table, - 'telos.gpu', 'telos.gpu', 'config')) + 'gpu.scd', 'gpu.scd', 'config')) if rows: return rows[0] @@ -102,7 +102,7 @@ class SkynetGPUConnector: rows = await failable( partial( self.cleos.aget_table, - 'telos.gpu', 'telos.gpu', 'users', + 'gpu.scd', 'gpu.scd', 'users', index_position=1, key_type='name', lower_bound=self.account, @@ -149,7 +149,7 @@ class SkynetGPUConnector: return await failable( partial( self.cleos.a_push_action, - 'telos.gpu', + 'gpu.scd', 'workbegin', { 'worker': self.account, @@ -166,7 +166,7 @@ class SkynetGPUConnector: return await failable( partial( self.cleos.a_push_action, - 'telos.gpu', + 'gpu.scd', 'workcancel', { 'worker': self.account, @@ -189,7 +189,7 @@ class SkynetGPUConnector: await failable( partial( self.cleos.a_push_action, - 'telos.gpu', + 'gpu.scd', 'withdraw', { 'user': self.account, @@ -205,7 +205,7 @@ class SkynetGPUConnector: return await failable( partial( self.cleos.aget_table, - 'telos.gpu', 'telos.gpu', 'results', + 'gpu.scd', 'gpu.scd', 'results', index_position=4, key_type='name', lower_bound=self.account, @@ -224,7 +224,7 @@ class SkynetGPUConnector: return await failable( partial( self.cleos.a_push_action, - 'telos.gpu', + 'gpu.scd', 'submit', { 'worker': self.account, diff --git a/skynet/frontend/discord/__init__.py b/skynet/frontend/discord/__init__.py index 4c5bf31..a6bc0f3 100644 --- a/skynet/frontend/discord/__init__.py +++ b/skynet/frontend/discord/__init__.py @@ -155,7 +155,7 @@ class SkynetDiscordFrontend: reward = '20.0000 GPU' res = await self.cleos.a_push_action( - 'telos.gpu', + 'gpu.scd', 'enqueue', { 'user': Name(self.account), @@ -202,7 +202,7 @@ class SkynetDiscordFrontend: try: submits = await self.hyperion.aget_actions( account=self.account, - filter='telos.gpu:submit', + filter='gpu.scd:submit', sort='desc', after=request_time ) diff --git a/skynet/frontend/discord/handlers.py b/skynet/frontend/discord/handlers.py index 27da3cd..95bfc52 100644 --- a/skynet/frontend/discord/handlers.py +++ b/skynet/frontend/discord/handlers.py @@ -309,7 +309,7 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'): # async def queue(message): # an_hour_ago = datetime.now() - timedelta(hours=1) # queue = await cleos.aget_table( - # 'telos.gpu', 'telos.gpu', 'queue', + # 'gpu.scd', 'gpu.scd', 'queue', # index_position=2, # key_type='i64', # sort='desc', diff --git a/skynet/frontend/discord/utils.py b/skynet/frontend/discord/utils.py index ac73646..8f6d484 100644 --- a/skynet/frontend/discord/utils.py +++ b/skynet/frontend/discord/utils.py @@ -112,12 +112,12 @@ def generate_reply_caption( async def get_global_config(cleos): return (await cleos.aget_table( - 'telos.gpu', 'telos.gpu', 'config'))[0] + 'gpu.scd', 'gpu.scd', 'config'))[0] async def get_user_nonce(cleos, user: str): return (await cleos.aget_table( - 'telos.gpu', 'telos.gpu', 'users', + 'gpu.scd', 'gpu.scd', 'users', index_position=1, key_type='name', lower_bound=user, diff --git a/skynet/frontend/telegram/__init__.py b/skynet/frontend/telegram/__init__.py index 14f8c6b..d4fd549 100644 --- a/skynet/frontend/telegram/__init__.py +++ b/skynet/frontend/telegram/__init__.py @@ -143,7 +143,7 @@ class SkynetTelegramFrontend: reward = '20.0000 GPU' res = await self.cleos.a_push_action( - 'telos.gpu', + 'gpu.scd', 'enqueue', { 'user': Name(self.account), @@ -193,7 +193,7 @@ class SkynetTelegramFrontend: try: submits = await self.hyperion.aget_actions( account=self.account, - filter='telos.gpu:submit', + filter='gpu.scd:submit', sort='desc', after=request_time ) diff --git a/skynet/frontend/telegram/handlers.py b/skynet/frontend/telegram/handlers.py index ef0e31f..63abe60 100644 --- a/skynet/frontend/telegram/handlers.py +++ b/skynet/frontend/telegram/handlers.py @@ -47,7 +47,7 @@ def create_handler_context(frontend: 'SkynetTelegramFrontend'): async def queue(message): an_hour_ago = datetime.now() - timedelta(hours=1) queue = await cleos.aget_table( - 'telos.gpu', 'telos.gpu', 'queue', + 'gpu.scd', 'gpu.scd', 'queue', index_position=2, key_type='i64', sort='desc', diff --git a/skynet/frontend/telegram/utils.py b/skynet/frontend/telegram/utils.py index 01a2a9b..f438623 100644 --- a/skynet/frontend/telegram/utils.py +++ b/skynet/frontend/telegram/utils.py @@ -95,11 +95,11 @@ def generate_reply_caption( async def get_global_config(cleos): return (await cleos.aget_table( - 'telos.gpu', 'telos.gpu', 'config'))[0] + 'gpu.scd', 'gpu.scd', 'config'))[0] async def get_user_nonce(cleos, user: str): return (await cleos.aget_table( - 'telos.gpu', 'telos.gpu', 'users', + 'gpu.scd', 'gpu.scd', 'users', index_position=1, key_type='name', lower_bound=user, diff --git a/skynet/ipfs/pinner.py b/skynet/ipfs/pinner.py index f3a51f9..1db06fe 100644 --- a/skynet/ipfs/pinner.py +++ b/skynet/ipfs/pinner.py @@ -44,8 +44,8 @@ class SkynetPinner: async def capture_enqueues(self, after: datetime): enqueues = await self.hyperion.aget_actions( - account='telos.gpu', - filter='telos.gpu:enqueue', + account='gpu.scd', + filter='gpu.scd:enqueue', sort='desc', after=after.isoformat(), limit=1000 @@ -63,8 +63,8 @@ class SkynetPinner: async def capture_submits(self, after: datetime): submits = await self.hyperion.aget_actions( - account='telos.gpu', - filter='telos.gpu:submit', + account='gpu.scd', + filter='gpu.scd:submit', sort='desc', after=after.isoformat(), limit=1000 From 687ff6f118647a4a4e5b9acf1a84fd740c177c11 Mon Sep 17 00:00:00 2001 From: zoltan Date: Wed, 27 Nov 2024 16:19:08 +0000 Subject: [PATCH 9/9] update ipfs_gateway_url reqs for discord config to be optional --- skynet/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/skynet/cli.py b/skynet/cli.py index 859e2b6..18ec273 100755 --- a/skynet/cli.py +++ b/skynet/cli.py @@ -453,7 +453,12 @@ def discord( node_url = load_key(config, 'skynet.discord.node_url') hyperion_url = load_key(config, 'skynet.discord.hyperion_url') - ipfs_gateway_url = load_key(config, 'skynet.discord.ipfs_gateway_url') + try: + ipfs_gateway_url = load_key(config, 'skynet.discord.ipfs_gateway_url') + + except ConfigParsingError: + ipfs_gateway_url = None + ipfs_url = load_key(config, 'skynet.discord.ipfs_url') try: