fix(sdk): fix upload_pipeline when no pipeline name is provided (#8695)
This commit is contained in:
parent
c79d35f53b
commit
e50f40305d
|
@ -7,6 +7,7 @@
|
||||||
## Deprecations
|
## Deprecations
|
||||||
|
|
||||||
## Bug fixes and other changes
|
## 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
|
## Documentation updates
|
||||||
# 2.0.0-beta.11
|
# 2.0.0-beta.11
|
||||||
|
|
|
@ -1372,9 +1372,8 @@ class Client:
|
||||||
``ApiPipeline`` object.
|
``ApiPipeline`` object.
|
||||||
"""
|
"""
|
||||||
if pipeline_name is None:
|
if pipeline_name is None:
|
||||||
pipeline_name = os.path.splitext(
|
pipeline_yaml = self._extract_pipeline_yaml(pipeline_package_path)
|
||||||
os.path.basename('something/file.txt'))[0]
|
pipeline_name = pipeline_yaml['pipelineInfo']['name']
|
||||||
|
|
||||||
validate_pipeline_resource_name(pipeline_name)
|
validate_pipeline_resource_name(pipeline_name)
|
||||||
response = self._upload_api.upload_pipeline(
|
response = self._upload_api.upload_pipeline(
|
||||||
pipeline_package_path, name=pipeline_name, description=description)
|
pipeline_package_path, name=pipeline_name, description=description)
|
||||||
|
|
|
@ -284,6 +284,45 @@ class TestClient(unittest.TestCase):
|
||||||
self.client.get_kfp_healthz(sleep_duration=0)
|
self.client.get_kfp_healthz(sleep_duration=0)
|
||||||
mock_get_kfp_healthz.assert_called()
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue