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

Autograph "Failed to parse source code" error when using lambda in for loop #30149

Closed
ageron opened this issue Jun 25, 2019 · 5 comments
Closed
Assignees
Labels
comp:autograph Autograph related issues TF 2.0 Issues relating to TensorFlow 2.0 type:bug Bug

Comments

@ageron
Copy link
Contributor

ageron commented Jun 25, 2019

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
    Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
    MacOSX 10.13.6
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
    N/A
  • TensorFlow installed from (source or binary):
    binary
  • TensorFlow version (use command below):
    VERSION=2.0.0-dev20190625
    GIT_VERSION=v1.12.1-4885-g71241a6afd
  • Python version:
    3.6.8
  • Bazel version (if compiling from source):
    N/A
  • GCC/Compiler version (if compiling from source):
    N/A
  • CUDA/cuDNN version:
    N/A
  • GPU model and memory:
    N/A

Describe the current behavior
I get an autograph error when running the following code (see the full stacktrace below):

import tensorflow as tf
ds = tf.data.Dataset.range(10).window(5, shift=1, drop_remainder=True)
for window in ds.flat_map(lambda window: window.batch(5)):
    print(window.numpy())

The error is ValueError: Failed to parse source code of <function <lambda> at 0x11194c488>

Describe the expected behavior
Everything works fine when I define the dataset on the previous line like this:

import tensorflow as tf
ds = tf.data.Dataset.range(10).window(5, shift=1, drop_remainder=True)
ds = ds.flat_map(lambda window: window.batch(5))
for window in ds:
    print(window.numpy())

Code to reproduce the issue
See above.

Other info / logs
Full stack trace with AUTOGRAPH_VERBOSITY=10:

2019-06-25 22:24:13.172683: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-06-25 22:24:13.197405: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7fa5e8a657c0 executing computations on platform Host. Devices:
2019-06-25 22:24:13.197445: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): <undefined>, <undefined>
Converted call: <function <lambda> at 0x134b81488>
    args: (<_VariantDataset shapes: (), types: tf.int64>,)
    kwargs: {}

Not whitelisted: <method-wrapper '__call__' of function object at 0x134b81488>: default rule
Not whitelisted: <function <lambda> at 0x134b81488>: default rule
Entity <function <lambda> at 0x134b81488> is not cached for key <code object <lambda> at 0x13b5f7ed0, file "<ipython-input-1-8a83c4c9b193>", line 4> subkey (<tensorflow.python.autograph.core.converter.ConversionOptions object at 0x13b641588>, frozenset())
Converting <function <lambda> at 0x134b81488>
WARNING: Logging before flag parsing goes to stderr.
E0625 22:24:13.215670 140735810999168 ag_logging.py:133] Error converting <function <lambda> at 0x134b81488>
Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 78, in parse_entity
    return parse_str(source, preamble_len=len(future_features)), source
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 140, in parse_str
    module_node = gast.parse(src)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/gast/gast.py", line 240, in parse
    return ast_to_gast(_ast.parse(*args, **kwargs))
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 5
    for window in ds.flat_map(lambda window: window.batch(5)):
                                                             ^
SyntaxError: unexpected EOF while parsing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 118, in parse_entity
    return parse_str(source, preamble_len=len(future_features)), source
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 140, in parse_str
    module_node = gast.parse(src)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/gast/gast.py", line 240, in parse
    return ast_to_gast(_ast.parse(*args, **kwargs))
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 5
    for window in ds.flat_map(lambda window: window.batch(5)):
                                                             ^
SyntaxError: unexpected EOF while parsing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/api.py", line 635, in to_graph
    return conversion.convert(entity, program_ctx)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 322, in convert
    free_nonglobal_var_names)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 240, in _convert_with_cache
    entity, program_ctx)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 441, in convert_entity_to_ast
    nodes, name, entity_info = convert_func_to_ast(o, program_ctx)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 601, in convert_func_to_ast
    node, source = parser.parse_entity(f, future_features=future_features)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 123, in parse_entity
    ' source to:\n{}\nBut that did not work.'.format(source))
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 66, in raise_parse_failure
    '{}'.format(entity, source, comment))
ValueError: Failed to parse source code of <function <lambda> at 0x134b81488>, which Python reported as:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
If this is a lambda function, the error may be avoided by creating the lambda in a standalone statement. Tried to strip down the source to:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
But that did not work.
ERROR: Error converting <function <lambda> at 0x134b81488>
Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 78, in parse_entity
    return parse_str(source, preamble_len=len(future_features)), source
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 140, in parse_str
    module_node = gast.parse(src)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/gast/gast.py", line 240, in parse
    return ast_to_gast(_ast.parse(*args, **kwargs))
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 5
    for window in ds.flat_map(lambda window: window.batch(5)):
                                                             ^
SyntaxError: unexpected EOF while parsing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 118, in parse_entity
    return parse_str(source, preamble_len=len(future_features)), source
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 140, in parse_str
    module_node = gast.parse(src)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/gast/gast.py", line 240, in parse
    return ast_to_gast(_ast.parse(*args, **kwargs))
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 5
    for window in ds.flat_map(lambda window: window.batch(5)):
                                                             ^
