-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make it possible to upload a version of the pipeline with CLI #3672
Changes from 2 commits
4c7afc8
70d7d44
b9f51fc
be7ed6c
55c8551
7ed5434
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,20 @@ def upload(ctx, pipeline_name, package_file): | |
_display_pipeline(pipeline) | ||
|
||
|
||
@pipeline.command() | ||
@click.argument("package-file") | ||
@click.argument("pipeline-version") | ||
@click.argument("pipeline-id") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to have (at least some of them as) options instead? It is error-prone to require a specific order of numerous args. It could be: @click.option(
"--id",
"--pipeline-id",
help="ID of the pipeline"
)
@click.option(
"-v",
"--pipeline-version",
help="Name of the pipeline version"
)
@click.argument("package-file") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking they are the necessary arguments of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @elikatsis I changed them to the options, but I feel they should be arguments because of the following reasons.
Here is the diff to make the arguments options code diffdiff --git a/sdk/python/kfp/_client.py b/sdk/python/kfp/_client.py
index 0108314c..34fc25df 100644
--- a/sdk/python/kfp/_client.py
+++ b/sdk/python/kfp/_client.py
@@ -688,18 +688,6 @@ class Client(object):
IPython.display.display(IPython.display.HTML(html))
return response
- def upload_pipeline_version(self, pipeline_package_path, version_name, pipeline_id):
- """Uploads a version of the pipeline to the Kubeflow pipeline cluster.
- Args:
- pipeline_package_path: Local path to the pipeline package.
- version_name: Version name of the pipeline.
- pipeline_id: The string ID of the pipeline.
- Returns:
- A response object including details of a pipeline.
- """
- response = self._upload_api.upload_pipeline_version(pipeline_package_path, name=version_name, pipelineid=pipeline_id)
- return response
-
def get_pipeline(self, pipeline_id):
"""Get pipeline details.
Args:
diff --git a/sdk/python/kfp/cli/pipeline.py b/sdk/python/kfp/cli/pipeline.py
index 9abe9a4b..930a5f29 100644
--- a/sdk/python/kfp/cli/pipeline.py
+++ b/sdk/python/kfp/cli/pipeline.py
@@ -43,16 +43,27 @@ def upload(ctx, pipeline_name, package_file):
@pipeline.command()
+@click.option(
+ "-p",
+ "--pipeline-id",
+ help="ID of the pipeline"
+)
+@click.option(
+ "-v",
+ "--pipeline-version",
+ help="Name of the pipeline version"
+)
@click.argument("package-file")
-@click.argument("pipeline-version")
-@click.argument("pipeline-id")
@click.pass_context
def upload_version(ctx, package_file, pipeline_version, pipeline_id):
"""Upload a version of the KFP pipeline"""
client = ctx.obj["client"]
- version = client.upload_pipeline_version(package_file, pipeline_version, pipeline_id)
- logging.info("The {} version of the pipeline {} has been submitted\n".format(pipeline_version, pipeline_id))
+ version = client.pipeline_uploads.upload_pipeline_version(
+ package_file, name=pipeline_version, pipelineid=pipeline_id)
+ logging.info(
+ "The {} version of the pipeline {} has been submitted\n".format(
+ pipeline_version, pipeline_id))
_display_pipeline_version(version)
Could you tell me your thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe you could set the @click.option(
"-v",
"--pipeline-version",
required=True,
help="Name of the pipeline version"
) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I modified the code in 70d7d44...7ed5434. PTAL. |
||
@click.pass_context | ||
def upload_version(ctx, package_file, pipeline_version, pipeline_id): | ||
"""Upload a version of the KFP pipeline""" | ||
client = ctx.obj["client"] | ||
|
||
version = client.upload_pipeline_version(package_file, pipeline_version, pipeline_id) | ||
logging.info("The {} version of the pipeline {} has been submitted\n".format(pipeline_version, pipeline_id)) | ||
_display_pipeline_version(version) | ||
|
||
|
||
@pipeline.command() | ||
@click.option( | ||
"--max-size", | ||
|
@@ -110,3 +124,14 @@ def _display_pipeline(pipeline): | |
headers = ["Parameter Name", "Default Value"] | ||
data = [[param.name, param.value] for param in pipeline.parameters] | ||
print(tabulate(data, headers=headers, tablefmt="grid")) | ||
|
||
|
||
def _display_pipeline_version(version): | ||
print(tabulate([], headers=["Pipeline Version Details"])) | ||
pipeline_id = version.resource_references[0].key.id | ||
table = [ | ||
["Pipeline ID", pipeline_id], | ||
["Version Name", version.name], | ||
["Uploaded at", version.created_at.isoformat()], | ||
] | ||
print(tabulate(table, tablefmt="plain")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use
client.pipeline_uploads.upload_pipeline_version()
instead of creating a helper?