From 6ecdd830b5508ca61b29eadeaa7bdb944af5708f Mon Sep 17 00:00:00 2001 From: hscott Date: Thu, 5 Dec 2024 12:20:27 -0500 Subject: [PATCH] organized parameters in Makefile --- Makefile | 59 +++++++++++++------------------------ precog/utils/general.py | 16 ++++++++++ precog/validators/reward.py | 17 +---------- 3 files changed, 37 insertions(+), 55 deletions(-) diff --git a/Makefile b/Makefile index cee96c2..fdf4fda 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,19 @@ -network = ws://127.0.0.1:9944 -netuid = 1 +## Network Parameters ## +finney = wss://entrypoint-finney.opentensor.ai:443 +testnet = wss://test.finney.opentensor.ai:443 +locanet = ws://127.0.0.1:9944 + +testnet_netuid = 256 +localnet_netuid = 1 logging_level = trace # options= ['info', 'debug', 'trace'] -coldkey = cm-owner + +netuid = $(testnet_netuid) +network = $(testnet) + +## User Parameters +coldkey = default +validator_hotkey = validator +miner_hotkey = miner metagraph: btcli subnet metagraph --netuid $(netuid) --subtensor.chain_endpoint $(network) @@ -16,28 +28,18 @@ validator: python start_validator.py \ --neuron.name validator \ --wallet.name $(coldkey) \ - --wallet.hotkey validator \ - --subtensor.chain_endpoint $(network) \ + --wallet.hotkey $(validator_hotkey) \ + --network $(network) \ --axon.port 30335 \ --netuid $(netuid) \ --logging.level $(logging_level) -validator2: - python start_validator.py \ - --neuron.name validator2 \ - --wallet.name $(coldkey) \ - --wallet.hotkey validator2 \ - --subtensor.chain_endpoint $(network) \ - --axon.port 30339 \ - --netuid $(netuid) \ - --logging.level $(logging_level) - miner: python start_miner.py \ --neuron.name miner \ --wallet.name $(coldkey) \ - --wallet.hotkey miner \ - --subtensor.chain_endpoint $(network) \ + --wallet.hotkey $(miner_hotkey) \ + --network $(network) \ --axon.port 30336 \ --netuid $(netuid) \ --logging.level $(logging_level) \ @@ -49,31 +51,10 @@ miner2: --neuron.name miner2 \ --wallet.name $(coldkey) \ --wallet.hotkey miner2 \ - --subtensor.chain_endpoint $(network) \ + --network $(network) \ --axon.port 30337 \ --netuid $(netuid) \ --logging.level $(logging_level) \ --timeout 16 \ --forward_function forward_bad -miner3: - python start_miner.py \ - --neuron.name miner3 \ - --wallet.name $(coldkey) \ - --wallet.hotkey miner3 \ - --subtensor.chain_endpoint $(network) \ - --axon.port 30338 \ - --netuid $(netuid) \ - --logging.level $(logging_level) \ - --timeout 16 \ - --forward_function forward - -setup_local: - btcli wallet faucet --wallet.name $(coldkey) --subtensor.chain_endpoint $(network) ;\ - btcli subnet create --wallet.name $(coldkey) --subtensor.chain_endpoint $(network) ;\ - btcli subnet register \ - --wallet.name $(coldkey) \ - --wallet.hotkey validator \ - --netuid $(netuid) - --subtensor.chain_endpoint $(network) ;\ - btcli stake add --wallet.name $(coldkey) --wallet.hotkey validator --amount 1024 ;\ diff --git a/precog/utils/general.py b/precog/utils/general.py index fbe3d5c..912b5f1 100644 --- a/precog/utils/general.py +++ b/precog/utils/general.py @@ -84,3 +84,19 @@ def get_version() -> Optional[str]: raise Exception("Version information not found") return version_match.group() + + +def rank(vector): + if vector is None or len(vector) <= 1: + return np.array([0]) + else: + # Sort the array and get the indices that would sort it + sorted_indices = np.argsort(vector) + sorted_vector = vector[sorted_indices] + # Create a mask for where each new unique value starts in the sorted array + unique_mask = np.concatenate(([True], sorted_vector[1:] != sorted_vector[:-1])) + # Use cumulative sum of the unique mask to get the ranks, then assign back in original order + ranks = np.cumsum(unique_mask) - 1 + rank_vector = np.empty_like(vector, dtype=int) + rank_vector[sorted_indices] = ranks + return rank_vector diff --git a/precog/validators/reward.py b/precog/validators/reward.py index 22e14c8..bad11fc 100644 --- a/precog/validators/reward.py +++ b/precog/validators/reward.py @@ -5,6 +5,7 @@ import numpy as np from precog.protocol import Challenge +from precog.utils.general import rank from precog.utils.timestamp import align_timepoints, get_now, mature_dictionary, round_minute_down @@ -49,22 +50,6 @@ def calc_rewards( return rewards -def rank(vector): - if vector is None or len(vector) <= 1: - return np.array([0]) - else: - # Sort the array and get the indices that would sort it - sorted_indices = np.argsort(vector) - sorted_vector = vector[sorted_indices] - # Create a mask for where each new unique value starts in the sorted array - unique_mask = np.concatenate(([True], sorted_vector[1:] != sorted_vector[:-1])) - # Use cumulative sum of the unique mask to get the ranks, then assign back in original order - ranks = np.cumsum(unique_mask) - 1 - rank_vector = np.empty_like(vector, dtype=int) - rank_vector[sorted_indices] = ranks - return rank_vector - - def interval_error(intervals, cm_prices): if intervals is None: return np.array([0])