示例#1
0
文件: utils_test.py 项目: mszb/beam
    def test_cacheables(self):
        p2 = beam.Pipeline()
        pcoll2 = p2 | beam.Create([2])
        ib.watch({'p2': p2, 'pcoll2': pcoll2})

        cacheables = utils.cacheables()
        cacheable_key = Cacheable.from_pcoll('pcoll2', pcoll2).to_key()
        self.assertIn(cacheable_key, cacheables)
示例#2
0
文件: utils.py 项目: mszb/beam
def cacheables() -> Dict[CacheKey, Cacheable]:
  """Finds all Cacheables with their CacheKeys."""
  from apache_beam.runners.interactive import interactive_environment as ie

  inspectables = ie.current_env().inspector_with_synthetic.inspectables
  cacheables = {}
  for _, inspectable in inspectables.items():
    metadata = inspectable['metadata']
    if metadata['type'] == 'pcollection':
      cacheable = Cacheable.from_pcoll(metadata['name'], inspectable['value'])
      cacheables[cacheable.to_key()] = cacheable
  return cacheables