Skip to content

Commit

Permalink
Monkeypatch in the caching of get_decoder_class
Browse files Browse the repository at this point in the history
Fixes #1833
  • Loading branch information
thewhaleking committed May 1, 2024
1 parent 752c1ad commit 9e682dd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bittensor/subtensor.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9e682dd

Please sign in to comment.