Esempio n. 1
0
 def testProtoOptionsDefaultValuesRoundTrip(self):
     pb = dataset_options_pb2.Options()
     options = dataset_ops.Options()
     options._from_proto(pb)
     result = options._to_proto()
     expected_pb = dataset_options_pb2.Options()
     expected_pb.distribute_options.CopyFrom(
         dataset_options_pb2.DistributeOptions())
     expected_pb.optimization_options.CopyFrom(
         dataset_options_pb2.OptimizationOptions())
     expected_pb.threading_options.CopyFrom(
         dataset_options_pb2.ThreadingOptions())
     self.assertProtoEquals(expected_pb, result)
Esempio n. 2
0
 def _to_proto(self):
   pb = dataset_options_pb2.Options()
   if self.deterministic is not None:
     pb.deterministic = self.deterministic
   pb.distribute_options.CopyFrom(self.experimental_distribute._to_proto())  # pylint: disable=protected-access
   if self.experimental_external_state_policy is not None:
     pb.external_state_policy = (
         ExternalStatePolicy._to_proto(  # pylint: disable=protected-access
             self.experimental_external_state_policy))
   pb.optimization_options.CopyFrom(self.experimental_optimization._to_proto())  # pylint: disable=protected-access
   if self.experimental_slack is not None:
     pb.slack = self.experimental_slack
   pb.threading_options.CopyFrom(self.threading._to_proto())  # pylint: disable=protected-access
   return pb