From e72640c522b20bf2bcb4dcd3d5c53d5a3d0f3451 Mon Sep 17 00:00:00 2001 From: Michal Zukowski Date: Thu, 11 Jul 2024 13:33:23 +0200 Subject: [PATCH] Hardcode default weights version --- .../validator/metagraph_client.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/validator/app/src/compute_horde_validator/validator/metagraph_client.py b/validator/app/src/compute_horde_validator/validator/metagraph_client.py index 2189e8077..478032571 100644 --- a/validator/app/src/compute_horde_validator/validator/metagraph_client.py +++ b/validator/app/src/compute_horde_validator/validator/metagraph_client.py @@ -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): @@ -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