Skip to content

fix(sdk): fix bug where dsl.OneOf with multiple consumers cannot be compiled #10452

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

Conversation

connor-mccarthy
Copy link
Member

Description of your changes:

Checklist:

Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@connor-mccarthy connor-mccarthy force-pushed the fix-dsl-oneof-with-multiple-consumers branch 2 times, most recently from f3ed311 to fcfbe29 Compare February 6, 2024 23:14
@connor-mccarthy connor-mccarthy force-pushed the fix-dsl-oneof-with-multiple-consumers branch from fcfbe29 to d9b00a3 Compare February 7, 2024 00:50
@google-oss-prow google-oss-prow bot added size/M and removed size/S labels Feb 7, 2024
@connor-mccarthy connor-mccarthy marked this pull request as ready for review February 7, 2024 00:58
Copy link

@connor-mccarthy: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
kfp-kubernetes-execution-tests d9b00a3 link false /test kfp-kubernetes-execution-tests

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.

@connor-mccarthy
Copy link
Member Author

/assign @chensun
/cc @KevinGrantLee
/cc @rickyxie0929

@@ -4786,6 +4786,12 @@ def flip_coin_pipeline(execute_pipeline: bool):
x = dsl.OneOf(print_task_1.outputs['a'],
print_task_2.outputs['a'])
print_artifact(a=x)
# test can be consumed multiple times from same oneof object
print_artifact(a=x)
y = dsl.OneOf(print_task_1.outputs['a'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to me redundant oneof, x and y would never differ from each other. In which scenario would we need y instead of reusing x?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is redundant, but it should be permitted, similar to how this would be permitted in normal Python:

x = 1
y = 1
add(x, y)

even though add(x, x) is equivalent due to Python's use of call by value for immutable variables.

Prior to this PR, this would have failed. Since the PR adds a fix, it also adds test coverage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to allow this redundancy. Albeit I think it's also reasonable to block it. Reasons include:

  • dsl.OneOf is a special syntax that is paired with a conditional branch set. There're restrictions on which inputs it can accept--e.g. it needs to include all exclusive outputs, not something else nor a subset of such outputs. Arguably, its argument list is even redundant and skippable. The special use case warrants special treatment/requirement.
  • I had this concern earlier that the pair seems loosely connected given it allows arbitrary code in between of the conditional branch and the oneof statement. Allowing multiple collection seems exposing this loose-pair further.
  • Conceptually, the oneof resolution happens only once (at runtime). Enforcing a single oneof matches and highlights the actual behavior, and avoids possible misconception.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline and will merge as-is. As far as we can tell, there's no obvious cost to supporting this user code other than increased flexibility, which is both a cost and a benefit.

Copy link
Member

@chensun chensun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@@ -4786,6 +4786,12 @@ def flip_coin_pipeline(execute_pipeline: bool):
x = dsl.OneOf(print_task_1.outputs['a'],
print_task_2.outputs['a'])
print_artifact(a=x)
# test can be consumed multiple times from same oneof object
print_artifact(a=x)
y = dsl.OneOf(print_task_1.outputs['a'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to allow this redundancy. Albeit I think it's also reasonable to block it. Reasons include:

  • dsl.OneOf is a special syntax that is paired with a conditional branch set. There're restrictions on which inputs it can accept--e.g. it needs to include all exclusive outputs, not something else nor a subset of such outputs. Arguably, its argument list is even redundant and skippable. The special use case warrants special treatment/requirement.
  • I had this concern earlier that the pair seems loosely connected given it allows arbitrary code in between of the conditional branch and the oneof statement. Allowing multiple collection seems exposing this loose-pair further.
  • Conceptually, the oneof resolution happens only once (at runtime). Enforcing a single oneof matches and highlights the actual behavior, and avoids possible misconception.

@google-oss-prow google-oss-prow bot added the lgtm label Feb 8, 2024
@connor-mccarthy
Copy link
Member Author

/approve

Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: connor-mccarthy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 21c5ffe into kubeflow:master Feb 8, 2024
roytman pushed a commit to roytman/pipelines that referenced this pull request Feb 14, 2024
stijntratsaertit pushed a commit to stijntratsaertit/kfp that referenced this pull request Feb 16, 2024
petethegreat pushed a commit to petethegreat/pipelines that referenced this pull request Mar 27, 2024
petethegreat pushed a commit to petethegreat/pipelines that referenced this pull request Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants