Allow components to have __init__ functions #327
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, zookeeper will throw an error if a component defines an
__init__
. This is annoying, because it makes it impossible to use zookeeper components that subclass existing classes that have one, e.g.tf.keras.models.Model
.This PR changes that by:
__init__
function, which will be called directly after configuration. This makes its behavior identical to__post_configure__
, which is therefore deprecated. Neither function supports any arguments.__post_configure__
but is not configured #280. The reason I've implemented this is that it would be very easy for bugs to appear if the user expects their__init__
to have run, but the component was never configured. This means that users are now effectively forced to configure any and all zookeeper components they use, which may be overly strict in case allField
s already have default values. Before making this an official release, we could therefore consider automatically callingconfigure
on a component if all its fields have default values. This is tricky, however, because the user may then still configure it from the command line, and we wouldn't want the init functions to be called multiple times.