示例#1
0
 def test_show_mark_pcolls_computed_when_done(self):
     p = beam.Pipeline(ir.InteractiveRunner())
     # pylint: disable=range-builtin-not-iterating
     pcoll = p | 'Create' >> beam.Create(range(10))
     self.assertFalse(pcoll in ie.current_env().computed_pcollections)
     # The call of show marks pcoll computed.
     ib.show(pcoll)
     self.assertTrue(pcoll in ie.current_env().computed_pcollections)
示例#2
0
 def test_show_handles_iterable_of_pcolls(self, mocked_visualize):
     p = beam.Pipeline(ir.InteractiveRunner())
     # pylint: disable=range-builtin-not-iterating
     pcoll = p | 'Create' >> beam.Create(range(10))
     ie.current_env().mark_pcollection_computed([pcoll])
     ie.current_env()._is_in_ipython = True
     ie.current_env()._is_in_notebook = True
     ib.show([pcoll])
     mocked_visualize.assert_called_once()
示例#3
0
 def test_show_mark_pcolls_computed_when_done(self):
     p = beam.Pipeline(ir.InteractiveRunner())
     # pylint: disable=bad-option-value
     pcoll = p | 'Create' >> beam.Create(range(10))
     self.assertFalse(pcoll in ie.current_env().computed_pcollections)
     # The call of show marks pcoll computed.
     ib.watch(locals())
     ie.current_env().track_user_pipelines()
     ib.show(pcoll)
     self.assertTrue(pcoll in ie.current_env().computed_pcollections)
示例#4
0
 def test_show_handles_iterable_of_pcolls(self, mocked_visualize):
     p = beam.Pipeline(ir.InteractiveRunner())
     # pylint: disable=bad-option-value
     pcoll = p | 'Create' >> beam.Create(range(10))
     ib.watch(locals())
     ie.current_env().track_user_pipelines()
     ie.current_env().mark_pcollection_computed([pcoll])
     ie.current_env()._is_in_ipython = True
     ie.current_env()._is_in_notebook = True
     ib.show([pcoll])
     mocked_visualize.assert_called_once()
示例#5
0
 def test_show_always_watch_given_pcolls(self):
     p = beam.Pipeline(ir.InteractiveRunner())
     # pylint: disable=range-builtin-not-iterating
     pcoll = p | 'Create' >> beam.Create(range(10))
     # The pcoll is not watched since watch(locals()) is not explicitly called.
     self.assertFalse(
         pcoll in _get_watched_pcollections_with_variable_names())
     # The call of show watches pcoll.
     ib.show(pcoll)
     self.assertTrue(
         pcoll in _get_watched_pcollections_with_variable_names())
示例#6
0
  def test_show_handles_deferred_dataframes(self, mocked_visualize):
    p = beam.Pipeline(ir.InteractiveRunner())

    deferred = frames.convert.to_dataframe(p | beam.Create([Record(0, 0, 0)]))

    ib.watch(locals())
    ie.current_env().track_user_pipelines()
    ie.current_env()._is_in_ipython = True
    ie.current_env()._is_in_notebook = True
    ib.show(deferred)
    mocked_visualize.assert_called_once()
示例#7
0
 def test_show_always_watch_given_pcolls(self):
   p = beam.Pipeline(ir.InteractiveRunner())
   # pylint: disable=bad-option-value
   pcoll = p | 'Create' >> beam.Create(range(10))
   # The pcoll is not watched since watch(locals()) is not explicitly called.
   self.assertFalse(pcoll in _get_watched_pcollections_with_variable_names())
   # The call of show watches pcoll.
   ib.watch({'p': p})
   ie.current_env().track_user_pipelines()
   ib.show(pcoll)
   self.assertTrue(pcoll in _get_watched_pcollections_with_variable_names())