From 9e682ddacc01b5175d5a4cdb589a847af53598fd Mon Sep 17 00:00:00 2001 From: bhimes Date: Wed, 1 May 2024 22:55:18 +0200 Subject: [PATCH] Monkeypatch in the caching of get_decoder_class Fixes #1833 --- bittensor/subtensor.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bittensor/subtensor.py b/bittensor/subtensor.py index 22396e38e8..33c04c71c6 100644 --- a/bittensor/subtensor.py +++ b/bittensor/subtensor.py @@ -1,6 +1,7 @@ # The MIT License (MIT) # Copyright © 2021 Yuma Rao # Copyright © 2023 Opentensor Foundation +import functools # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated # documentation files (the “Software”), to deal in the Software without restriction, including without limitation @@ -92,6 +93,21 @@ T = TypeVar("T") +####### +# Monkey patch in caching the get_decoder_class method +####### +@functools.cache +def patched_get_decoder_class(self, type_string): + return original_get_decoder_class(self, type_string) + + +if hasattr(RuntimeConfiguration, "get_decoder_class"): + original_get_decoder_class = RuntimeConfiguration.get_decoder_class + RuntimeConfiguration.get_decoder_class = patched_get_decoder_class + +####### + + class ParamWithTypes(TypedDict): name: str # Name of the parameter. type: str # ScaleType string of the parameter.