add type-checked get_field() method to TargetAdaptor and consume v1 target payloads #9188
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.
Problem
One possible attempt to address the migration to v2
TargetAdaptor
s, in conjunction with #9153. Theget_field()
method makes progress towards #4535.This implements the strategy from #8760, much more cleanly and efficiently.
Solution
TargetAdaptor
subclasses (such asPythonBinaryAdaptor
), assign a v1Target
subclass (such asPythonBinary
) to the_v1_target_class
class field inengine_initializer.py
.TargetAdaptor
is accessed, create an instance ofself._v1_target_class
withbuild_graph=None
andsources=None
.Target
to theTargetAdaptor
'skwargs()
.get_field()
method toTargetAdaptor
to access its kwargs while checking types.Result
If a v2
TargetAdaptor
has declared a_v1_target_class
field, it will have access to that target's payload fields when created. This allows re-use of logic written in v1 target classes, while allowing a smooth eventual migration to v2TargetAdaptor
s. Along with #9153, this is a first step in addressing #4535.