Esempio n. 1
0
 def test_basics_without_type_check(self):
   # Run the workflow without --pipeline_type_check option. This will make sure
   # the typehints associated with all transforms will have default values and
   # therefore any custom coders will not be used. The default coder (pickler)
   # will be used instead.
   temp_path = self.create_temp_file(self.SAMPLE_RECORDS)
   group_with_coder.run([
       '--no_pipeline_type_check',
       '--input=%s*' % temp_path,
       '--output=%s.result' % temp_path])
   # Parse result file and compare.
   results = []
   with open(temp_path + '.result') as result_file:
     for line in result_file:
       name, points = line.split(',')
       results.append((name, int(points)))
     logging.info('result: %s', results)
   self.assertEqual(
       sorted(results),
       sorted([('ann', 15), ('fred', 9), ('joe', 60), ('mary', 8)]))
Esempio n. 2
0
 def test_basics_with_type_check(self):
   # Run the workflow with --pipeline_type_check option. This will make sure
   # the typehints associated with all transforms will have non-default values
   # and therefore any custom coders will be used. In our case we want to make
   # sure the coder for the Player class will be used.
   temp_path = self.create_temp_file(self.SAMPLE_RECORDS)
   group_with_coder.run([
       '--pipeline_type_check',
       '--input=%s*' % temp_path,
       '--output=%s.result' % temp_path])
   # Parse result file and compare.
   results = []
   with open(temp_path + '.result') as result_file:
     for line in result_file:
       name, points = line.split(',')
       results.append((name, int(points)))
     logging.info('result: %s', results)
   self.assertEqual(
       sorted(results),
       sorted([('x:ann', 15), ('x:fred', 9), ('x:joe', 60), ('x:mary', 8)]))