From 558aa5f71bbf422f38d66bdc0112facda2822c8f Mon Sep 17 00:00:00 2001 From: bkb2135 Date: Mon, 23 Dec 2024 22:29:47 +0000 Subject: [PATCH 1/5] Manually Resync Metagraph --- prompting/weight_setting/weight_setter.py | 5 ++--- shared/settings.py | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/prompting/weight_setting/weight_setter.py b/prompting/weight_setting/weight_setter.py index d1e1a9de..fd2a08b6 100644 --- a/prompting/weight_setting/weight_setter.py +++ b/prompting/weight_setting/weight_setter.py @@ -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: @@ -239,8 +237,9 @@ 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 diff --git a/shared/settings.py b/shared/settings.py index 1fb9f84d..dc8cbc6a 100644 --- a/shared/settings.py +++ b/shared/settings.py @@ -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}") From 293e9c11c221131b6328c8ae3f86fa4a043d03ec Mon Sep 17 00:00:00 2001 From: bkb2135 Date: Mon, 23 Dec 2024 22:31:15 +0000 Subject: [PATCH 2/5] Bump Version Number --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b24f97a5..53fd4c33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" From 8f1494adb773766ccd33e5df5d8c5054a5a98efe Mon Sep 17 00:00:00 2001 From: bkb2135 Date: Mon, 23 Dec 2024 22:33:34 +0000 Subject: [PATCH 3/5] Formatting --- .env.api.example | 2 +- api_keys.json | 2 +- prompting/weight_setting/weight_setter.py | 4 +++- shared/settings.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.env.api.example b/.env.api.example index eaf06982..dcd8ea1d 100644 --- a/.env.api.example +++ b/.env.api.example @@ -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 \ No newline at end of file +VALIDATOR_API = "0.0.0.0:8094" # The validator API to forward responses to for scoring diff --git a/api_keys.json b/api_keys.json index 9e26dfee..0967ef42 100644 --- a/api_keys.json +++ b/api_keys.json @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/prompting/weight_setting/weight_setter.py b/prompting/weight_setting/weight_setter.py index fd2a08b6..03f7c47a 100644 --- a/prompting/weight_setting/weight_setter.py +++ b/prompting/weight_setting/weight_setter.py @@ -237,7 +237,9 @@ 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=shared_settings.SUBTENSOR, metagraph=shared_settings.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) diff --git a/shared/settings.py b/shared/settings.py index dc8cbc6a..e6c22175 100644 --- a/shared/settings.py +++ b/shared/settings.py @@ -253,7 +253,7 @@ def refresh_metagraph(self) -> bt.metagraph: 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}") From 065fd63a8dce681088fa5970f1ff1bf6a4a2113b Mon Sep 17 00:00:00 2001 From: bkb2135 Date: Tue, 24 Dec 2024 01:03:36 +0000 Subject: [PATCH 4/5] Improve weight attempt logging --- prompting/weight_setting/weight_setter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prompting/weight_setting/weight_setter.py b/prompting/weight_setting/weight_setter.py index 03f7c47a..51d3c879 100644 --- a/prompting/weight_setting/weight_setter.py +++ b/prompting/weight_setting/weight_setter.py @@ -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: logger.info("set_weights on chain successfully!") else: - logger.error("set_weights failed") + logger.error(f"set_weights failed: {result}") class WeightSetter(AsyncLoopRunner): From f86627db864315df952e603f17840891ec527497 Mon Sep 17 00:00:00 2001 From: bkb2135 Date: Tue, 24 Dec 2024 01:19:40 +0000 Subject: [PATCH 5/5] Update logging for cr3 --- prompting/weight_setting/weight_setter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prompting/weight_setting/weight_setter.py b/prompting/weight_setting/weight_setter.py index 51d3c879..01d5f20f 100644 --- a/prompting/weight_setting/weight_setter.py +++ b/prompting/weight_setting/weight_setter.py @@ -127,7 +127,7 @@ def set_weights( version_key=__spec_version__, ) - if result is True: + if result[0] is True: logger.info("set_weights on chain successfully!") else: logger.error(f"set_weights failed: {result}")