# Path: tensorflow_transform/test_case.py
# def is_tf_api_version_1():
# def cross_named_parameters(*args):
#   def _cross_test_cases(parameters_list):
# def parameters(*testcases):
#   def wrapper(fn):
#     def to_arg_dict(testcase):
# def cross_parameters(*args):
# def _make_placeholder(tensor_spec):
# def _graph_function_handler(input_signature):
#   def wrapper(fn):
#     def _run_graph(*inputs):
# def _ragged_value_as_constant(value, dtype):
# def _wrap_as_constant(value, tensor_spec):
# def _eager_function_handler(input_signature):
#   def wrapper(fn):
#     def _run_eagerly(*inputs):  # pylint: disable=missing-docstring
# def _tf_function_function_handler(input_signature):
#   def wrapper(fn):
# def is_external_environment():
# def skip_if_external_environment(reason):
# def skip_if_not_tf2(reason):
# def cross_with_function_handlers(parameters_list):
#   def assertDataCloseOrEqual(self, a_data, b_data):
#   def _assertValuesCloseOrEqual(self, a_value, b_value, msg=None):
#   def AssertVocabularyContents(self, vocab_file_path, file_contents):
#   def WriteRenderedDotFile(self, dot_string, output_file=None):
#   def _NumpyArraysToLists(self, maybe_arrays):
#   def _SortedDicts(self, list_of_dicts):
#   def _SortedData(self, list_of_dicts_of_arrays):
# FUNCTION_HANDLERS = [
#     dict(testcase_name='graph',
#          function_handler=_graph_function_handler),
#     dict(testcase_name='eager',
#          function_handler=_eager_function_handler),
#     dict(testcase_name='tf_function',
#          function_handler=_tf_function_function_handler)
# ]
# class TransformTestCase(parameterized.TestCase, tf.test.TestCase):


import os
import shutil
import tensorflow as tf
import tensorflow_transform as tft
import sentiment_example
import local_model_server
from tensorflow_transform import test_case



class SentimentExampleTest(test_case.TransformTestCase):

  def testSentimentExampleAccuracy(self):
    raw_data_dir = os.path.join(os.path.dirname(__file__), 'testdata/sentiment')
    working_dir = self.get_temp_dir()

    # Copy data from raw data directory to `working_dir`
    try:
      for filename in ['test_shuffled-00000-of-00001',
                       'train_shuffled-00000-of-00001']:
        shutil.copy(os.path.join(raw_data_dir, filename), working_dir)
    except FileNotFoundError:
      # We only use a small sample of the data for testing purposes.
      train_neg_filepattern = os.path.join(raw_data_dir, 'train/neg/10000*')
      train_pos_filepattern = os.path.join(raw_data_dir, 'train/pos/10000*')
      test_neg_filepattern = os.path.join(raw_data_dir, 'test/neg/10000*')
      test_pos_filepattern = os.path.join(raw_data_dir, 'test/pos/10000*')

      # Writes the shuffled data under working_dir in TFRecord format.
      sentiment_example.read_and_shuffle_data(train_neg_filepattern,
                                              train_pos_filepattern,
                                              test_neg_filepattern,
                                              test_pos_filepattern, working_dir)

    sentiment_example.transform_data(working_dir)
    results = sentiment_example.train_and_evaluate(
        working_dir, num_train_instances=1000, num_test_instances=1000)

# Path: tensorflow_transform/test_case.py
# def is_tf_api_version_1():
# def cross_named_parameters(*args):
#   def _cross_test_cases(parameters_list):
# def parameters(*testcases):
#   def wrapper(fn):
#     def to_arg_dict(testcase):
# def cross_parameters(*args):
# def _make_placeholder(tensor_spec):
# def _graph_function_handler(input_signature):
#   def wrapper(fn):
#     def _run_graph(*inputs):
# def _ragged_value_as_constant(value, dtype):
# def _wrap_as_constant(value, tensor_spec):
# def _eager_function_handler(input_signature):
#   def wrapper(fn):
#     def _run_eagerly(*inputs):  # pylint: disable=missing-docstring
# def _tf_function_function_handler(input_signature):
#   def wrapper(fn):
# def is_external_environment():
# def skip_if_external_environment(reason):
# def skip_if_not_tf2(reason):
# def cross_with_function_handlers(parameters_list):
#   def assertDataCloseOrEqual(self, a_data, b_data):
#   def _assertValuesCloseOrEqual(self, a_value, b_value, msg=None):
#   def AssertVocabularyContents(self, vocab_file_path, file_contents):
#   def WriteRenderedDotFile(self, dot_string, output_file=None):
#   def _NumpyArraysToLists(self, maybe_arrays):
#   def _SortedDicts(self, list_of_dicts):
#   def _SortedData(self, list_of_dicts_of_arrays):
# FUNCTION_HANDLERS = [
#     dict(testcase_name='graph',
#          function_handler=_graph_function_handler),
#     dict(testcase_name='eager',
#          function_handler=_eager_function_handler),
#     dict(testcase_name='tf_function',
#          function_handler=_tf_function_function_handler)
# ]
# class TransformTestCase(parameterized.TestCase, tf.test.TestCase):


# Path: examples/sentiment_example_test.py
import os
import shutil
import tensorflow as tf
import tensorflow_transform as tft
import sentiment_example
import local_model_server
from tensorflow_transform import test_case




class SentimentExampleTest(test_case.TransformTestCase):

  def testSentimentExampleAccuracy(self):
    raw_data_dir = os.path.join(os.path.dirname(__file__), 'testdata/sentiment')
    working_dir = self.get_temp_dir()

    # Copy data from raw data directory to `working_dir`
    try:
      for filename in ['test_shuffled-00000-of-00001',
                       'train_shuffled-00000-of-00001']:
        shutil.copy(os.path.join(raw_data_dir, filename), working_dir)
    except FileNotFoundError:
      # We only use a small sample of the data for testing purposes.
      train_neg_filepattern = os.path.join(raw_data_dir, 'train/neg/10000*')
      train_pos_filepattern = os.path.join(raw_data_dir, 'train/pos/10000*')
      test_neg_filepattern = os.path.join(raw_data_dir, 'test/neg/10000*')
      test_pos_filepattern = os.path.join(raw_data_dir, 'test/pos/10000*')

      # Writes the shuffled data under working_dir in TFRecord format.
      sentiment_example.read_and_shuffle_data(train_neg_filepattern,
                                              train_pos_filepattern,
                                              test_neg_filepattern,
                                              test_pos_filepattern, working_dir)

    sentiment_example.transform_data(working_dir)
    results = sentiment_example.train_and_evaluate(
        working_dir, num_train_instances=1000, num_test_instances=1000)

    if not test_case.is_external_environment():