-
Notifications
You must be signed in to change notification settings - Fork 310
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
VoidPromise and Promise chaining #981
Conversation
Signed-off-by: Kevin Su <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #981 +/- ##
==========================================
+ Coverage 86.26% 86.33% +0.06%
==========================================
Files 252 252
Lines 24129 24177 +48
Branches 2745 2750 +5
==========================================
+ Hits 20815 20873 +58
+ Misses 2846 2839 -7
+ Partials 468 465 -3
Continue to review full report at Codecov.
|
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 this chaining void promise? What about promises with outputs?
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Updated it. Now it works for both the promise and the void promise. |
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
flytekit/core/promise.py
Outdated
def __lshift__(self, other: typing.Union[Promise, VoidPromise]): | ||
if not self.is_ready: | ||
other.ref.node.runs_before(self.ref.node) |
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 find the right shift syntax more clear, but maybe I'm missing some use case that could benefit from support for left shift as well?
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.
how about we just document in the flytesnacks PR that you can set either upstream or downstream dependencies?
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 find Airflow support left shift, so I add that. https://airflow.apache.org/docs/apache-airflow/stable/tutorial.html#adding-dag-and-tasks-documentation.
how about we just document in the flytesnacks PR that you can set either upstream or downstream dependencies?
will do.
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 feel like we can deprecate create_node
if we have promise chaining. https://docs.flyte.org/projects/cookbook/en/latest/auto/core/control_flow/chain_tasks.html#sphx-glr-auto-core-control-flow-chain-tasks-py
What do you think? also cc @wild-endeavor
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'm not sure we should deprecate create_node
right now. The API proposed in this PR is better, but there's no automated migration for people who are using create_node
, so unless supporting that is going to cause trouble for us down the line we should keep it.
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.
can we not add lshift actually?
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.
sure, removed it
@@ -332,6 +332,14 @@ def __init__(self, var: str, val: Union[NodeOutput, _literal_models.Literal]): | |||
def __hash__(self): | |||
return hash(id(self)) | |||
|
|||
def __rshift__(self, other: typing.Union[Promise, VoidPromise]): |
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.
Not for this PR, but we should support chaining of multiple tasks/nodes, for example, this should work:
t1 >> t2 >> t3
but right now we only have support for pair-wise constraints, in other words, we have to specify separately:
t1 >> t2
t2 >> t3
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 can get pretty crazy, imagine someone doing:
t1 >> t2 << t3
😂
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.
Yeah could we remove the lshift actually? I feel like having only one symbolic way and one text-based way is good enough. another one can be confusing.
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su [email protected]
TL;DR
create_node
Type
Are all requirements met?
Complete description
Tracking Issue
flyteorg/flyte#2374
Follow-up issue
NA