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

[WIP] Fix Flyte Types Upload Issues in Default Input #2907

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

Conversation

Future-Outlier
Copy link
Member

@Future-Outlier Future-Outlier commented Nov 6, 2024

Tracking issue

flyteorg/flyte#5318

Why are the changes needed?

What changes were proposed in this pull request?

How was this patch tested?

remote execution and integration test.

"""
add context where Kevin and Yee found and add unit tests
fix the filepathtransofrmer to literal expected literal type's type hint
"""
import typing
import os
from dataclasses import dataclass, fields, field
from typing import Dict, List
from flytekit.types.file import FlyteFile
from flytekit.types.structured import StructuredDataset
from flytekit.types.directory import FlyteDirectory
from flytekit import task, workflow, ImageSpec
import datetime
from enum import Enum
import pandas as pd

flytekit_hash = "6a8f45cf30531d39633abce95def22327deaec4f"
flytekit = f"git+https://github.com/flyteorg/flytekit.git@{flytekit_hash}"
image = ImageSpec(
    packages=[flytekit, "pandas", "pyarrow"],
    apt_packages=["git"],
    registry="localhost:30000",
)

@dataclass
class DC:
    ff: FlyteFile
    sd: StructuredDataset

# /Users/future-outlier/code/dev/flytekit/build/debugyt/user/FE/src/data/df.parquet
# StructuredDataset(uri="/Users/future-outlier/code/dev/flytekit/build/debugyt/user/FE/src/data/df.parquet", file_format="parquet")

@task(container_image=image)
def t1(dc: DC = DC(ff=FlyteFile(os.path.realpath(__file__)),
                    sd=StructuredDataset(uri="/Users/future-outlier/code/dev/flytekit/build/debugyt/user/FE/src/data/df.parquet", file_format="parquet"))) -> DC:
    with open(dc.ff, "r") as f:
        print("File Content: ", f.read())
    print("sd:", dc.sd.open(pd.DataFrame).all())
    return dc

@workflow
def wf(dc: DC = DC(ff=FlyteFile(os.path.realpath(__file__)),
                    sd=StructuredDataset(uri="/Users/future-outlier/code/dev/flytekit/build/debugyt/user/FE/src/data/df.parquet", file_format="parquet"))):
    t1(dc=dc)

if __name__ == "__main__":
    from flytekit.clis.sdk_in_container import pyflyte
    from click.testing import CliRunner
    import os
    # print(os.path.realpath(__file__))
    # print(os.getcwd())

    runner = CliRunner()
    path = os.path.realpath(__file__)
    #
    result = runner.invoke(pyflyte.main,
                           ["run", path, "wf"])
    print("Local Execution: ", result.output)
    #
    result = runner.invoke(pyflyte.main,
                           ["run", "--remote", path, "wf"])
    print("Remote Execution: ", result.output)
    # #
    result = runner.invoke(pyflyte.main,
                           ["run", "--remote", path, "t1"])
    print("Remote Execution: ", result.output)

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

@Future-Outlier Future-Outlier changed the title Fix Flyte Types Upload Issues in Default Input [WIP] Fix Flyte Types Upload Issues in Default Input Nov 6, 2024
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.

1 participant