Commit Graph

172 Commits

Author SHA1 Message Date
Jiaxiao Zheng 846423a870
feat(sdk): Always add pipeline root as a pipeline parameter (#5122)
* refactor pipeline root passing

* fix test
2021-02-10 16:29:57 -08:00
Jiaxiao Zheng 85a3b51713
feat(sdk): Add v2 component to build_python_component (#5079)
* porting the original PR

* comment

* refactor

* remove python2

* comment on default entrypoint

* update comment

* min versioned KFP

* fix tests
2021-02-04 01:50:36 -08:00
Chen Sun ecb14f40bb
chore(sdk): Remove v2 components fork, use v1 instead. (#5042)
* Remove v2.components fork

* fix setup.py
2021-01-28 18:20:07 -08:00
Jiaxiao Zheng 3ee0ae01eb
chore: Resolve comments in #5003 (#5009)
* use pathlib

* fix tests
2021-01-21 09:29:02 -08:00
Jiaxiao Zheng a36a62a700
feat(sdk): Artifact metadata related placeholder for components. (#5003)
* resolve comments.

* fix tests

* wip: add structures and skeleton for component resolution logic

* add generator

* fix the problem

* cleanup

* add a test

* fix tests
2021-01-19 08:57:45 -08:00
Alexey Volkov 691eefc599
fix(sdk): Components - Fixed python components that use \n. Fixes #4939 (#4993)
* SDK - Components - Fixed python components that use \n

The escape sequence was being replaced by the `echo` command.

Apparently, unlike in the `bash` shell, the `echo` command of the `sh` shell expands the escape sequences by default and does not support an option to turn it off. (For some reason the -n option works properly even though it should not).

Fixes https://github.com/kubeflow/pipelines/issues/4939

* Fixed the test data

* Fixed the deprecated container component builder

* Fixed the new compiler test case

* Added test
2021-01-14 18:21:51 -08:00
Jiaxiao Zheng 279694ec6d
feat(sdk): Container entrypoint used for new styled KFP component authoring (#4978)
* skeleton

* add entrypoint utils to parse param

* wip: artifact parsing

* add input param artifacts passing and clean unused code

* wip

* add output artifact inspection

* add parameter output

* finish entrypoint implementation

* add entrypoint_utils_test.py

* add entrypoint test

* add entrypoint test

* get rid of tf

* fix test

* fix file location

* fix tests

* fix tests

* resolving comments

* Partially rollback

* resolve comments in entrypoint.py

* resolve comments
2021-01-14 16:01:21 -08:00
Alexey Volkov d629397654
feat(sdk): Components - Support annotations when creating components from python (#4996)
The component specification has always supported component annotations, but there was no way to specify them for the components generated from python. This PR fixes that.
2021-01-14 13:59:31 -08:00
Jiaxiao Zheng 7540ba5c3b
feat(sdk): Implements artifact URI placeholder. (#4932)
* add placeholder to spec

* add output_directory to pipeline

* respect uri placeholder in file outputs

* wip: add data passing rewriting logic to respect the uri semantics

* merge input_uri and paths when instantiating ContainerOp

* fix

* fix workflow rewriting

* Add topology rewriting

* add a test case, and various fixes

* make the test case more complex

* Fix the case when working with OpsGroup

* Fix test case

* fix resolving test

* fix redundant cmd lines

* fix redundant cmd lines

* resolve comments

* fix file outputs

* resolve comments

* copy file outputs instead of modifying inplace.
2021-01-05 20:39:51 -08:00
Chen Sun 88dbfda02b
chore(sdk): Add inputUri and outputUri placeholders in v1 (#4913)
* SDK - Components - Added support for inputUri and outputUri placeholders

* remove InputUriSpec and OutputUriSpec

* Address review comments

Co-authored-by: Alexey Volkov <alexey.volkov@ark-kun.com>
2020-12-18 08:28:25 -08:00
Alexey Volkov 7a66414cf7
feat(sdk): Components - Restored stack traces in lightweight python components. Fixes #4273, #4849 (#4861)
Currently were running the python code inline using `python -c <code>`.
This has two issues:
1) Python does not show source code line in exception stack traces
2) inspect.getsource does not work. This method is used in PyTorch JIT for example.

We solve these issues by writing the code into a file before executing it.

The disadvantage of the new approach is that it adds complexity, a filesystem write operation and also requires the `sh` executable to be present (we could replace it with python-based program if needed).
2020-12-14 14:33:49 -08:00
Jiaxiao Zheng fb15223f7e
chore: Add doc strings marking the feature stages for SDK. (#4575)
* add doc strings

* Simplify the docstring

* fix unittest

* recover cli.py

* recover cli.py

* substitute docstring in resource ops with TODOs

* revert stable labels
2020-11-24 00:19:00 -08:00
Alexey Volkov 8699a05c27
fix(sdk): Components - Fixed handling of typing.NamedTuple in Python 3.9 (#4614)
Python 3.9 has dropped support for `typing.NamedTuple(...)`.`_field_types` in favor of `__annotations__` which in turn does not exist in Python 3.5.
2020-10-17 00:32:12 -07:00
Alexey Volkov ccc763fb71
SDK - Restored module decoupling (#4625)
A recent PR has added changes architecturally belonged to a different module (the component bridge). This has introduced unintended dependencies and couplings between the modules. This PR restores the module separation. It also makes the code simpler.
2020-10-13 20:11:54 -07:00
Chen Sun 5020fd1079
compiler for IR (#4529)
* Compile IR proto in setup.py

* compile to IR

* Fix importer node logic and lint

* cleanup and lint

* merge, undo setup.py change

* cleanup and lint

* remove currently unused code

* format _component_bridge.py

* cleanup and format

* cleanup

* upgrade protobuf in test

* restructure and test

* address review comments

* fix bug

* avoid f-strings formatting

* address review comments

* address review comments

* limit the primitive types to only int, double, and string.

* Fix test for python3.5

* use instance_schema instead of schema_title

* add v2 to setup.py

* address review comments

* move the tests closer to the code

* add more tests

* cleanup and linting

* add more tests

* fix bug on input paramter connection

* linting

* restructure tests

* fix python3.5 test failure

* support outputs.parameters placeholder

* remove pipeline decorator from v2.dsl
2020-10-13 17:13:54 -07:00
Alexey Volkov f445c09f81
chore(sdk): Components - Simplified graph component child task resolving (#4608)
Previously the process that was used to resolve a child task of a graph component was convoluted:
* Generate a dynamic task factory function for the child task component
* Convert input argument names from original to pythonic names
* Call the generated dynamic factory function using the python arguments to get back a task object
* Convert the task object outputs from pythonic back to original names (recently removed)

This PR significantly simplifies this process o just:
* Directly construct a task object based on the task component and the original arguments
2020-10-12 21:00:28 -07:00
Alexey Volkov be899723e3
fix(sdk): Components - Fixed ModelBase handling of open generic types in Python 3.9 (#4613)
In Python 3.9 the open generic types like `typing.Dict` lack the `__args__` attribute.
2020-10-12 04:12:47 -07:00
Alexey Volkov d4fd6e16a8
feat(sdk): Components - Added Bool as a known type name (#4597)
* SDK - Components - Added Bool as a known type name

Some components are already using this type name and are starting to fail due to more strict type checking during constant argument serialization.

* Fixed syntax error
2020-10-09 03:49:06 -07:00
Michalina Kotwica 0b3187966e
fix(sdk): Allow non-pythonic names for graph components' task's outputs. Fixes #4514. (#4515)
* add tests for pythonic and non-pythonic component outputs

* fix: graph for non-pythonic container output's names

Loading container component from component.yaml creates both
pythonic and original output names. Graph component iterated over
all outputs, using pythonic-to-output conversion on all. If some
of the names are not identical to their pythonic versions, they
rised KeyError on the lookup table.

This commit fixes this problem by using default value for the lookup.

* remove depythonification of outputs - not needed anymore
2020-09-28 20:53:25 -07:00
Abhishek Vilas Munagekar 5613db02bc
feat(sdk): Python components - Parse component input/output descriptions from the function docstring (#4512)
* cleanup imports

* add description to inputs and outputs

* update requirements

* add test

* improve component description

* update tests

* review changes: fix lint and requirements

* upgrade docstring-parser
2020-09-19 23:22:29 -07:00
Alexey Volkov 03325848fc
feat(sdk): Components - Prevent passing unserializable objects to components. Fixes #4040 (#4496) 2020-09-16 02:23:22 -07:00
Alex Latchford 704c8c7660
chore: Clean up KFP SDK docstrings, make formatting a little more consistent (#4218)
* Prepare SDK docs environment so its easier to understand how to build the docs locally so theyre consistent with ReadTheDocs.

* Clean up docstrings for kfp.Client

* Add in updates to the docs for compiler and components

* Update components area to add in code references and make formatting a little more consistent.

* Clean up containers, add in custom CSS to ensure we do not overflow on inline code blocks

* Clean up containers, add in custom CSS to ensure we do not overflow on inline code blocks

* Remove unused kfp.notebook package links

* Clean up a few more errant references

* Clean up the DSL docs some more

* Update SDK docs for KFP extensions to follow Sphinx guidelines

* Clean up formatting of docstrings after Ark-Kuns comments
2020-08-04 00:33:47 +08:00
Alexey Volkov 39975e3cde
SDK - Components - Temporary removed Kubernetes options from ComponentSpec (#4230)
* SDK - Components - Replaced Kubernetes options with generic launcher options

This reduces the schema size and makes the task launcher options more flexible.

* Removed the launcherOptions for now
2020-07-16 19:59:00 -07:00
Alexey Volkov aeb0401c8a
SDK - Components - Fixed examples in docstrings (#4074) 2020-07-14 14:27:21 -07:00
Alexey Volkov afd816161d
feat(sdk): SDK - Components - Added annotations to TaskSpec (#4153) 2020-07-12 22:22:32 -07:00
Alexey Volkov 9b1580039f
feat(sdk): SDK - Components - Added annotations to InputSpec and OutputSpec (#4154) 2020-07-12 21:34:33 -07:00
Alexey Volkov 79f6a4023d
fix(sdk): SDK - Components - Fixed the error message format string (#4130) 2020-07-01 23:00:00 -07:00
Alexey Volkov ceb860c594
SDK - Components - Python - Switched the default base image to python 3.7 (4054)
Previously the default image was set to an old version of tensorflow image. That image is now outdated. It's also framework-specific and pretty big.
We're switching to the official python image which is small, official and framework-agnostic.
The users can easily switch to the old behavior by just specifying `base_image='tensorflow/tensorflow:1.13.2-py3'` during the component creation.
2020-06-25 15:15:31 -07:00
Alexey Volkov 49fab02126
SDK - Components - Added authentication support for component loading functions (#3976) 2020-06-17 13:02:04 -07:00
Alexey Volkov 1403b9bd84
SDK - Components - Added ComponentStore search (#3884)
* SDK - Components - Added ComponentStore search

ComponentStore(...).search searches for components by name in the configured component store. It prints the name and URL for components that match the given name.
Only components on GitHub are currently supported.

Example:

```
kfp.components.ComponentStore.default_store.search('xgboost')

>>> Xgboost train   https://raw.githubusercontent.com/.../components/XGBoost/Train/component.yaml
>>> Xgboost predict https://raw.githubusercontent.com/.../components/XGBoost/Predict/component.yaml
```

* Implemented the review feedback

* Added retries
2020-06-03 23:54:44 -07:00
Alexey Volkov da5f86ee55
SDK - Normalize line endings when calculating component hash (#3882) 2020-06-01 03:08:03 -07:00
Alexey Volkov f773b9c263
SDK - Components - Stabilize JSON serialization by sorting keys (#3879)
* SDK - Components - Stabilize JSON serialization by sorting keys

Otherwise serialization of the default values of the component/pipeline inputs is unstable on Python 3.5.

* Fixed the test data
2020-06-01 03:07:55 -07:00
Alexey Volkov da4acbbd73
SDK - Python Components - Stop generating output saving code if no outputs (#3836)
Removed dead code from the generated python command-line wrapper.
2020-05-28 23:47:15 -07:00
Alexey Volkov 55d41df83d
SDK - Components - Removed the deprecated _python_op.get_default_base_image and set_default_base_image functions (#3773) 2020-05-17 20:23:36 -07:00
Alexey Volkov d418f57654
SDK - Components - Improved stability of the input and output renaming (#3738)
In some cases the input and output names need to be converted (for example, the input names need to be converted to python function parameter names).
With naive renaming, multiple inputs might be mapped to the same parameter name in some edge cases. The `generate_unique_name_conversion_table` creates a correct mapping.

However, in some really rare cases the resulting mapping could be confusing since it might rename an input whose name was already a correct parameter name and map a different input name to that parameter. E.g. {'AAA' -> 'aaa', 'aaa' -> 'aaa_2'}.
This PR fixes that. Names that do not change when applying the conversion_func will remain unchanged in the mapping. {'AAA' -> 'aaa_2', 'aaa' -> 'aaa'}.
2020-05-13 11:06:26 -07:00
Alexey Volkov fe30d5462a
SDK - Components - Calculate component hash digest (#3726)
* SDK - Components - Calculate component hash digest

The digest is calculated when loading the component from URL, tfile or text.
Slightly refactored component loading - streams are no longer used, only bytes.
TODO: Calculate the digest if missing
TODO: Report possible digest conflicts

* Updated the test graph component

* Using the actual digest in the test
2020-05-12 18:24:26 -07:00
Alexey Volkov b9aa106bb5
SDK - Prioritize lib2to3 when stripping type annotations (#3724)
* SDK - Prioritize lib2to3 when stripping type annotations

It's a standard python library (although not well supported) and it doe not leave training spaces.

* Fixed compiler test data
2020-05-11 18:44:20 -07:00
Alexey Volkov b3eeaaeb12
Updated the ComponentSpec schema (#3698) 2020-05-06 12:01:08 -07:00
Alexey Volkov 5ff7a65a0c
SDK - Components - Fixed bug in _strip_type_hints_using_lib2to3 (#3679) 2020-05-04 22:41:08 -07:00
Alexey Volkov e43a011033
SDK - Components - Split load_component functions into loading the spec and creating task factory (#3614)
The PR is a refactoring.
Split all load_component* methods in _components and _component_store into _load_component_spec* and creating task factory from that spec.
This makes it easier to load the spec without having to create task factory functions.
2020-04-29 14:30:18 -07:00
Alexey Volkov 9619655ed5
SDK - Enabled file inputs to be optional (#3620)
* SDK - Enabled file inputs to be optional

* Added unit tests
2020-04-27 19:34:04 -07:00
Alexey Volkov e41ee9cdf7
SDK - Components - Task objects now have the .output attribute when component has only one output (#3622) 2020-04-26 18:47:28 -07:00
Alexey Volkov 08c7c0ef36
SDK - Made YAML dumping more awesome (#3520)
See the root cause explanation in https://github.com/kubeflow/pipelines/issues/3519
2020-04-16 21:23:07 -07:00
Alexey Volkov 8cbf65b835
SDK - Components - Restored the yaml formatting style (#3488)
Fixing compatibility with PyYaml 5.3
2020-04-09 09:15:44 -07:00
Alexey Volkov ca4fe85311
SDK - Components - Fixed bug in loading input-less graph components (#3446) 2020-04-06 14:47:47 -07:00
Alexey Volkov be12ccf2a1
SDK - Moved the @python_component decorator test to dsl tests (#3324)
* SDK - Moved the @python_component decorator test to dsl tests

* Deprecate @python_component
2020-03-21 08:14:43 -07:00
Alexey Volkov 734b43e3db
SDK - Added support for maxCacheStaleness (#3318)
* SDK - Added support for maxCacheStaleness

* Added the vendor prefix to the annotation
2020-03-20 13:38:09 -07:00
Alexey Volkov 264ff37c1e
SDK - Moved _dsl_bridge to dsl (#3267)
This is a pure refactoring change.
The components library should not have any dependencies on the DSL library.
2020-03-14 00:12:34 -07:00
Alexey Volkov 119e329108
SDK - Components - Fixed handling collection return values (#3263)
* SDK - Components - Fixed handling collection return values

Fixes https://github.com/kubeflow/pipelines/issues/3262

* Fixed the tests
2020-03-12 23:50:39 -07:00
Alexey Volkov 0a9af0eeb8
SDK - Components - Make component structures hashable (#3258)
This commit makes it possiblt to put TaskSpec or InputSpec into python set.
2020-03-11 16:14:37 -07:00