Skip to content
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(bindings): Task arguments default value binding #2401

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MortalHappiness
Copy link
Contributor

@MortalHappiness MortalHappiness commented May 9, 2024

Tracking issue

Resolves: flyteorg/flyte#5321

Why are the changes needed?

See the issue description for details.

What changes were proposed in this pull request?

if the key is not in kwargs but in interface.inputs_with_defaults, add the value in interface.inputs_with_defaults to kwargs.

How was this patch tested?

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

@MortalHappiness MortalHappiness marked this pull request as draft May 9, 2024 18:04
@MortalHappiness MortalHappiness force-pushed the feature/#5321-task-default-value-binding branch from b434ddf to cc13415 Compare May 9, 2024 18:45
@MortalHappiness MortalHappiness marked this pull request as ready for review May 9, 2024 18:46
@MortalHappiness MortalHappiness marked this pull request as draft May 9, 2024 18:50
@MortalHappiness MortalHappiness marked this pull request as ready for review May 10, 2024 04:51
Copy link
Member

@pingsutw pingsutw left a comment

Choose a reason for hiding this comment

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

Also, should we remove these lines? since if statement will always be false.

@@ -46,6 +46,14 @@ def t2(a: typing.Optional[int] = None) -> typing.Optional[int]:
assert p.ref.var == "o0"
assert len(p.ref.node.bindings) == 0

@task
def t_default_value(a: int = 1) -> typing.Optional[int]:
Copy link
Member

Choose a reason for hiding this comment

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

Could you also add a test like below?

@task
deft_default_value(a: int = 1) -> typing.Optional[int]:
    return a

@workflow
def wf() -> typing.Optional[int]:
  return t_default_value(a=2)

I want to make sure the output of the workflow is 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@MortalHappiness MortalHappiness force-pushed the feature/#5321-task-default-value-binding branch from cc13415 to 277d88b Compare May 15, 2024 12:49
@MortalHappiness
Copy link
Contributor Author

Also, should we remove these lines? since if statement will always be false.

Done

@MortalHappiness MortalHappiness force-pushed the feature/#5321-task-default-value-binding branch 2 times, most recently from 51e15e5 to 6446ad1 Compare May 16, 2024 15:13
@wild-endeavor
Copy link
Contributor

could you add more tests please? take a look at serialization tests, it should be pretty simple to test the compiled workflow.

do we do anything special for [] and {}? You're not supposed to use those as function defaults anyways but some people might.

Resolves: flyteorg/flyte#5321
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Resolves: flyteorg/flyte#5321
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
@MortalHappiness MortalHappiness force-pushed the feature/#5321-task-default-value-binding branch from 6446ad1 to 6c808ae Compare May 17, 2024 13:24
@MortalHappiness
Copy link
Contributor Author

could you add more tests please? take a look at serialization tests, it should be pretty simple to test the compiled workflow.

do we do anything special for [] and {}? You're not supposed to use those as function defaults anyways but some people might.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants