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

Feature gate for FlyteMissingReturnValueException #2623

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion flytekit/core/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import collections
import copy
import inspect
import sys
import typing
from collections import OrderedDict
from typing import Any, Dict, Generator, List, Optional, Tuple, Type, TypeVar, Union, cast
Expand Down Expand Up @@ -381,10 +382,12 @@ def transform_function_to_interface(fn: typing.Callable, docstring: Optional[Doc
return_annotation = type_hints.get("return", None)

ctx = FlyteContextManager.current_context()
# Only check if the task/workflow has a return statement at compile time locally.
if (
ctx.execution_state
# Only check if the task/workflow has a return statement at compile time locally.
and ctx.execution_state.mode is None
# inspec module does not work correctly with Python <3.10. https://github.com/flyteorg/flyte/issues/5608
pingsutw marked this conversation as resolved.
Show resolved Hide resolved
and sys.version_info >= (3, 10)
pingsutw marked this conversation as resolved.
Show resolved Hide resolved
and return_annotation
and type(None) not in get_args(return_annotation)
and return_annotation is not type(None)
Expand Down
23 changes: 23 additions & 0 deletions tests/flytekit/unit/core/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,29 @@ def one_output_wf() -> int: # type: ignore
one_output_wf()


def test_custom_wrapper():
def our_task(
_task_function: typing.Optional[typing.Callable] = None,
**kwargs,
):
def wrapped(_func: typing.Callable):
return task(_task_function=_func)

if _task_function:
return wrapped(_task_function)
else:
return wrapped

@our_task(
foo={
"bar1": lambda x: print(x),
"bar2": lambda x: print(x),
},
)
def missing_func_body() -> str:
return "foo"


def test_wf_no_output():
@task
def t1(a: int) -> int:
Expand Down
Loading