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

AIP-4600: [Part 2 of 3] Add in publishing to ZG Artifactory #8

Merged
merged 17 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ca04bf3
AIP-4600: Add in publishing to ZG Artifactory
alexlatchford Aug 31, 2021
7479ddf
Trigger CICD
alexlatchford Aug 31, 2021
3f68150
AIP-4600: Add in credentials for publishing to Artifactory
alexlatchford Aug 31, 2021
a8fa267
AIP-4600: Add in credentials for publishing to Artifactory
alexlatchford Aug 31, 2021
f2d7e50
AIP-4600: Add in credentials for publishing to Artifactory
alexlatchford Aug 31, 2021
876ebe7
AIP-4600: Add in credentials for publishing to Artifactory
alexlatchford Aug 31, 2021
0558130
AIP-4600: Add in credentials for publishing to Artifactory
alexlatchford Aug 31, 2021
05c3214
AIP-4600: Update PYPI_REPOSITORY to to publish to ANALYTICS_PYPI_REPO…
alexlatchford Sep 1, 2021
147bdbd
AIP-4600: Embed package name and version into sdist
alexlatchford Sep 2, 2021
9790c43
AIP-4600: Fix GNU sed compatibility error
alexlatchford Sep 2, 2021
248ef74
AIP-4600: Ensure + chars in KFP version are replaced when used as K8s…
alexlatchford Sep 2, 2021
95205d8
AIP-4600: Ensure + chars in KFP version are replaced when used as K8s…
alexlatchford Sep 3, 2021
3ebfb12
AIP-4600: Allow ZG to control semantic version of zillow-kfp
alexlatchford Sep 16, 2021
d614fc2
fix(sdk): Get short name of complex input/output types to ensure we c…
alexlatchford Sep 10, 2021
6f9828d
fix(sdk): Update upper bound on kubernetes constraint in Python SDK (…
alexlatchford Sep 9, 2021
ecf30d2
Merge pull request #9 from zillow/alexla/AIP-4600-pt3
alexlatchford Sep 21, 2021
9a564b5
AIP-4600: Update CICD pin
alexlatchford Sep 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
include:
alexlatchford marked this conversation as resolved.
Show resolved Hide resolved
- project: 'analytics/artificial-intelligence/ai-platform/aip-infrastructure/ci-templates/ci-cd-template'
ref: &include_ref 'v2'
file: '/blocks/python.yml'

stages:
- build

build:publish:
extends: .aip_python_debian_image
stage: build
variables:
MAJOR_VERSION: "1"
MINOR_VERSION: "0"
PY_LIBRARY_NAME: 'zillow-kfp'
KFP_VERSION_PATH: "sdk/python/kfp/__init__.py"
script:
- KFP_VERSION=$(cat $KFP_VERSION_PATH | sed -nr "s/^__version__ = ['\"]([^'\"]*)['\"]$/\1/p")
- |
if [ "${CI_COMMIT_BRANCH}" = "${CI_DEFAULT_BRANCH}" ]; then
PY_LIBRARY_VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${CI_PIPELINE_IID}.${KFP_VERSION}"
else
PY_LIBRARY_VERSION="0.0.${CI_PIPELINE_IID}.${KFP_VERSION}"
fi
# Now write back the zillow-kfp version back to the original location we found the original.
- sed -i "s/\(__version__ = ['\"]\)[^'\"]*\(['\"]\)/\1${PY_LIBRARY_VERSION}\2/" $KFP_VERSION_PATH
hsezhiyan marked this conversation as resolved.
Show resolved Hide resolved
- python setup.py sdist
# Set up the configuration for Artifactory to publish the python package internally.
- |
cat >~/.pypirc <<EOL
[distutils]
index-servers = artifactory
[artifactory]
repository: ${ANALYTICS_PYPI_REPOSITORY}
username: ${PYPI_USERNAME}
password: ${PYPI_PASSWORD}
EOL
- python setup.py sdist upload --repository "${ANALYTICS_PYPI_REPOSITORY}"
6 changes: 6 additions & 0 deletions sdk/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@

## Bug Fixes and Other Changes

* Remove dead code on importer check in v1. [\#6508](https://github.com/kubeflow/pipelines/pull/6508)
* Fix issue where dict, list, bool typed input parameters don't accept constant values or pipeline inputs. [\#6523](https://github.com/kubeflow/pipelines/pull/6523)
* Fix passing in "" to a str parameter causes the parameter to receive it as None instead. [\#6533](https://github.com/kubeflow/pipelines/pull/6533)
* Depends on `kfp-pipeline-spec>=0.1.10,<0.2.0` [\#6515](https://github.com/kubeflow/pipelines/pull/6515)
* Depends on kubernetes>=8.0.0,<19. [\#6532](https://github.com/kubeflow/pipelines/pull/6532)
* Get short name of complex input/output types to ensure we can map to appropriate de|serializer. [\#6504](https://github.com/kubeflow/pipelines/pull/6504)

## Documentation Updates

Expand Down
4 changes: 2 additions & 2 deletions sdk/python/kfp/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ def _create_workflow(
default=default_param_values[param.name]))

op_transformers = [add_pod_env]
pod_labels = {_SDK_VERSION_LABEL: kfp.__version__, _SDK_ENV_LABEL:_SDK_ENV_DEFAULT}
pod_labels = {_SDK_VERSION_LABEL: kfp.__version__.replace('+', '-'), _SDK_ENV_LABEL:_SDK_ENV_DEFAULT}
op_transformers.append(add_pod_labels(pod_labels))
op_transformers.extend(pipeline_conf.op_transformers)

Expand Down Expand Up @@ -974,7 +974,7 @@ def _create_workflow(


# Labels might be logged better than annotations so adding some information here as well
labels[_SDK_VERSION_LABEL] = kfp.__version__
labels[_SDK_VERSION_LABEL] = kfp.__version__.replace('+', '-')

return workflow

Expand Down
11 changes: 6 additions & 5 deletions sdk/python/kfp/components/_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ._naming import _sanitize_file_name, _sanitize_python_function_name, generate_unique_name_conversion_table
from ._yaml_utils import load_yaml
from .structures import *
from ._data_passing import serialize_value, get_canonical_type_for_type_struct
from ._data_passing import serialize_value, get_canonical_type_for_type_name


_default_component_name = 'Component'
Expand Down Expand Up @@ -375,10 +375,11 @@ def component_default_to_func_default(component_default: str, is_optional: bool)
input_parameters = [
_dynamic.KwParameter(
input_name_to_pythonic[port.name],
annotation=(get_canonical_type_for_type_struct(str(port.type)) or str(port.type) if port.type else inspect.Parameter.empty),
default=component_default_to_func_default(port.default, port.optional),
)
for port in reordered_input_list
annotation=(get_canonical_type_for_type_name(str(port.type)) or str(
port.type) if port.type else inspect.Parameter.empty),
default=component_default_to_func_default(port.default,
port.optional),
) for port in reordered_input_list
]
factory_function_parameters = input_parameters #Outputs are no longer part of the task factory function signature. The paths are always generated by the system.

Expand Down
64 changes: 45 additions & 19 deletions sdk/python/kfp/components/_data_passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@
# limitations under the License.

__all__ = [
'get_canonical_type_struct_for_type',
'get_canonical_type_for_type_struct',
'get_deserializer_code_for_type',
'get_deserializer_code_for_type_struct',
'get_serializer_func_for_type_struct',
'get_canonical_type_name_for_type',
'get_canonical_type_for_type_name',
'get_deserializer_code_for_type_name',
'get_serializer_func_for_type_name',
]


import inspect
from typing import Any, Callable, NamedTuple, Sequence
from typing import Any, Callable, NamedTuple, Optional, Sequence, Type
import warnings

from kfp.components import type_annotation_utils


Converter = NamedTuple('Converter', [
('types', Sequence[str]),
('types', Sequence[Type]),
('type_names', Sequence[str]),
('serializer', Callable[[Any], str]),
('deserializer_code', str),
Expand Down Expand Up @@ -125,37 +124,64 @@ def _deserialize_base64_pickle(s):
type_name_to_serializer = {type_name: converter.serializer for converter in _converters for type_name in converter.type_names}


def get_canonical_type_struct_for_type(typ) -> str:
def get_canonical_type_name_for_type(typ: Type) -> str:
"""Find the canonical type name for a given type.

Args:
typ: The type to search for.

Returns:
The canonical name of the type found.
"""
try:
return type_to_type_name.get(typ, None)
except:
return None


def get_canonical_type_for_type_struct(type_struct) -> str:
try:
return type_name_to_type.get(type_struct, None)
except:
return None
def get_canonical_type_for_type_name(type_name: str) -> Optional[Type]:
"""Find the canonical type for a given type name.

Args:
type_name: The type name to search for.

def get_deserializer_code_for_type(typ) -> str:
Returns:
The canonical type found.
"""
try:
return type_name_to_deserializer.get(get_canonical_type_struct_for_type[typ], None)
return type_name_to_type.get(type_name, None)
except:
return None


def get_deserializer_code_for_type_struct(type_struct) -> str:
def get_deserializer_code_for_type_name(type_name: str) -> Optional[str]:
"""Find the deserializer code for the given type name.

Args:
type_name: The type name to search for.

Returns:
The deserializer code needed to deserialize the type.
"""
try:
return type_name_to_deserializer.get(type_struct, None)
return type_name_to_deserializer.get(
type_annotation_utils.get_short_type_name(type_name), None)
except:
return None


def get_serializer_func_for_type_struct(type_struct) -> str:
def get_serializer_func_for_type_name(type_name: str) -> Optional[Callable]:
"""Find the serializer code for the given type name.

Args:
type_name: The type name to search for.

Returns:
The serializer func needed to serialize the type.
"""
try:
return type_name_to_serializer.get(type_struct, None)
return type_name_to_serializer.get(
type_annotation_utils.get_short_type_name(type_name), None)
except:
return None

Expand Down
10 changes: 5 additions & 5 deletions sdk/python/kfp/components/_python_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from ._yaml_utils import dump_yaml
from ._components import _create_task_factory_from_component_spec
from ._data_passing import serialize_value, get_deserializer_code_for_type_struct, get_serializer_func_for_type_struct, get_canonical_type_struct_for_type
from ._data_passing import serialize_value, get_deserializer_code_for_type_name, get_serializer_func_for_type_name, get_canonical_type_name_for_type
from ._naming import _make_name_unique_by_adding_index
from .structures import *
from . import _structures as structures
Expand Down Expand Up @@ -309,7 +309,7 @@ def annotation_to_type_struct(annotation):
if isinstance(annotation, dict):
return annotation
if isinstance(annotation, type):
type_struct = get_canonical_type_struct_for_type(annotation)
type_struct = get_canonical_type_name_for_type(annotation)
if type_struct:
return type_struct
type_name = str(annotation.__name__)
Expand All @@ -319,7 +319,7 @@ def annotation_to_type_struct(annotation):
type_name = str(annotation)

# It's also possible to get the converter by type name
type_struct = get_canonical_type_struct_for_type(type_name)
type_struct = get_canonical_type_name_for_type(type_name)
if type_struct:
return type_struct
return type_name
Expand Down Expand Up @@ -496,7 +496,7 @@ def _func_to_component_spec(func, extra_code='', base_image : str = None, packag

definitions = set()
def get_deserializer_and_register_definitions(type_name):
deserializer_code = get_deserializer_code_for_type_struct(type_name)
deserializer_code = get_deserializer_code_for_type_name(type_name)
if deserializer_code:
(deserializer_code_str, definition_str) = deserializer_code
if definition_str:
Expand Down Expand Up @@ -532,7 +532,7 @@ def get_argparse_type_for_input_file(passing_style):
raise NotImplementedError('Unexpected data passing style: "{}".'.format(str(passing_style)))

def get_serializer_and_register_definitions(type_name) -> str:
serializer_func = get_serializer_func_for_type_struct(type_name)
serializer_func = get_serializer_func_for_type_name(type_name)
if serializer_func:
# If serializer is not part of the standard python library, then include its code in the generated program
if hasattr(serializer_func, '__module__') and not _module_is_builtin_or_standard(serializer_func.__module__):
Expand Down
5 changes: 2 additions & 3 deletions sdk/python/kfp/v2/components/component_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def _annotation_to_type_struct(annotation):
if isinstance(annotation, dict):
return annotation
if isinstance(annotation, type):
type_struct = _data_passing.get_canonical_type_struct_for_type(
annotation)
type_struct = _data_passing.get_canonical_type_name_for_type(annotation)
if type_struct:
return type_struct
type_name = str(annotation.__name__)
Expand All @@ -99,7 +98,7 @@ def _annotation_to_type_struct(annotation):
type_name = str(annotation)

# It's also possible to get the converter by type name
type_struct = _data_passing.get_canonical_type_struct_for_type(type_name)
type_struct = _data_passing.get_canonical_type_name_for_type(type_name)
if type_struct:
return type_struct
return type_name
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docstring-parser>=0.7.3,<1
# kfp.dsl
PyYAML>=5.3,<6
jsonschema>=3.0.1,<4
kubernetes>=8.0.0,<13
kubernetes>=8.0.0,<19

# kfp.Client
kfp-server-api>=1.1.2,<2.0.0
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# pip-compile requirements.in
#

absl-py==0.11.0
# via -r requirements.in
attrs==20.3.0
Expand Down Expand Up @@ -68,7 +69,7 @@ kfp-pipeline-spec==0.1.9
# via -r requirements.in
kfp-server-api==1.3.0
# via -r requirements.in
kubernetes==12.0.1
kubernetes==18.20.0
# via -r requirements.in
oauthlib==3.1.0
# via requests-oauthlib
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import re
from setuptools import setup

NAME = 'kfp'
NAME = 'zillow-kfp' # 'kfp'
#VERSION = .... Change the version in kfp/__init__.py

# NOTICE, after any updates to the following, ./requirements.in should be updated
Expand All @@ -27,7 +27,7 @@
# `Blob.from_string` was introduced in google-cloud-storage 1.20.0
# https://github.com/googleapis/python-storage/blob/master/CHANGELOG.md#1200
'google-cloud-storage>=1.20.0,<2',
'kubernetes>=8.0.0,<13',
'kubernetes>=8.0.0,<19',
# google-api-python-client v2 doesn't work for private dicovery by default:
# https://github.com/googleapis/google-api-python-client/issues/1225#issuecomment-791058235
'google-api-python-client>=1.7.8,<2',
Expand Down