diff --git a/template/base/miner.py b/template/base/miner.py index 1788e24b..4bbcc394 100644 --- a/template/base/miner.py +++ b/template/base/miner.py @@ -111,20 +111,10 @@ def run(self): # This loop maintains the miner's operations until intentionally stopped. try: while not self.should_exit: - while ( - self.block - self.metagraph.last_update[self.uid] - < self.config.neuron.epoch_length - ): - # Wait before checking again. - time.sleep(1) - - # Check if we should exit. - if self.should_exit: - break - - # Sync metagraph and potentially set weights. - self.sync() - self.step += 1 + bt.logging.debug(f"block: {self.block}") + if self.block % self.config.neuron.epoch_length == 0: + self.sync() + time.sleep(12) # If someone intentionally stops the miner, it'll safely terminate operations. except KeyboardInterrupt: diff --git a/template/base/utils/weight_utils.py b/template/base/utils/weight_utils.py index 26133efd..f31eac4e 100644 --- a/template/base/utils/weight_utils.py +++ b/template/base/utils/weight_utils.py @@ -159,6 +159,11 @@ def process_weights_for_netuid( non_zero_weight_idx = np.argwhere(weights > 0).squeeze() non_zero_weight_uids = uids[non_zero_weight_idx] non_zero_weights = weights[non_zero_weight_idx] + + # Ensure non_zero_weights is a NumPy array + if not isinstance(non_zero_weights, np.ndarray): + non_zero_weights = np.array(non_zero_weights) + if non_zero_weights.size == 0 or metagraph.n < min_allowed_weights: bittensor.logging.warning("No non-zero weights returning all ones.") final_weights = np.ones(metagraph.n) / metagraph.n @@ -167,7 +172,7 @@ def process_weights_for_netuid( elif non_zero_weights.size < min_allowed_weights: bittensor.logging.warning( - "No non-zero weights less then min allowed weight, returning all ones." + "No non-zero weights less than min allowed weight, returning all ones." ) weights = ( np.ones(metagraph.n) * 1e-5