Skip to content

Commit

Permalink
feat(sdk): Upload namespaced pipeline definitions. Part of kubeflow#4197
Browse files Browse the repository at this point in the history


Add a namespace field in the relevant Python wrappers for uploading
namespaced pipeline definitions.
  • Loading branch information
elikatsis committed Feb 9, 2023
1 parent 0fc174a commit 10bb01b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
31 changes: 23 additions & 8 deletions sdk/python/kfp/client/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 The Kubeflow Authors
# Copyright 2022-2023 The Kubeflow Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1359,6 +1359,7 @@ def upload_pipeline(
pipeline_package_path: str,
pipeline_name: Optional[str] = None,
description: Optional[str] = None,
namespace: str = None,
) -> kfp_server_api.ApiPipeline:
"""Uploads a pipeline.
Expand All @@ -1367,6 +1368,9 @@ def upload_pipeline(
pipeline_name: Name of the pipeline to be shown in the UI.
description: Description of the pipeline to be shown in
the UI.
namespace: Optional. Kubernetes namespace where the pipeline should be uploaded.
For single user deployment, leave it as None;
For multi user, input a namespace where the user is authorized.
Returns:
``ApiPipeline`` object.
Expand All @@ -1375,8 +1379,12 @@ def upload_pipeline(
pipeline_yaml = self._extract_pipeline_yaml(pipeline_package_path)
pipeline_name = pipeline_yaml['pipelineInfo']['name']
validate_pipeline_resource_name(pipeline_name)
namespace = namespace or self.get_user_namespace()
response = self._upload_api.upload_pipeline(
pipeline_package_path, name=pipeline_name, description=description)
pipeline_package_path,
name=pipeline_name,
description=description,
namespace=namespace)
link = f'{self._get_url_prefix()}/#/pipelines/details/{response.id}'
if self._is_ipython():
import IPython
Expand All @@ -1388,12 +1396,13 @@ def upload_pipeline(
return response

def upload_pipeline_version(
self,
pipeline_package_path: str,
pipeline_version_name: str,
pipeline_id: Optional[str] = None,
pipeline_name: Optional[str] = None,
description: Optional[str] = None,
self,
pipeline_package_path: str,
pipeline_version_name: str,
pipeline_id: Optional[str] = None,
pipeline_name: Optional[str] = None,
description: Optional[str] = None,
namespace: Optional[str] = None
) -> kfp_server_api.ApiPipelineVersion:
"""Uploads a new version of the pipeline.
Expand All @@ -1404,6 +1413,9 @@ def upload_pipeline_version(
pipeline_id: ID of the pipeline.
pipeline_name: Name of the pipeline.
description: Description of the pipeline version to show in the UI.
namespace: Optional. Kubernetes namespace where the pipeline should be uploaded.
For single user deployment, leave it as None;
For multi user, input a namespace where the user is authorized.
Returns:
``ApiPipelineVersion`` object.
Expand All @@ -1423,6 +1435,9 @@ def upload_pipeline_version(
if description:
kwargs['description'] = description

if namespace:
kwargs['namespace'] = namespace or self.get_user_namespace()

response = self._upload_api.upload_pipeline_version(
pipeline_package_path, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kfp-pipeline-spec==0.2.0
# kfp-server-api package is released.
# Update the lower version when kfp sdk depends on new apis/fields in
# kfp-server-api.
kfp-server-api==2.0.0a6
kfp-server-api==2.0.0b0
kubernetes>=8.0.0,<24
protobuf>=3.13.0,<4
PyYAML>=5.3,<7
Expand Down

0 comments on commit 10bb01b

Please sign in to comment.