Skip to content

Commit

Permalink
fam
Browse files Browse the repository at this point in the history
  • Loading branch information
latentvector committed Aug 31, 2024
1 parent 55f664a commit 04d357b
Show file tree
Hide file tree
Showing 33 changed files with 1,080 additions and 1,170 deletions.
10 changes: 10 additions & 0 deletions commune/executor/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ def tasks(cls, task = None, mode='pm2',**kwargs) -> List[str]:
return tasks


@classmethod
def asubmit(cls, fn:str, *args, **kwargs):

async def _asubmit():
kwargs.update(kwargs.pop('kwargs',{}))
return fn(*args, **kwargs)
return _asubmit()



thread_map = {}

@classmethod
Expand Down
17 changes: 2 additions & 15 deletions commune/key/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,19 +598,6 @@ def from_json(cls, obj: Union[str, dict], password: str = None) -> dict:
if 'ss58_address' in obj:
obj['_ss58_address'] = obj.pop('ss58_address')
return cls(**obj)

@classmethod
def sand(cls):

for k in cls.new_key(suri=2):

password = 'fam'
enc = cls.encrypt(k, password=password)
dec = cls.decrypt(enc, password='bro ')





@classmethod
def generate_mnemonic(cls, words: int = 24, language_code: str = MnemonicLanguageCode.ENGLISH) -> str:
Expand Down Expand Up @@ -1533,8 +1520,8 @@ def resolve_key_address(cls, key):




Keypair.run(__name__)
if __name__ == "__main__":
Keypair.run()



Expand Down
67 changes: 0 additions & 67 deletions commune/module/_api.py

This file was deleted.

2 changes: 1 addition & 1 deletion commune/module/_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def resolve_console(cls, console = None, **kwargs):
import logging
from rich.logging import RichHandler
from rich.console import Console
logging.basicConfig(level=logging.DEBUG, handlers=[RichHandler()])
logging.basicConfig( handlers=[RichHandler()])
# print the line number
console = Console()
cls.console = console
Expand Down
54 changes: 54 additions & 0 deletions commune/module/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,3 +1046,57 @@ def hash_modes(cls):

str2hash = hash


def set_api_key(self, api_key:str, cache:bool = True):
api_key = os.getenv(str(api_key), None)
if api_key == None:
api_key = self.get_api_key()
self.api_key = api_key
if cache:
self.add_api_key(api_key)
assert isinstance(api_key, str)


def add_api_key(self, api_key:str, path=None):
assert isinstance(api_key, str)
path = self.resolve_path(path or 'api_keys')
api_keys = self.get(path, [])
api_keys.append(api_key)
api_keys = list(set(api_keys))
self.put(path, api_keys)
return {'api_keys': api_keys}

def set_api_keys(self, api_keys:str):
api_keys = list(set(api_keys))
self.put('api_keys', api_keys)
return {'api_keys': api_keys}

def rm_api_key(self, api_key:str):
assert isinstance(api_key, str)
api_keys = self.get(self.resolve_path('api_keys'), [])
for i in range(len(api_keys)):
if api_key == api_keys[i]:
api_keys.pop(i)
break
path = self.resolve_path('api_keys')
self.put(path, api_keys)
return {'api_keys': api_keys}

def get_api_key(self, module=None):
if module != None:
self = self.module(module)
api_keys = self.api_keys()
if len(api_keys) == 0:
raise
else:
return self.choice(api_keys)

def api_keys(self):
return self.get(self.resolve_path('api_keys'), [])


def rm_api_keys(self):
self.put(self.resolve_path('api_keys'), [])
return {'api_keys': []}


166 changes: 0 additions & 166 deletions commune/module/_routes.py

This file was deleted.

Loading

0 comments on commit 04d357b

Please sign in to comment.