Hey folks,
When I want to configure individual methods of a class, i.e. to write in config.gin something like:
If i'm not mistaken we need two layers of configurable decorators on our class, like so:
@gin.configurable
@dataclass
class Foo:
x: float = 5.
@gin.configurable(module="Foo")
def bar(self, y: float):
print(y)
@classmethod
@gin.configurable(module="Foo")
def baz(cls, xstr: str):
return cls(float(xstr))
This is fine, I guess the interpretation of the top-level decorator is that we only want to configure the init, and want to be explicit about which individual methods are configurable.
How do we tackle binding to method arguments on an external_configurable? In particular, I want to do something in config.gin like:
import llama_index
import mymodule.gin # inside I import ServiceContext and run gin.external_configurable on it
# ...
llama_index.ServiceContext.from_defaults.llm = %llm
Do I need to monkey patch gin-decorated versions of each method in the class from the external library?
Thanks for any advice or thoughts. Absolutely love this library btw.
Hey folks,
When I want to configure individual methods of a class, i.e. to write in
config.ginsomething like:If i'm not mistaken we need two layers of configurable decorators on our class, like so:
This is fine, I guess the interpretation of the top-level decorator is that we only want to configure the init, and want to be explicit about which individual methods are configurable.
How do we tackle binding to method arguments on an
external_configurable? In particular, I want to do something inconfig.ginlike:Do I need to monkey patch gin-decorated versions of each method in the class from the external library?
Thanks for any advice or thoughts. Absolutely love this library btw.