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

SDK - Switching python container components to Lightweight components code generator #1889

Conversation

Ark-kun
Copy link
Contributor

@Ark-kun Ark-kun commented Aug 19, 2019

This PR switches the Python container components feature to use Lightweight components code generator and part of the component API unification and streamlining.
The code generation will now become the same which brings feature parity.

Here is a sample of the features that python container components will now support:

  • Multiple outputs (already added)
  • Input and output types (built-in types, simple types and parameterized types)
  • Default values for inputs (including complex default values like None, singletons, function calls etc.)
  • Capturing the dependencies of the function (functions, classes, modules)
  • Optional inputs

This PR reduces support for python 2. (Official Python 2 support ends in less than 5 months and Kubeflow Pipelines have only supported python 3.5+ from the start.)
SDK still supports specifying the python2 interpreter, but if the function is not compatible with python 2, the system no longer goes out of its way to fix the user code. This makes sense: if the user wants to run a function under python 2, the function should be compatible with python 2.

Fixes #1687
Fixes #1580
Fixes #1611

This PR builds on top of the #1887 refactoring (the first commit)


This change is Reviewable

@Ark-kun Ark-kun requested a review from gaoning777 August 19, 2019 21:09
@Ark-kun Ark-kun changed the title [WIP] SDK - Switching python container components to Lightweight components code generator SDK - Switching python container components to Lightweight components code generator Aug 19, 2019
@Ark-kun Ark-kun force-pushed the SDK---Using-the-Lightweight-code-generator-in-Python-container-components branch from c699aaa to 10874d8 Compare August 21, 2019 21:48
Ark-kun and others added 2 commits August 21, 2019 14:51
Had to remove the python2 test since python2 code generation is going away (python2 is near its End of Life and Kubeflow Pipelines only support python 3.5+).
@Ark-kun Ark-kun force-pushed the SDK---Using-the-Lightweight-code-generator-in-Python-container-components branch from 10874d8 to 6911236 Compare August 21, 2019 21:51
@Ark-kun
Copy link
Contributor Author

Ark-kun commented Aug 21, 2019

/retest

@Ark-kun
Copy link
Contributor Author

Ark-kun commented Aug 23, 2019

@gaoning777 All the tests are passing.

program_code = command_line_args[program_code_index]
return program_code


class TestGenerator(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add a test for a component function with default values?

Copy link
Contributor Author

@Ark-kun Ark-kun Sep 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are pretty extensive tests for default value handlingin the Lightweight components test suite.

def test_saving_default_values(self):

def test_handling_default_value_of_none(self):

def test_handling_complex_default_values_of_none(self):

Do you have some additional scenarios in mind?

@gaoning777
Copy link
Contributor

/lgtm

@Ark-kun
Copy link
Contributor Author

Ark-kun commented Sep 3, 2019

Talked with @gaoning777 offline: He proposed removing the test_func_to_endpoint in compiler/component_builder_test.oy since it's not just a proxy for _func_to_component_spec which is covered by tests in components/test_python_op.py.

This was proposed by @gaoning777: `_func_to_entrypoint` is now just a reference to `_func_to_component_spec` which is extensively covered by other tests.
@k8s-ci-robot k8s-ci-robot removed the lgtm label Sep 3, 2019
@Ark-kun
Copy link
Contributor Author

Ark-kun commented Sep 3, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Ark-kun

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gaoning777
Copy link
Contributor

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment