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

Support Passing Dataclass Values via Command Line #2446

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

Future-Outlier
Copy link
Member

@Future-Outlier Future-Outlier commented May 28, 2024

Tracking issue

flyteorg/flyte#4486

Why are the changes needed?

Currently, we don't support passing dataclass values via command line after this PR.

For example, using this command line will raise an error.
pyflyte run --remote --image localhost:30000/any:0528-1445 dataclass_task.py foo_wf --a '{ "x": 1, "y": "2", "z": { "1": "one", "2": "two" }, "w": [1, 2, 3] }'

image

What changes were proposed in this pull request?

If we use only dataclass decorator only for our dataclass value, convert it to dataclass_json.

How was this patch tested?

local execution, remote execution and unit test.

Setup process

from flytekit import task, workflow
from dataclasses import dataclass

@dataclass
class Datum:
    x: int
    y: str
    z: dict[int, str]
    w: list[int]

@task
def foo_dataclass(a: Datum) -> int:
    if type(a) == Datum:
        return a.x
    return 0

@workflow
def foo_wf(a: Datum) -> int:
    return foo_dataclass(a=a)

Screenshots

local execution
image
remote execution
image
image
unit test
image

Check all the applicable boxes

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

@Future-Outlier Future-Outlier force-pushed the support-dataclass-command-line-input branch from 40b1935 to 7d13a64 Compare June 3, 2024 03:31
@Future-Outlier Future-Outlier changed the title [MINOR][easy] Support Passing Dataclass Values via Command Line [MINOR] Support Passing Dataclass Values via Command Line Jun 4, 2024
@Future-Outlier Future-Outlier merged commit 9872e65 into master Jun 4, 2024
46 checks passed
@wild-endeavor
Copy link
Contributor

renaming... no need for [MINOR] in the pr desc please. That typically means that the change is non-backwards compatible and will need a minor release instead of a patch release. (since we're kinda using minor as major at this point)

@Future-Outlier
Copy link
Member Author

renaming... no need for [MINOR] in the pr desc please. That typically means that the change is non-backwards compatible and will need a minor release instead of a patch release. (since we're kinda using minor as major at this point)

No problem, thank you

@Future-Outlier Future-Outlier changed the title [MINOR] Support Passing Dataclass Values via Command Line Support Passing Dataclass Values via Command Line Jun 17, 2024
fiedlerNr9 pushed a commit that referenced this pull request Jul 25, 2024
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants