From 1d540390030bf6901dde7a767694513965708635 Mon Sep 17 00:00:00 2001 From: latentvector Date: Mon, 16 Sep 2024 22:55:58 -0400 Subject: [PATCH] removed redundant fns in utils --- commune/client.py | 19 +++---------------- commune/utils/os.py | 25 ------------------------- 2 files changed, 3 insertions(+), 41 deletions(-) diff --git a/commune/client.py b/commune/client.py index e3cddfcb..815c9348 100644 --- a/commune/client.py +++ b/commune/client.py @@ -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() @@ -93,7 +95,6 @@ def call(cls, params=params, timeout=timeout, **extra_kwargs) - return response @classmethod @@ -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) @@ -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') @@ -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) diff --git a/commune/utils/os.py b/commune/utils/os.py index eb7daa52..00e4b3dc 100644 --- a/commune/utils/os.py +++ b/commune/utils/os.py @@ -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. """ @@ -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}