-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hi, I have had the problem that I often want variables defined in the top-most layers of my config (e.g. a logger as seen below), which I then want to refer to in multiple places. This causes a recursion error:
InterpolationDepthError: Recursion limit exceeded in value substitution: option 'logger' in section 'training' contains an interpolation key which cannot be substituted in 10 steps. Raw value: '${logger}'
I don't see any principled reason why that would not be possible (though I might be wrong). My question is simply if I were to find the time to make a PR for this would it be considered useful?
Minimal example:
import catalogue
from confection import Config, registry
class Registry(registry):
registry = catalogue.create("my_package", "loggers")
@Registry.registry.register("my_logger")
def test_fn(name: str):
return name
# desired config
config_str_unnested = """
[logger]
@registry = "my_logger"
name = "test_logger"
[training]
batch_size = 32
logger = ${logger}
"""
# current config
config_str_nested = """
[logger]
[logger.logger]
@registry = "my_logger"
name = "test_logger"
[training]
batch_size = 32
logger = ${logger.logger}
"""
if __name__ == "__main__":
cfg = Config().from_str(text=config_str_nested)
# works, but is less readable
cfg = Config().from_str(text=config_str_unnested)
# does not work, but is more readable
bdewilde
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request