SyntaxError: unexpected EOF while parsing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/api.py", line 635, in to_graph
    return conversion.convert(entity, program_ctx)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 322, in convert
    free_nonglobal_var_names)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 240, in _convert_with_cache
    entity, program_ctx)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 441, in convert_entity_to_ast
    nodes, name, entity_info = convert_func_to_ast(o, program_ctx)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 601, in convert_func_to_ast
    node, source = parser.parse_entity(f, future_features=future_features)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 123, in parse_entity
    ' source to:\n{}\nBut that did not work.'.format(source))
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 66, in raise_parse_failure
    '{}'.format(entity, source, comment))
ValueError: Failed to parse source code of <function <lambda> at 0x134b81488>, which Python reported as:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
If this is a lambda function, the error may be avoided by creating the lambda in a standalone statement. Tried to strip down the source to:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
But that did not work.
Error transforming entity <function <lambda> at 0x134b81488>
Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 78, in parse_entity
    return parse_str(source, preamble_len=len(future_features)), source
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 140, in parse_str
    module_node = gast.parse(src)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/gast/gast.py", line 240, in parse
    return ast_to_gast(_ast.parse(*args, **kwargs))
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 5
    for window in ds.flat_map(lambda window: window.batch(5)):
                                                             ^
SyntaxError: unexpected EOF while parsing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 118, in parse_entity
    return parse_str(source, preamble_len=len(future_features)), source
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 140, in parse_str
    module_node = gast.parse(src)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/gast/gast.py", line 240, in parse
    return ast_to_gast(_ast.parse(*args, **kwargs))
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 5
    for window in ds.flat_map(lambda window: window.batch(5)):
                                                             ^
SyntaxError: unexpected EOF while parsing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/api.py", line 635, in to_graph
    return conversion.convert(entity, program_ctx)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 322, in convert
    free_nonglobal_var_names)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 240, in _convert_with_cache
    entity, program_ctx)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 441, in convert_entity_to_ast
    nodes, name, entity_info = convert_func_to_ast(o, program_ctx)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 601, in convert_func_to_ast
    node, source = parser.parse_entity(f, future_features=future_features)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 123, in parse_entity
    ' source to:\n{}\nBut that did not work.'.format(source))
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/pyct/parser.py", line 66, in raise_parse_failure
    '{}'.format(entity, source, comment))
ValueError: Failed to parse source code of <function <lambda> at 0x134b81488>, which Python reported as:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
If this is a lambda function, the error may be avoided by creating the lambda in a standalone statement. Tried to strip down the source to:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
But that did not work.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/api.py", line 528, in converted_call
    experimental_optional_features=options.optional_features)
  File "/Users/ageron/miniconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/autograph/impl/api.py", line 639, in to_graph
    entity, e.__class__.__name__, str(e)))
tensorflow.python.autograph.impl.api.ConversionError: converting <function <lambda> at 0x134b81488>: ValueError: Failed to parse source code of <function <lambda> at 0x134b81488>, which Python reported as:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
If this is a lambda function, the error may be avoided by creating the lambda in a standalone statement. Tried to strip down the source to:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
But that did not work.
W0625 22:24:13.223130 140735810999168 ag_logging.py:146] Entity <function <lambda> at 0x134b81488> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <function <lambda> at 0x134b81488>: ValueError: Failed to parse source code of <function <lambda> at 0x134b81488>, which Python reported as:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
If this is a lambda function, the error may be avoided by creating the lambda in a standalone statement. Tried to strip down the source to:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
But that did not work.
WARNING: Entity <function <lambda> at 0x134b81488> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <function <lambda> at 0x134b81488>: ValueError: Failed to parse source code of <function <lambda> at 0x134b81488>, which Python reported as:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
If this is a lambda function, the error may be avoided by creating the lambda in a standalone statement. Tried to strip down the source to:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
for window in ds.flat_map(lambda window: window.batch(5)):
But that did not work.
2019-06-25 22:24:13.243343: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1541] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set.  If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU.  To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile.
[0 1 2 3 4]
[1 2 3 4 5]
[2 3 4 5 6]
[3 4 5 6 7]
[4 5 6 7 8]
[5 6 7 8 9]
@ravikyram ravikyram self-assigned this Jun 26, 2019
@ravikyram ravikyram added comp:autograph Autograph related issues type:bug Bug TF 2.0 Issues relating to TensorFlow 2.0 labels Jun 26, 2019
@ravikyram
Copy link
Contributor

I have reproduced the issue in Colab using TF VERSION=2.0.0-dev20190625.Thanks!

@mdanatg mdanatg self-assigned this Jun 26, 2019
@mdanatg
Copy link

mdanatg commented Jun 26, 2019

This is related to a limitation in Python's inspect.getsource, which can't always get the source code of lambda functions. Specifically, getsource returns the entire source code line, which isn't always well-formed Python code, as you could see from this example.

The workaround is to declare the lambda function on a single line, as the OP indicates.

Normally, the error message should describe that (albeit in more detail), but it should definitely suggest the workaround of declaring the lambda on a separate line - @ageron can you confirm that the error message included that guidance?

