Skip to content

Commit

Permalink
v2.15.3
Browse files Browse the repository at this point in the history
Manually Resync Metagraph
  • Loading branch information
bkb2135 authored Dec 24, 2024
2 parents 3d58403 + f86627d commit bf64ca0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env.api.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ API_PORT = "42170" # Port for the API server
API_HOST = "0.0.0.0" # Host for the API server
SCORING_KEY = "123" # The scoring key for the validator (must match the scoring key in the .env.validator file)
SCORE_ORGANICS = True # Whether to score organics
VALIDATOR_API = "0.0.0.0:8094" # The validator API to forward responses to for scoring
VALIDATOR_API = "0.0.0.0:8094" # The validator API to forward responses to for scoring
2 changes: 1 addition & 1 deletion api_keys.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
15 changes: 8 additions & 7 deletions prompting/weight_setting/weight_setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ def set_weights(
netuid=shared_settings.NETUID,
uids=uint_uids,
weights=uint_weights,
wait_for_finalization=False,
wait_for_inclusion=False,
wait_for_finalization=True,
wait_for_inclusion=True,
version_key=__spec_version__,
)

if result is True:
if result[0] is True:
logger.info("set_weights on chain successfully!")
else:
logger.error("set_weights failed")
logger.error(f"set_weights failed: {result}")


class WeightSetter(AsyncLoopRunner):
Expand All @@ -148,8 +148,6 @@ class Config:

async def start(self, reward_events):
self.reward_events = reward_events
self.subtensor = bt.Subtensor(network=shared_settings.SUBTENSOR_NETWORK)
self.metagraph = self.subtensor.metagraph(netuid=shared_settings.NETUID)
global PAST_WEIGHTS

try:
Expand Down Expand Up @@ -239,8 +237,11 @@ async def run_step(self):
except Exception as ex:
logger.exception(f"{ex}")
# set weights on chain
set_weights(final_rewards, step=self.step, subtensor=self.subtensor, metagraph=self.metagraph)
set_weights(
final_rewards, step=self.step, subtensor=shared_settings.SUBTENSOR, metagraph=shared_settings.METAGRAPH
)
self.reward_events = [] # empty reward events queue
shared_settings.refresh_metagraph()
await asyncio.sleep(0.01)
return final_rewards

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "prompting"
version = "2.15.2"
version = "2.15.3"
description = "Subnetwork 1 runs on Bittensor and is maintained by Macrocosmos. It's an effort to create decentralised AI"
authors = ["Kalei Brady, Dmytro Bobrenko, Felix Quinque, Steffen Cruz, Richard Wardle"]
readme = "README.md"
Expand Down
6 changes: 6 additions & 0 deletions shared/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ def METAGRAPH(self) -> bt.metagraph:
logger.info(f"Instantiating metagraph with NETUID: {self.NETUID}")
return self.SUBTENSOR.metagraph(netuid=self.NETUID)

def refresh_metagraph(self) -> bt.metagraph:
# Drop the cached property so it will be recomputed
if "METAGRAPH" in self.__dict__:
del self.__dict__["METAGRAPH"]
return self.METAGRAPH

@cached_property
def DENDRITE(self) -> bt.dendrite:
logger.info(f"Instantiating dendrite with wallet: {self.WALLET}")
Expand Down

0 comments on commit bf64ca0

Please sign in to comment.