-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update core.py [If funnction do not return any thing then warning will be pop up] #28680
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1423,15 +1423,21 @@ def _check_fn_use_yield_and_return(fn): | |
source_code = _get_function_body_without_inners(fn) | ||
has_yield = False | ||
has_return = False | ||
if len(source_code)==0: | ||
return None | ||
for line in source_code.split("\n"): | ||
if line.lstrip().startswith("yield ") or line.lstrip().startswith( | ||
"yield("): | ||
has_yield = True | ||
if line.lstrip().startswith("return ") or line.lstrip().startswith( | ||
"return("): | ||
has_return = True | ||
if line.lstrip().startswith("return None"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warn could also be placed here instead, eliminating the need for the |
||
return None | ||
if has_yield and has_return: | ||
return True | ||
if not has_return and not has_yield: | ||
return None | ||
return False | ||
except Exception as e: | ||
_LOGGER.debug(str(e)) | ||
|
@@ -1484,8 +1490,13 @@ def __init__(self, fn, *args, **kwargs): | |
'Using yield and return in the process method ' | ||
'of %s can lead to unexpected behavior, see:' | ||
'https://github.com/apache/beam/issues/22969.', | ||
self.fn.__class__) | ||
self.fn.__class__) | ||
|
||
elif _check_fn_use_yield_and_return(self.fn.process) is None: | ||
_LOGGER.warning( | ||
'no iterator is returned by the process method in %s', | ||
self.fn.__class__) | ||
|
||
Comment on lines
+1495
to
+1499
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mechanically you probably don't want to re-run |
||
# Validate the DoFn by creating a DoFnSignature | ||
from apache_beam.runners.common import DoFnSignature | ||
self._signature = DoFnSignature(self.fn) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this check?