This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
Ease-of-use improvements to wrapper teacher #3247
Merged
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.
Patch description
In most cases,
AbstractWrapperTeacher
is used to edit the fields of the action returned by the teacher that it wraps around. Assuming that this inner teacher is aFixedDialogTeacher
, however, editing the fields of this action is tricky because it must be done before theFixedDialogTeacher
performs further processing on the action and registers it for metrics and evaluations, as part ofFixedDialogTeacher.process_action()
. This, this PR givesAbstractWrapperTeacher
a concrete implementation of.act()
and an abstract method._edit_action()
, in order to give subclasses ofAbstractWrapperTeacher
an easy way to edit the action at the appropriate point in the pipeline without worrying about side effects.This change is back-compatible with all existing subclasses of
AbstractWrapperTeacher
, which are not required to use the new.act()
method or to provide an implementation of._edit_action()
. However, two particular subclasses ofAbstractWrapperTeacher
have been upgraded to use._edit_action()
to demonstrate how this new method is used.Testing steps
This change has test coverage through
tests/nightly/gpu/test_style_gen.py
andtests/test_wrapper.py
.test_new_tasks.py
As expected, an error is produced when running
python tests/datatests/test_new_tasks.py
onAbstractWrapperTeacher
, for the reason given in #2642