Skip to content

[Feature Request] Consider supporting singleton pattern in recursive instantiation #1393

@omry

Description

@omry

The following config can in theory be used to instantiate one object

container:
  _target_: ...
  object1:
    _target_: ...
    _singleton_: true

  object2: ${.object1}
c = instantiate(cfg.container)
assert c.object1 is c.object2

This will will probably require changes in OmegaConf.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions