fix(sdk): fix upload_pipeline when no pipeline name is provided (#8695)

This commit is contained in:
Tara Tufano 2023-01-31 16:45:39 -05:00 committed by GitHub
parent c79d35f53b
commit e50f40305d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 3 deletions

View File

@ -7,6 +7,7 @@
## Deprecations
## Bug fixes and other changes
* Fix upload_pipeline method on client when no name is provided [\#8695](https://github.com/kubeflow/pipelines/pull/8695)
## Documentation updates
# 2.0.0-beta.11

View File

@ -1372,9 +1372,8 @@ class Client:
``ApiPipeline`` object.
"""
if pipeline_name is None:
pipeline_name = os.path.splitext(
os.path.basename('something/file.txt'))[0]
pipeline_yaml = self._extract_pipeline_yaml(pipeline_package_path)
pipeline_name = pipeline_yaml['pipelineInfo']['name']
validate_pipeline_resource_name(pipeline_name)
response = self._upload_api.upload_pipeline(
pipeline_package_path, name=pipeline_name, description=description)

View File

@ -284,6 +284,45 @@ class TestClient(unittest.TestCase):
self.client.get_kfp_healthz(sleep_duration=0)
mock_get_kfp_healthz.assert_called()
def test_upload_pipeline_without_name(self):
@component
def return_bool(boolean: bool) -> bool:
return boolean
@pipeline(name='test-upload-without-name', description='description')
def pipeline_test_upload_without_name(boolean: bool = True):
return_bool(boolean=boolean)
with patch.object(self.client._upload_api,
'upload_pipeline') as mock_upload_pipeline:
with patch.object(self.client, '_is_ipython', return_value=False):
with tempfile.TemporaryDirectory() as tmp_path:
pipeline_test_path = os.path.join(tmp_path, 'test.yaml')
Compiler().compile(
pipeline_func=pipeline_test_upload_without_name,
package_path=pipeline_test_path)
self.client.upload_pipeline(
pipeline_package_path=pipeline_test_path,
description='description')
mock_upload_pipeline.assert_called_once_with(
pipeline_test_path,
name='test-upload-without-name',
description='description')
def test_upload_pipeline_with_name(self):
with patch.object(self.client._upload_api,
'upload_pipeline') as mock_upload_pipeline:
with patch.object(self.client, '_is_ipython', return_value=False):
self.client.upload_pipeline(
pipeline_package_path='fake.yaml',
pipeline_name='overwritten-name',
description='description')
mock_upload_pipeline.assert_called_once_with(
'fake.yaml',
name='overwritten-name',
description='description')
if __name__ == '__main__':
unittest.main()