Skip to content

Commit

Permalink
removed redundant fns in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
latentvector committed Sep 17, 2024
1 parent 4f00c4d commit 1d54039
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 41 deletions.
19 changes: 3 additions & 16 deletions commune/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ def __init__(
):
self.serializer = c.module('serializer')()
self.network = network
self.loop = c.get_event_loop()
self.key = c.get_key(key, create_if_not_exists=True)
self.module = module
self.fn2max_age = fn2max_age
self.stream_prefix = stream_prefix
self.address = self.resolve_module_address(module, network=network)

self.loop = c.get_event_loop()

self.virtual = virtual
self.session = requests.Session()

Expand Down Expand Up @@ -93,7 +95,6 @@ def call(cls,
params=params,
timeout=timeout,
**extra_kwargs)

return response

@classmethod
Expand All @@ -106,14 +107,6 @@ def connect(cls,
if virtual:
return ClientVirtual(client=client)
return client

def test(self, module='module::test_client'):
c.serve(module)
c.sleep(1)
info = c.call(module+'/info')
key = c.get_key(module)
assert info['key'] == key.ss58_address
return {'info': info, 'key': str(key)}

def __str__ ( self ):
return "Client(address={}, virtual={})".format(self.address, self.virtual)
Expand Down Expand Up @@ -258,11 +251,6 @@ def stream(self, response):
print(f'Error in stream: {e}')
yield None

def tokenize(self, data):
# Customize tokenization logic here. For example, split by spaces.
# Returning a list of tokens and the last incomplete token (if any) as a string.
tokens = data.split()
return tokens
def process_stream_line(self, line , stream_prefix=None):
stream_prefix = stream_prefix or self.stream_prefix
event_data = line.decode('utf-8')
Expand Down Expand Up @@ -304,7 +292,6 @@ def get_curl(self,
curl_command = f'curl -X POST {headers_str} -d "{data_str}" "{url}"'

return curl_command


def run_curl(self, *args, **kwargs):
curl_command = self.get_curl(*args, **kwargs)
Expand Down
25 changes: 0 additions & 25 deletions commune/utils/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ def path_exists(path:str):
return os.path.exists(path)


def seed_everything(seed: int) -> None:
import numpy as np
import torch
import random
"seeding function for reproducibility"
random.seed(seed)
os.environ["PYTHONHASHSEED"] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True




def check_pid(pid):
""" Check For the existence of a unix pid. """
Expand Down Expand Up @@ -635,17 +621,6 @@ def kill_process(process):
# sys.exit(0)


def seed_everything(seed: int) -> None:
import torch, random
import numpy as np
"seeding function for reproducibility"
random.seed(seed)
os.environ["PYTHONHASHSEED"] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True

def set_env(key:str, value:str):
os.environ[key] = value
return {'success': True, 'key': key, 'value': value}
Expand Down

0 comments on commit 1d54039

Please sign in to comment.