-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
The Fiddle tutorials describe how to use parameter sharing for any object, but what would be the right way to reuse the same value of the primitive type in multiple places (similar to ConfigDict.get_ref)?
The solution I've found so far relies on replacing the value of primitive type by an fdl.Config for a lambda, but I wonder if there is a better way?
!pip install fiddle-config
import fiddle as fdl
import dataclasses
@dataclasses.dataclass
class Obj:
value: str
@dataclasses.dataclass
class BaseConfig:
primitive: str
nested: Obj
def build_base():
primitive = fdl.Config(lambda value: value, "NOT_SPECIFIED")
obj = fdl.Config(Obj, value=primitive)
return fdl.Config(BaseConfig, primitive=primitive, nested=obj)
c = build_base()
c.primitive.value = "NEW VALUE"
result = fdl.build(c)
print(result.nested.value)
(fiddle-config-0.1.0)
Metadata
Metadata
Assignees
Labels
No labels