David Yan created BEAM-7876:
-------------------------------
Summary: Interactive Beam example does not work with Python3
Key: BEAM-7876
URL: https://issues.apache.org/jira/browse/BEAM-7876
Project: Beam
Issue Type: Bug
Components: examples-python
Reporter: David Yan
When going through the example
[https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/interactive/README.md]
using Jupyter Notebook running in Python 3, the run() method throws an error:
TypeError Traceback (most recent call last)
<ipython-input-3-6b6671c6b2d0> in <module>
3 squares = init_pcoll | 'Square' >> beam.Map(lambda x: x*x)
4 cubes = init_pcoll | 'Cube' >> beam.Map(lambda x: x**3)
----> 5 result = p.run()
6 result.wait_until_finish()
~/beam/sdks/python/apache_beam/pipeline.py in run(self, test_runner_api)
404 self.to_runner_api(use_fake_coders=True),
405 self.runner,
--> 406 self._options).run(False)
407
408 if self._options.view_as(TypeOptions).runtime_type_check:
~/beam/sdks/python/apache_beam/pipeline.py in run(self, test_runner_api)
417 finally:
418 shutil.rmtree(tmpdir)
--> 419 return self.runner.run_pipeline(self, self._options)
420
421 def __enter__(self):
~/beam/sdks/python/apache_beam/runners/interactive/interactive_runner.py in
run_pipeline(self, pipeline, options)
142 cache_manager=self._cache_manager,
143 pipeline_graph_renderer=self._renderer)
--> 144 display.start_periodic_update()
145 result = pipeline_to_execute.run()
146 result.wait_until_finish()
~/beam/sdks/python/apache_beam/runners/interactive/display/display_manager.py
in start_periodic_update(self)
158 def start_periodic_update(self):
159 """Start a thread that periodically updates the display."""
--> 160 self.update_display(True)
161 self._periodic_update = True
162
~/beam/sdks/python/apache_beam/runners/interactive/display/display_manager.py
in update_display(self, force)
149 rendered_graph = self._renderer.render_pipeline_graph(
150 self._pipeline_graph)
--> 151 display.display(display.HTML(rendered_graph))
152
153 _display_progress('Running...')
~/beam/sdks/python/notebook3/lib/python3.6/site-packages/IPython/core/display.py
in __init__(self, data, url, filename, metadata)
691 return prefix.startswith("<iframe ") and suffix.endswith("</iframe>")
692
--> 693 if warn():
694 warnings.warn("Consider using IPython.display.IFrame instead")
695 super(HTML, self).__init__(data=data, url=url, filename=filename,
metadata=metadata)
~/beam/sdks/python/notebook3/lib/python3.6/site-packages/IPython/core/display.py
in warn()
689 prefix = data[:10].lower()
690 suffix = data[-10:].lower()
--> 691 return prefix.startswith("<iframe ") and suffix.endswith("</iframe>")
692
693 if warn():
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)