Spaces:
Sleeping
Sleeping
Sarkosos
commited on
Commit
·
5144f34
1
Parent(s):
0872630
Sped up get_data_transferred 7x
Browse files
utils.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
|
|
| 1 |
import os
|
| 2 |
-
import tqdm
|
| 3 |
import time
|
| 4 |
-
import wandb
|
| 5 |
-
import streamlit as st
|
| 6 |
-
import pandas as pd
|
| 7 |
-
import bittensor as bt
|
| 8 |
-
import ast
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# TODO: Store the runs dataframe (as in sn1 dashboard) and top up with the ones created since the last snapshot
|
| 12 |
# TODO: Store relevant wandb data in a database for faster access
|
|
@@ -142,11 +143,18 @@ def get_total_md_input_sizes(run):
|
|
| 142 |
return convert_unit(size_bytes, from_unit='B', to_unit=BASE_UNITS)
|
| 143 |
|
| 144 |
|
|
|
|
|
|
|
| 145 |
def get_data_transferred(df, unit='GB'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
-
validator_sent = df.md_inputs_sizes.dropna().apply(lambda x: ast.literal_eval(x)).explode().sum()
|
| 148 |
-
miner_sent = df.response_returned_files_sizes.dropna().apply(lambda x: ast.literal_eval(x)).explode().explode().sum()
|
| 149 |
-
|
| 150 |
return {
|
| 151 |
'validator_sent': convert_unit(validator_sent, from_unit='B', to_unit=BASE_UNITS),
|
| 152 |
'miner_sent': convert_unit(miner_sent, from_unit='B', to_unit=BASE_UNITS),
|
|
|
|
| 1 |
+
import json
|
| 2 |
import os
|
|
|
|
| 3 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
import bittensor as bt
|
| 6 |
+
import numpy as np
|
| 7 |
+
import pandas as pd
|
| 8 |
+
import streamlit as st
|
| 9 |
+
import tqdm
|
| 10 |
+
import wandb
|
| 11 |
|
| 12 |
# TODO: Store the runs dataframe (as in sn1 dashboard) and top up with the ones created since the last snapshot
|
| 13 |
# TODO: Store relevant wandb data in a database for faster access
|
|
|
|
| 143 |
return convert_unit(size_bytes, from_unit='B', to_unit=BASE_UNITS)
|
| 144 |
|
| 145 |
|
| 146 |
+
|
| 147 |
+
|
| 148 |
def get_data_transferred(df, unit='GB'):
|
| 149 |
+
def safe_json_loads(x):
|
| 150 |
+
try:
|
| 151 |
+
return json.loads(x)
|
| 152 |
+
except ValueError:
|
| 153 |
+
return []
|
| 154 |
+
|
| 155 |
+
validator_sent = np.nansum(df.md_inputs_sizes.dropna().apply(safe_json_loads).explode().replace([np.inf, -np.inf], np.nan).values)
|
| 156 |
+
miner_sent = np.nansum(df.response_returned_files_sizes.dropna().apply(safe_json_loads).explode().explode().replace([np.inf, -np.inf], np.nan).values)
|
| 157 |
|
|
|
|
|
|
|
|
|
|
| 158 |
return {
|
| 159 |
'validator_sent': convert_unit(validator_sent, from_unit='B', to_unit=BASE_UNITS),
|
| 160 |
'miner_sent': convert_unit(miner_sent, from_unit='B', to_unit=BASE_UNITS),
|