Related, we should remove the extraneous imports from the error message. The message should spell just:

ValueError: Failed to parse source code of <function <lambda> at 0x134b81488>, which Python reported as:
for window in ds.flat_map(lambda window: window.batch(5)):

@jvishnuvardhan jvishnuvardhan removed their assignment Jun 26, 2019
@ageron
Copy link
Contributor Author

ageron commented Jun 28, 2019

Yes, I can confirm that the message If this is a lambda function, the error may be avoided by creating the lambda in a standalone statement. was part of the (very long) error message. But it's neither at the beginning nor at the end, so it's easily overlooked. I would recommend shortening the error message (except when AUTOGRAPH_VERBOSITY=10), to something like this:

ValueError: Failed to parse source code of <function <lambda> at 0x134b81488>, which Python reported as:
for window in ds.flat_map(lambda window: window.batch(5)):
The error may be avoided by creating the lambda in a standalone statement.

Alternatively, isn't it possible to parse this line to extract the lambda? After all, it's right there. :)

@mdanatg
Copy link

mdanatg commented Jun 28, 2019

I agree - will simplify the error message.

Yes, we do attempt to parse the line, but in this case is it not well-formed Python code - in our example, it's a for loop without a body. One could imagine a partial parser which attempts to parse as much as possible of the code that is well-formed, but the Python parser doesn't know how to do that, and even then there may still be situations of ambiguity where the results would be incorrect.

A much more robust fix would be to fix the parser so that it records the exact extents of the lambda, with column numbers. Currently it only records the line number, which is the root of the problem.

@yifeif yifeif closed this as completed in 38df5d8 Jul 1, 2019
@tensorflow-bot
Copy link

tensorflow-bot bot commented Jul 1, 2019

Are you satisfied with the resolution of your issue?
Yes
No

WeichenXu123 added a commit to uber/petastorm that referenced this issue Apr 21, 2020
Currently, for some function, TF2 autograph will fail.
See
tensorflow/tensorflow#35765
tensorflow/tensorflow#30149
tensorflow/autograph#3

If autograph failed, the functions will be run eagerly and TF cannot optimize them. So we'd better address them.


## Manually test
~~~python
df1 = spark.range(100)
from petastorm.spark import make_spark_converter

# Set a cache directory on DBFS FUSE for intermediate data.
spark.conf.set("petastorm.spark.converter.parentCacheDirUrl", "file:///dbfs/ml/tmp/petastorm/QA/bugs/")
converter1 = make_spark_converter(df1)

with converter1.make_tf_dataset(num_epochs=1) as dataset:
  for batch in dataset:
    print(batch.id)
~~~

* Before
Output includes:
```
WARNING:tensorflow:AutoGraph could not transform <function _NamedtupleCache.get at 0x7f0bfbe6f200> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause: expected exactly one node node, found [<gast.gast.FunctionDef object at 0x7f0bfad5d050>, <gast.gast.Return object at 0x7f0bfad5d7d0>]
WARNING:tensorflow:AutoGraph could not transform <function make_petastorm_dataset.<locals>.<lambda> at 0x7f0bf8da03b0> and will run it as-is.
Cause: could not parse the source code:

            .map(lambda row: _set_shape_to_named_tuple(reader.schema, row, reader.batched_output))

This error may be avoided by creating the lambda in a standalone statement.
```

* After
The warnings listed above disappear.
tkakantousis pushed a commit to logicalclocks/petastorm that referenced this issue Sep 16, 2020
Currently, for some function, TF2 autograph will fail.
See
tensorflow/tensorflow#35765
tensorflow/tensorflow#30149
tensorflow/autograph#3

If autograph failed, the functions will be run eagerly and TF cannot optimize them. So we'd better address them.


## Manually test
~~~python
df1 = spark.range(100)
from petastorm.spark import make_spark_converter

# Set a cache directory on DBFS FUSE for intermediate data.
spark.conf.set("petastorm.spark.converter.parentCacheDirUrl", "file:///dbfs/ml/tmp/petastorm/QA/bugs/")
converter1 = make_spark_converter(df1)

with converter1.make_tf_dataset(num_epochs=1) as dataset:
  for batch in dataset:
    print(batch.id)
~~~

* Before
Output includes:
```
WARNING:tensorflow:AutoGraph could not transform <function _NamedtupleCache.get at 0x7f0bfbe6f200> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause: expected exactly one node node, found [<gast.gast.FunctionDef object at 0x7f0bfad5d050>, <gast.gast.Return object at 0x7f0bfad5d7d0>]
WARNING:tensorflow:AutoGraph could not transform <function make_petastorm_dataset.<locals>.<lambda> at 0x7f0bf8da03b0> and will run it as-is.
Cause: could not parse the source code:

            .map(lambda row: _set_shape_to_named_tuple(reader.schema, row, reader.batched_output))

This error may be avoided by creating the lambda in a standalone statement.
```

* After
The warnings listed above disappear.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:autograph Autograph related issues TF 2.0 Issues relating to TensorFlow 2.0 type:bug Bug
Projects
None yet
Development

No branches or pull requests

4 participants