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.
Overview
Finishes formalizing the content for
BlueprintMixin
s, as well as the methodology for using them. With this change, we address two types of mixin users:BlueprintArgs
,SharedTaskState
, etc.It then includes machinery to discover Mixins for a blueprint, and automatically call their initializers and asserts. It also includes fixes for the ParlAI blueprint, and testing for the mixin architecture.
Implementation
Rather than using metaclass magic, in order to address both of the above classes, simple case users can use the
@BlueprintMixin. mixin_args_and_state
decorator on theirBlueprint
class, for whateverBlueprintMixin
s they want. Our tasks (ParlAIChatBlueprint
) use the extended form, in which we ask each configuration class to also mixin the mixin's defined configuration classes.This method wraps the created
Blueprint
with aMixedInBlueprint
which automatically incorporates and mixes in the config mixins that are required. Generally it's more opaque than doing it yourself, but it's certainly simpler for people who don't need to get into the nitty-gritty of defining the arguments.Discussion
The
extract_unique_mixins
method is likely the most "magic" method in this, going through the class structure of a givenBlueprint
and discovering allBlueprintMixin
s that can be considered "unique" (not directly subclassed by another mixin that is also included). I think this covers most cases to avoid redundancy, but in any case theinit_mixin_config
method of anyBlueprintMixin
should be idempotent to deal with cases where there are strange inheritance structures.@kushalchawla this should resolve your issue, and you can return to using
main
once it is merged. Sorry for the inconvenience!Testing
Added new testing, existing tests pass after the changes that move mixin config inits into the
Blueprint
base class.