You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
maksay
changed the title
Parameter sharing for primitive types?
Parameter sharing for primitive types? ❓
May 24, 2022
maksay
changed the title
Parameter sharing for primitive types? ❓
Parameter sharing for primitive types❓
May 24, 2022
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?
(fiddle-config-0.1.0)
The text was updated successfully, but these errors were encountered: