Summary: Provide an extension point pre_expand to let a configurable class A make sure another class B is registered before A is expanded. This reduces top level imports.
Reviewed By: bottler
Differential Revision: D44504122
fbshipit-source-id: c418bebbe6d33862d239be592d9751378eee3a62
Summary:
Small config system fix. Allows get_default_args to work on an instance which has been created with a dict (instead of a DictConfig) as an args field. E.g.
```
gm = GenericModel(
raysampler_AdaptiveRaySampler_args={"scene_extent": 4.0}
)
OmegaConf.structured(gm1)
```
Reviewed By: shapovalov
Differential Revision: D40341047
fbshipit-source-id: 587d0e8262e271df442a80858949a48e5d6db3df
Summary:
- indicate location of OmegaConf.structured failures
- split the data gathering from enable_get_default_args to ease experimenting with it.
- comment fixes.
- nicer error when a_class_type has weird type.
Reviewed By: kjchalup
Differential Revision: D39434447
fbshipit-source-id: b80c7941547ca450e848038ef5be95b7ebbe8f3e
Summary: Made the config system call open_dict when it calls the tweak function.
Reviewed By: shapovalov
Differential Revision: D38315334
fbshipit-source-id: 5924a92d8d0bf399bbf3788247f81fc990e265e7
Summary:
This is an internal change in the config systen. It allows redefining a pluggable implementation with new default values. This is useful in notebooks / interactive use. For example, this now works.
class A(ReplaceableBase):
pass
registry.register
class B(A):
i: int = 4
class C(Configurable):
a: A
a_class_type: str = "B"
def __post_init__(self):
run_auto_creation(self)
expand_args_fields(C)
registry.register
class B(A):
i: int = 5
c = C()
assert c.a.i == 5
Reviewed By: shapovalov
Differential Revision: D38219371
fbshipit-source-id: 72911a9bd3426d3359cf8802cc016fc7f6d7713b
Summary: Allow a class to modify its subparts in get_default_args by defining the special function provide_config_hook.
Reviewed By: davnov134
Differential Revision: D36671081
fbshipit-source-id: 3e5b73880cb846c494a209c4479835f6352f45cf
Summary: Fix recently observed case where enable_get_default_args was missing things declared as Optional[something mutable]=None.
Reviewed By: davnov134
Differential Revision: D36440492
fbshipit-source-id: 192ec07564c325b3b24ccc49b003788f67c63a3d
Summary: Make create_x delegate to create_x_impl so that users can rely on create_x_impl in their overrides of create_x.
Reviewed By: shapovalov, davnov134
Differential Revision: D35929810
fbshipit-source-id: 80595894ee93346b881729995775876b016fc08e
Summary:
Applies new import merging and sorting from µsort v1.0.
When merging imports, µsort will make a best-effort to move associated
comments to match merged elements, but there are known limitations due to
the diynamic nature of Python and developer tooling. These changes should
not produce any dangerous runtime changes, but may require touch-ups to
satisfy linters and other tooling.
Note that µsort uses case-insensitive, lexicographical sorting, which
results in a different ordering compared to isort. This provides a more
consistent sorting order, matching the case-insensitive order used when
sorting import statements by module name, and ensures that "frog", "FROG",
and "Frog" always sort next to each other.
For details on µsort's sorting and merging semantics, see the user guide:
https://usort.readthedocs.io/en/stable/guide.html#sorting
Reviewed By: bottler
Differential Revision: D35553814
fbshipit-source-id: be49bdb6a4c25264ff8d4db3a601f18736d17be1
Summary: A new type of auto-expanded member of a Configurable: something of type Optional[X] where X is a Configurable. This works like X but its construction is controlled by a boolean membername_enabled.
Reviewed By: davnov134
Differential Revision: D35368269
fbshipit-source-id: 7e0c8a3e8c4930b0aa942fa1b325ce65336ebd5f
Summary:
Try again to solve https://github.com/facebookresearch/pytorch3d/issues/1144 pickling problem.
D35258561 (24260130ce) didn't work.
When writing a function or vanilla class C which you want people to be able to call get_default_args on, you must add the line enable_get_default_args(C) to it. This causes autogeneration of a hidden dataclass in the module.
Reviewed By: davnov134
Differential Revision: D35364410
fbshipit-source-id: 53f6e6fff43e7142ae18ca3b06de7d0c849ef965
Summary: Aid reflection by adding the original declared types of replaced members of a configurable as values in _processed_members.
Reviewed By: davnov134
Differential Revision: D35358422
fbshipit-source-id: 80ef3266144c51c1c2105f349e0dd3464e230429
Summary:
ListConfig and DictConfig members of get_default_args(X) when X is a callable will contain references to a temporary dataclass and therefore be unpicklable. Avoid this in a few cases.
Fixes https://github.com/facebookresearch/pytorch3d/issues/1144
Reviewed By: shapovalov
Differential Revision: D35258561
fbshipit-source-id: e52186825f52accee9a899e466967a4ff71b3d25
Summary: Allow things like `renderer:Optional[BaseRenderer]` in configurables.
Reviewed By: davnov134
Differential Revision: D35118339
fbshipit-source-id: 1219321b2817ed4b26fe924c6d6f73887095c985
Summary:
Before the fix, running get_default_args(C: Callable) returns an unstructured DictConfig which causes Enums to be handled incorrectly. This is a fix.
WIP update: Currently tests still fail whenever a function signature contains an untyped argument: This needs to be somehow fixed.
Reviewed By: bottler
Differential Revision: D34932124
fbshipit-source-id: ecdc45c738633cfea5caa7480ba4f790ece931e8