Eliminating restrictions on builds(..., zen_partial=<...>, builds_bases=(<...>))
#289
Labels
enhancement
New feature or request
Milestone
There are currently two restrictions that hydra-zen imposes on
builds(..., zen_partial=<...>, builds_bases=(<...>))
:1. Inheriting from a partial-builds parent
Inheriting from a parent where
zen_partial=True
requires that all children explicitly specifyzen_partial=True
.This restriction is due to the fact that the default argument for
zen_partial
isFalse
. Thus there is presently no way for us to distinguish between a user leavingzen_partial
unspecified and explicitly specifying that they wantzen_partial=False
for the child.Solution
We will update the default of
zen_partial
to beNone
so that we can distinguish betweenzen_partial
being left un-specified and it being set toFalse
explicitly. With this change in place, the following behaviors will manifest:2. Mixing
_partial_=True
with zen-processing featuresHydra's added support for partial instantiation made possible the formation of configs like:
where instantiating this config will produce:
this is not desirable as the
.func
attribute of this partial'd object should returnSomeTarget
, it will instead returnhydra_zen.funcs.zen_processing
Even more insidious is the case where we have:
Here, instantiating this config will produce:
I.e. the presence of
_partial_=true
and_zen_partial=true
means that the target will be double partial'd. For these reasons hydra-zen currently prohibits inheriting from a parent that uses zen-processing features into a child that is: a partial-builds and does not itself use zen-processing features.Specifically this leads to the following restrictions:
This is quite unintuitive for users, and leads to issues like #288 where a natural inheritance hierarchy with a partial'd base gets blocked.
Solution
We can detect when a child is both inheriting
_partial_=True
and is using zen_processing, and we can overwrite_partial_=False
and_zen_partial=True
so that onlyzen_processing
is responsible for performing the partial instantiation.Thus we would have:
Some sharp edges:
If we end up with configs like:
users may coerce their builds into being partial-builds by checking for / setting
_partial_=True
. This would be a mistake if_zen_partial=True
-- it can lead to the "double partial" scenario laid out above. There are a few things that we might do to reduce the risks of this:is_partial_builds
function that will check both_partial_
andzen_partial
for users. This could either warn or raise in the case when both are set to Truevalidate_partial_builds
function that will raise when it sees bad combinations of_partial_
and zen-processingThe text was updated successfully, but these errors were encountered: