Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add type-checked get_field() method to TargetAdaptor and consume v1 target payloads #9188

Conversation

cosmicexplorer
Copy link
Contributor

@cosmicexplorer cosmicexplorer commented Feb 27, 2020

Problem

One possible attempt to address the migration to v2 TargetAdaptors, in conjunction with #9153. The get_field() method makes progress towards #4535.

This implements the strategy from #8760, much more cleanly and efficiently.

Solution

  • For several TargetAdaptor subclasses (such as PythonBinaryAdaptor), assign a v1 Target subclass (such as PythonBinary) to the _v1_target_class class field in engine_initializer.py.
  • When such a TargetAdaptor is accessed, create an instance of self._v1_target_class with build_graph=None and sources=None.
  • Add all payload fields from the constructed v1 Target to the TargetAdaptor's kwargs().
  • Add the get_field() method to TargetAdaptor 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 v2 TargetAdaptors. Along with #9153, this is a first step in addressing #4535.

@Eric-Arellano
Copy link
Contributor

Closing due to being superseded by the Target API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants