Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ import time
|
|
11 |
from dotenv import load_dotenv
|
12 |
from huggingface_hub import HfApi
|
13 |
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
14 |
|
15 |
load_dotenv()
|
16 |
|
@@ -81,7 +82,8 @@ def get_tao_price() -> float:
|
|
81 |
|
82 |
def get_validator_weights(metagraph: bt.metagraph) -> typing.Dict[int, typing.Tuple[float, int, typing.Dict[int, float]]]:
|
83 |
ret = {}
|
84 |
-
|
|
|
85 |
vtrust = metagraph.validator_trust[uid].item()
|
86 |
if vtrust > 0:
|
87 |
ret[uid] = (vtrust, metagraph.S[uid].item(), {})
|
@@ -95,7 +97,8 @@ def get_validator_weights(metagraph: bt.metagraph) -> typing.Dict[int, typing.Tu
|
|
95 |
|
96 |
def get_subnet_data(subtensor: bt.subtensor, metagraph: bt.metagraph) -> typing.List[ModelData]:
|
97 |
result = []
|
98 |
-
|
|
|
99 |
hotkey = metagraph.hotkeys[uid]
|
100 |
metadata = get_metadata(subtensor, metagraph.netuid, hotkey)
|
101 |
if not metadata:
|
@@ -117,21 +120,6 @@ def get_subnet_data(subtensor: bt.subtensor, metagraph: bt.metagraph) -> typing.
|
|
117 |
result.append(model_data)
|
118 |
return result
|
119 |
|
120 |
-
def floatable(x) -> bool:
|
121 |
-
return (isinstance(x, float) and not math.isnan(x) and not math.isinf(x)) or isinstance(x, int)
|
122 |
-
|
123 |
-
def get_float_score(key: str, history) -> typing.Tuple[typing.Optional[float], bool]:
|
124 |
-
if key in history:
|
125 |
-
data = list(history[key])
|
126 |
-
if len(data) > 0:
|
127 |
-
if floatable(data[-1]):
|
128 |
-
return float(data[-1]), True
|
129 |
-
else:
|
130 |
-
data = [float(x) for x in data if floatable(x)]
|
131 |
-
if len(data) > 0:
|
132 |
-
return float(data[-1]), False
|
133 |
-
return None, False
|
134 |
-
|
135 |
def get_sample(uid, history) -> typing.Optional[typing.Tuple[str, str]]:
|
136 |
prompt_key = f"sample_prompt_data.{uid}"
|
137 |
response_key = f"sample_response_data.{uid}"
|
|
|
11 |
from dotenv import load_dotenv
|
12 |
from huggingface_hub import HfApi
|
13 |
from apscheduler.schedulers.background import BackgroundScheduler
|
14 |
+
from tqdm import tqdm
|
15 |
|
16 |
load_dotenv()
|
17 |
|
|
|
82 |
|
83 |
def get_validator_weights(metagraph: bt.metagraph) -> typing.Dict[int, typing.Tuple[float, int, typing.Dict[int, float]]]:
|
84 |
ret = {}
|
85 |
+
uid_list = metagraph.uids.tolist()
|
86 |
+
for uid in tqdm(uid_list, desc="get_validator_weights"):
|
87 |
vtrust = metagraph.validator_trust[uid].item()
|
88 |
if vtrust > 0:
|
89 |
ret[uid] = (vtrust, metagraph.S[uid].item(), {})
|
|
|
97 |
|
98 |
def get_subnet_data(subtensor: bt.subtensor, metagraph: bt.metagraph) -> typing.List[ModelData]:
|
99 |
result = []
|
100 |
+
uid_list = metagraph.uids.tolist()
|
101 |
+
for uid in tqdm(uid_list, desc="get_subnet_data"):
|
102 |
hotkey = metagraph.hotkeys[uid]
|
103 |
metadata = get_metadata(subtensor, metagraph.netuid, hotkey)
|
104 |
if not metadata:
|
|
|
120 |
result.append(model_data)
|
121 |
return result
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
def get_sample(uid, history) -> typing.Optional[typing.Tuple[str, str]]:
|
124 |
prompt_key = f"sample_prompt_data.{uid}"
|
125 |
response_key = f"sample_response_data.{uid}"
|