Skip to content

Commit

Permalink
Merge pull request #168 from backend-developers-ltd/hardcode-default-…
Browse files Browse the repository at this point in the history
…weights-version

Hardcode default weights version
  • Loading branch information
mzukowski-reef authored Jul 11, 2024
2 parents dd2e1ae + e72640c commit 9d118f9
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

logger = logging.getLogger(__name__)

# only when reading hyperparams fails - should be updated after hyperparam is updated
DEFAULT_WEIGHTS_VERSION = 1


class WeightVersionHolder:
def __init__(self):
Expand All @@ -26,12 +29,20 @@ def get(self):
with self._lock:
if time.time() - self._time_set > 300:
subtensor = bittensor.subtensor(network=settings.BITTENSOR_NETWORK)
hyperparameters = subtensor.get_subnet_hyperparameters(
netuid=settings.BITTENSOR_NETUID
)
if hyperparameters is None:
raise RuntimeError("Network hyperparameters are None")
self.value = hyperparameters.weights_version
try:
hyperparameters = subtensor.get_subnet_hyperparameters(
netuid=settings.BITTENSOR_NETUID
)
if hyperparameters is None:
raise RuntimeError("Network hyperparameters are None")
self.value = hyperparameters.weights_version
except Exception as exc:
# we actually want to know about the problem
logger.error(
f"Error when getting weights version - will use default '{DEFAULT_WEIGHTS_VERSION}': {exc}",
exc_info=True,
)
self.value = DEFAULT_WEIGHTS_VERSION
self._time_set = time.time()
return self.value

Expand Down

0 comments on commit 9d118f9

Please sign in to comment.