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

Better error for min_success_ratio<1 #2724

Merged
merged 11 commits into from
Sep 3, 2024
Merged

Conversation

pingsutw
Copy link
Member

@pingsutw pingsutw commented Aug 30, 2024

Tracking issue

NA

Why are the changes needed?

when min_success_ratio < 1, flytekit automatically makes the output interface optional (str => Optional[str])
If the input of the downstream task is not optional, Flytekit will fail to deserialize the output and display a confusing error message

What changes were proposed in this pull request?

check the type at compile time

How was this patch tested?

Setup process

pyflyte run flyte-example/map_optional_list.py wf
import os
import tempfile
from typing import List

from flytekit import map_task, workflow, task
from flytekit.types.directory import FlyteDirectory


@task
def generate_directory(word: str) -> FlyteDirectory:
    temp_dir1 = tempfile.TemporaryDirectory()
    with open(os.path.join(temp_dir1.name, "file.txt"), "w") as tmp:
        tmp.write(f"Hello world {word}!\n")
    return FlyteDirectory(path=temp_dir1.name)


@task
def consume_directories(dirs: List[FlyteDirectory]):
    for d in dirs:
        print(f"Directory: {d.path} {d._remote_source}")
        for path_info, other_info in d.crawl():
            print(path_info)


mt = map_task(generate_directory, min_success_ratio=0.1)


@workflow
def wf():
    dirs = mt(word=["one", "two", "three"])
    consume_directories(dirs=dirs

Screenshots

Before:
Screenshot 2024-09-03 at 11 47 01 AM

After:
Screenshot 2024-09-03 at 11 46 00 AM

Check all the applicable boxes

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

Related PRs

NA

Docs link

NA

wild-endeavor and others added 5 commits August 28, 2024 13:54
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Copy link

codecov bot commented Aug 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Project coverage is 48.31%. Comparing base (8bad8e6) to head (f18b84d).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
flytekit/core/promise.py 0.00% 14 Missing ⚠️
flytekit/core/type_engine.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2724      +/-   ##
==========================================
- Coverage   49.76%   48.31%   -1.45%     
==========================================
  Files         193      279      +86     
  Lines       19659    24057    +4398     
  Branches     4097     2844    -1253     
==========================================
+ Hits         9783    11624    +1841     
- Misses       9345    12220    +2875     
+ Partials      531      213     -318     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@task
def consume_directories(dirs: List[FlyteDirectory]):
for d in dirs:
print(f"Directory: {d.path} {d._remote_source}")
Copy link
Contributor

Choose a reason for hiding this comment

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

nix this

Copy link
Contributor

Choose a reason for hiding this comment

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

oh this won't run nm, keep

wild-endeavor
wild-endeavor previously approved these changes Aug 30, 2024
@wild-endeavor
Copy link
Contributor

i think it's good to have this... i don't want flytekit to fall into the trap of duplicating the compiler, but this is a common and tricky enough case that I think it's okay to explicitly catch this.

Signed-off-by: Kevin Su <pingsutw@apache.org>
@pingsutw pingsutw marked this pull request as ready for review September 3, 2024 18:46
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
@pingsutw pingsutw changed the title [WIP] Better error for min_success_ratio<1 Better error for min_success_ratio<1 Sep 3, 2024
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
@wild-endeavor wild-endeavor merged commit a5c44cd into master Sep 3, 2024
101 checks passed
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.

2 participants