soldni / springs

A set of utilities to turn Dataclasses into useful configuration managers.
https://springs.soldaini.net
MIT License
11 stars 2 forks source link

Add option to register structured config by name #2

Closed soldni closed 2 years ago

soldni commented 2 years ago

It would convenient to be able to register structured config by name, so they can be easily recalled via a resolver.

Imagine something like this:

@sp.nickname("ducky")      # this is new 
@dataclass
class DuckyConfig:
    height: float: 3.
    color: str = 'yellow'

and then in a config:

root:
    toy: ${sp.nickname:ducky}     # this looks up "ducky" and places it here

Might have to figure out how to customize nicknamed configs on use.