-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(sdk): backport PipelineTaskFinalStatus change to sdk/release-1.8
branch
#7483
feat(sdk): backport PipelineTaskFinalStatus change to sdk/release-1.8
branch
#7483
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Again, going to ignore this test failure. |
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.
/lgtm
This looks great, @chensun. Just some small nitpick comments and things to consider.
@@ -16,6 +16,7 @@ | |||
from typing import Any, Callable, Dict, List, Optional, Union | |||
|
|||
from kfp.v2.components.types import artifact_types, type_annotations | |||
from kfp.v2.components import task_final_status |
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.
In the samples PipelineTaskFinalStatus
is imported from from dsl
, rather than components
. Should we import from the same place in samples and source code? Or is convention to import from dsl
as a "user/author" but from the "true" path in the kfp
source code?
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.
Applies to multiple files
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.
Or is convention to import from dsl as a "user/author"
This is definitely true. We want users to get our public interface from one of the packages. They shouldn't be aware of the true path, as they're considered internal and could be changed/moved.
but from the "true" path in the kfp source code?
This is probably my personal preference. From my view, the benefit is you won't get any surprise due to possible intended or unintended import aliasing, and you can always tell easily where's the source code for the dependency.
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.
Thank you for explaining -- that makes sense to me.
|
||
|
||
@component | ||
def exit_op(user_input: str, status: PipelineTaskFinalStatus): |
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.
nit: I think this should be dsl.PipelineTaskFinalStatus
per Google Python Style Guide 2.2 Imports.
I haven't been entirely consistent about this in my own PRs, FWIW.
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.
I asked the same question before. :)
The answer was it's okay to break the style guide to keep user experience simple, and I think that makes sense.
For the same reason, you may see our public examples like below.
from kfp.dsl import Input, Dataset
@component
def my_component(data: Input[Dataset]):
...
state=value.get('state'), | ||
pipeline_job_resource_name=value.get( | ||
'pipelineJobResourceName'), | ||
# pipelineTaskName won't be None once the BE change is |
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.
Is there any more info you can provide on which BE change this refers to (issue link, PR, etc)?
@@ -25,6 +25,7 @@ | |||
Model) | |||
from kfp.v2.components.types.type_annotations import (Input, InputPath, Output, | |||
OutputPath) | |||
from kfp.v2.components.task_final_status import PipelineTaskFinalStatus |
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.
(duplicate)
nit: I think this should be dsl.PipelineTaskFinalStatus
(or task_final_status.PipelineTaskFinalStatus
) per Google Python Style Guide 2.2 Imports.
I haven't been entirely consistent about this in my own PRs, FWIW.
@@ -30,6 +30,8 @@ | |||
from .structures import * | |||
from ._data_passing import serialize_value, get_canonical_type_for_type_name | |||
|
|||
from kfp.v2.components.types import type_utils |
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.
nit: update copyright to 2018-2022, I think?
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.
Applies to multiple files
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.
Adding current year is optional per https://opensource.google/documentation/reference/copyright
I'll skip that for this branch. :)
"""The final status of a pipeline task. | ||
|
||
This is the Python representation of the proto: PipelineTaskFinalStatus | ||
https://github.com/kubeflow/pipelines/blob/61d9210c61ff9be780b678ab78a7f7200d50cffa/api/v2alpha1/pipeline_spec.proto#L886 |
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.
This references a hash where kfp-pipeline-spec==0.1.13
. Should it be 0.1.14
per the change to setup.py
in this PR?
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.
Good catch. And I'll update the master branch on this shortly.
output_parameter_path, | ||
'gs://some-bucket/some_task/nested/output_parameter') | ||
output_parameter_path, self._test_dir + | ||
'/gcs/some-bucket/some_task/nested/output_parameter') |
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.
👍🏻
@@ -273,8 +274,23 @@ def execute(self): | |||
# `Optional[]` to get the actual parameter type. | |||
v = type_annotations.maybe_strip_optional_from_annotation(v) | |||
|
|||
if self._is_parameter(v): | |||
func_kwargs[k] = self._get_input_parameter_value(k, v) | |||
if v == task_final_status.PipelineTaskFinalStatus: |
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.
nit: Should this be is
instead of ==
because we're asking if the class is the same and the class itself is a singleton?
Feel free to ignore. This isn't entirely consistent throughout.
@@ -21,6 +21,7 @@ | |||
from kfp import components | |||
from kfp.v2 import compiler | |||
from kfp.v2 import dsl | |||
from kfp.v2.dsl import PipelineTaskFinalStatus |
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.
(duplicate) see other import path comments
if type_utils.is_task_final_status_type( | ||
input_spec.type): | ||
raise ValueError( | ||
'PipelineTaskFinalStatus can only be used in an exit task.' |
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.
nit / personal preference: consider using PipelineTaskFinalStatus.__name__
so that the string name will remain up-to-date if the dataclass
name ever changes.
@chensun: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/lgtm |
Description of your changes:
Re-implement #7309 in
sdk/release-1.8
branch.Checklist: