Skip to content

Commit

Permalink
organized parameters in Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
hscott-yuma committed Dec 5, 2024
1 parent f4a8d05 commit 6ecdd83
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 55 deletions.
59 changes: 20 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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) \
Expand All @@ -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 ;\
16 changes: 16 additions & 0 deletions precog/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 1 addition & 16 deletions precog/validators/reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 6ecdd83

Please sign in to comment.