# Path: tensorflow_transform/tf_metadata/test_common.py
# def get_test_schema():
# 
# Path: tensorflow_transform/tf_metadata/dataset_metadata.py
# class DatasetMetadata:
#   def __init__(self, schema: schema_pb2.Schema):
#   def from_feature_spec(
#       cls: Type[_DatasetMetadataType],
#       feature_spec: Mapping[str, common_types.FeatureSpecType],
#       domains: Optional[Mapping[str, common_types.DomainType]] = None
#   ) -> _DatasetMetadataType:
#   def schema(self) -> schema_pb2.Schema:
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def __repr__(self):
# 
# Path: tensorflow_transform/tf_metadata/metadata_io.py
# def read_metadata(path):
# def _parse_schema_json(schema_json):
# def _column_schema_from_json(feature_dict):
# def _domain_from_json(domain):
#     def maybe_to_int(s):
# def _dtype_from_json(domain):
# def write_metadata(metadata, path):
# def _convert_scalar_or_list(fn, scalar_or_list):


import os
import tempfile
import unittest
from tensorflow_transform.tf_metadata import test_common
from tensorflow_transform.tf_metadata import dataset_metadata
from tensorflow_transform.tf_metadata import metadata_io
from tensorflow.python.lib.io import file_io  # pylint: disable=g-direct-tensorflow-import
    schema_no_sparse_features = """
    {
      "feature": [{
        "name": "my_key",
        "fixedShape": {
          "axis": [{
            "size": 2
          }]
        },
        "type": "INT",
        "domain": {
          "ints": {}
        },
        "parsingOptions": {
          "tfOptions": {
            "fixedLenFeature": {}
          }
        }
      }]
    }
    """
    self._write_schema_to_disk(basedir, schema_no_sparse_features)
    _ = metadata_io.read_metadata(basedir)

  def test_write_and_read(self):
    # TODO(b/123241798): use TEST_TMPDIR
    basedir = tempfile.mkdtemp()
    original = dataset_metadata.DatasetMetadata(
        schema=test_common.get_test_schema())


# Path: tensorflow_transform/tf_metadata/test_common.py
# def get_test_schema():
# 
# Path: tensorflow_transform/tf_metadata/dataset_metadata.py
# class DatasetMetadata:
#   def __init__(self, schema: schema_pb2.Schema):
#   def from_feature_spec(
#       cls: Type[_DatasetMetadataType],
#       feature_spec: Mapping[str, common_types.FeatureSpecType],
#       domains: Optional[Mapping[str, common_types.DomainType]] = None
#   ) -> _DatasetMetadataType:
#   def schema(self) -> schema_pb2.Schema:
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def __repr__(self):
# 
# Path: tensorflow_transform/tf_metadata/metadata_io.py
# def read_metadata(path):
# def _parse_schema_json(schema_json):
# def _column_schema_from_json(feature_dict):
# def _domain_from_json(domain):
#     def maybe_to_int(s):
# def _dtype_from_json(domain):
# def write_metadata(metadata, path):
# def _convert_scalar_or_list(fn, scalar_or_list):


# Path: tensorflow_transform/tf_metadata/metadata_io_test.py
import os
import tempfile
import unittest
from tensorflow_transform.tf_metadata import test_common
from tensorflow_transform.tf_metadata import dataset_metadata
from tensorflow_transform.tf_metadata import metadata_io
from tensorflow.python.lib.io import file_io  # pylint: disable=g-direct-tensorflow-import

    schema_no_sparse_features = """
    {
      "feature": [{
        "name": "my_key",
        "fixedShape": {
          "axis": [{
            "size": 2
          }]
        },
        "type": "INT",
        "domain": {
          "ints": {}
        },
        "parsingOptions": {
          "tfOptions": {
            "fixedLenFeature": {}
          }
        }
      }]
    }
    """
    self._write_schema_to_disk(basedir, schema_no_sparse_features)
    _ = metadata_io.read_metadata(basedir)

  def test_write_and_read(self):
    # TODO(b/123241798): use TEST_TMPDIR
    basedir = tempfile.mkdtemp()
    original = dataset_metadata.DatasetMetadata(
        schema=test_common.get_test_schema())


    metadata_io.write_metadata(original, basedir)