def _set_domain(name, feature, domain):
  """Set the domain of a Feature proto."""
  if domain is None:
    return

  if isinstance(domain, schema_pb2.IntDomain):
    feature.int_domain.CopyFrom(domain)
  elif isinstance(domain, schema_pb2.StringDomain):
    feature.string_domain.CopyFrom(domain)
  elif isinstance(domain, schema_pb2.FloatDomain):
    feature.float_domain.CopyFrom(domain)
  else:
    raise ValueError('Feature "{}" has invalid domain {}'.format(name, domain))
Set the domain of a Feature proto.
tensorflow_transform/tf_metadata/schema_utils.py