-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow struct/dataclass types to be used as default arguments (#1024)
* Allow struct/dataclass types to be used as default arguments Signed-off-by: Roberto Ruiz <[email protected]> * Add test case Signed-off-by: Eduardo Apolinario <[email protected]> * Lint Signed-off-by: Eduardo Apolinario <[email protected]> Co-authored-by: Eduardo Apolinario <[email protected]>
- Loading branch information
1 parent
065b899
commit 5c1395a
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/flytekit/unit/cli/pyflyte/dataclasses_default_arguments/wf.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from dataclasses import dataclass | ||
|
||
from dataclasses_json import dataclass_json | ||
|
||
from flytekit import task, workflow | ||
|
||
|
||
@dataclass_json | ||
@dataclass | ||
class DataclassA: | ||
a: str | ||
b: int | ||
|
||
|
||
@task | ||
def t(dca: DataclassA): | ||
print(dca) | ||
|
||
|
||
@workflow | ||
def wf(dca: DataclassA = DataclassA("hello", 42)): | ||
t(dca=dca) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters