Exemple #1
0
def write_schema_text(schema: schema_pb2.Schema, output_path: Text) -> None:
    """Writes input schema to a file in text format.

  Args:
    schema: A Schema protocol buffer.
    output_path: File path to write the input schema.

  Raises:
    TypeError: If the input schema is not of the expected type.
  """
    if not isinstance(schema, schema_pb2.Schema):
        raise TypeError('schema is of type %s, should be a Schema proto.' %
                        type(schema).__name__)

    schema_text = text_format.MessageToString(schema)
    io_util.write_string_to_file(output_path, schema_text)
def write_anomalies_text(anomalies: anomalies_pb2.Anomalies,
                         output_path: Text) -> None:
    """Writes the Anomalies proto to a file in text format.

  Args:
    anomalies: An Anomalies protocol buffer.
    output_path: File path to which to write the Anomalies proto.

  Raises:
    TypeError: If the input Anomalies proto is not of the expected type.
  """
    if not isinstance(anomalies, anomalies_pb2.Anomalies):
        raise TypeError(
            'anomalies is of type %s; should be an Anomalies proto.' %
            type(anomalies).__name__)

    anomalies_text = text_format.MessageToString(anomalies)
    io_util.write_string_to_file(output_path, anomalies_text)
def write_stats_text(stats: statistics_pb2.DatasetFeatureStatisticsList,
                     output_path: Text) -> None:
    """Writes a DatasetFeatureStatisticsList proto to a file in text format.

  Args:
    stats: A DatasetFeatureStatisticsList proto.
    output_path: File path to write the DatasetFeatureStatisticsList proto.

  Raises:
    TypeError: If the input proto is not of the expected type.
  """
    if not isinstance(stats, statistics_pb2.DatasetFeatureStatisticsList):
        raise TypeError('stats is of type %s, should be a '
                        'DatasetFeatureStatisticsList proto.' %
                        type(stats).__name__)

    stats_proto_text = text_format.MessageToString(stats)
    io_util.write_string_to_file(output_path, stats_proto_text)