diff --git a/sdk/python/kfp/__main__.py b/sdk/python/kfp/__main__.py index 921bbd36abf4..f70002926d1d 100644 --- a/sdk/python/kfp/__main__.py +++ b/sdk/python/kfp/__main__.py @@ -18,9 +18,5 @@ # kfp compile (migrate from dsl-compile) # kfp experiment (manage experiments) -# TODO: kfp pipeline delete -# Calling client._pipelines_api.delete_pipeline(id=pipeline_id) throws -# exception: module 'kfp_server_api.models' has no attribute 'ERRORUNKNOWN' - if __name__ == '__main__': main() diff --git a/sdk/python/kfp/_client.py b/sdk/python/kfp/_client.py index d84e726b851b..a62778d15a75 100644 --- a/sdk/python/kfp/_client.py +++ b/sdk/python/kfp/_client.py @@ -560,3 +560,15 @@ def get_pipeline(self, pipeline_id): Exception if pipeline is not found. """ return self._pipelines_api.get_pipeline(id=pipeline_id) + + def delete_pipeline(self, pipeline_id): + """Delete pipeline. + Args: + id of the pipeline. + Returns: + Object. If the method is called asynchronously, + returns the request thread. + Throws: + Exception if pipeline is not found. + """ + return self._pipelines_api.delete_pipeline(id=pipeline_id) diff --git a/sdk/python/kfp/cli/pipeline.py b/sdk/python/kfp/cli/pipeline.py index e6654b97437a..d8aa490be21a 100644 --- a/sdk/python/kfp/cli/pipeline.py +++ b/sdk/python/kfp/cli/pipeline.py @@ -74,6 +74,17 @@ def get(ctx, pipeline_id): _display_pipeline(pipeline) +@pipeline.command() +@click.argument("pipeline-id") +@click.pass_context +def delete(ctx, pipeline_id): + """Delete an uploaded KFP pipeline""" + client = ctx.obj["client"] + + client.delete_pipeline(pipeline_id) + print(f"{pipeline_id} is deleted") + + def _print_pipelines(pipelines): headers = ["Pipeline ID", "Name", "Uploaded at"] data = [[