# Path: px/environments/bidaf.py
# class BidafEnvironment(object):
#   def __init__(self,
#                data_dir,
#                shared_path,
#                model_dir,
#                docid_separator='###',
#                debug_mode=False,
#                load_test=False,
#                load_impossible_questions=False):
#   def _ReadImpossiblities(self, dataset, data_dir):
#   def _WordTokenize(self, text):
#   def _PreprocessQaData(self, questions, document_ids):
#   def IsImpossible(self, document_id):
#   def GetAnswers(self, questions, document_ids):
# 
# Path: px/environments/bidaf_server.py
# FLAGS = flags.FLAGS
# DOCID_SEPARATOR = '###'
# class BidafServer(aqa_pb2_grpc.EnvironmentServerServicer):
#   def __init__(self, *args, **kwargs):
#   def _InitializeEnvironment(self, data_dir, shared_file, model_dir, load_test,
#                              load_impossible_questions, debug_mode):
#   def GetObservations(self, request, context):
# def main(unused_argv):


import collections
import grpc
import mock
import portpicker
import unittest
from absl import logging
from grpc.framework.foundation import logging_pool
from tensorflow.python.util.protobuf import compare
from px.environments import bidaf
from px.environments import bidaf_server
from px.proto import aqa_pb2
from px.proto import aqa_pb2_grpc
          ('f1_scores', {
              document_ids[0]: F1_SCORE1,
              document_ids[1]: F1_SCORE2
          }),
          (document_ids[0], ANSWER1),
          (document_ids[1], ANSWER2)
      ])
      questions_dict = {
          document_ids[0]: {
              'rewrite': PROCESSED1,
              'raw_rewrite': QUESTION1
          },
          document_ids[1]: {
              'rewrite': PROCESSED2,
              'raw_rewrite': QUESTION2
          }
      }

    return answers_dict, questions_dict, 0


class BidafServerTest(unittest.TestCase):

  def setUp(self):
    with mock.patch.object(bidaf_server.BidafServer,
                           '_InitializeEnvironment') as mock_method:
      port = portpicker.pick_unused_port()
      server_pool = logging_pool.pool(max_workers=10)
      self._server = grpc.server(server_pool)
      self._server.add_insecure_port('[::]:{}'.format(port))

# Path: px/environments/bidaf.py
# class BidafEnvironment(object):
#   def __init__(self,
#                data_dir,
#                shared_path,
#                model_dir,
#                docid_separator='###',
#                debug_mode=False,
#                load_test=False,
#                load_impossible_questions=False):
#   def _ReadImpossiblities(self, dataset, data_dir):
#   def _WordTokenize(self, text):
#   def _PreprocessQaData(self, questions, document_ids):
#   def IsImpossible(self, document_id):
#   def GetAnswers(self, questions, document_ids):
# 
# Path: px/environments/bidaf_server.py
# FLAGS = flags.FLAGS
# DOCID_SEPARATOR = '###'
# class BidafServer(aqa_pb2_grpc.EnvironmentServerServicer):
#   def __init__(self, *args, **kwargs):
#   def _InitializeEnvironment(self, data_dir, shared_file, model_dir, load_test,
#                              load_impossible_questions, debug_mode):
#   def GetObservations(self, request, context):
# def main(unused_argv):


# Path: px/environments/bidaf_server_test.py
import collections
import grpc
import mock
import portpicker
import unittest
from absl import logging
from grpc.framework.foundation import logging_pool
from tensorflow.python.util.protobuf import compare
from px.environments import bidaf
from px.environments import bidaf_server
from px.proto import aqa_pb2
from px.proto import aqa_pb2_grpc

          ('f1_scores', {
              document_ids[0]: F1_SCORE1,
              document_ids[1]: F1_SCORE2
          }),
          (document_ids[0], ANSWER1),
          (document_ids[1], ANSWER2)
      ])
      questions_dict = {
          document_ids[0]: {
              'rewrite': PROCESSED1,
              'raw_rewrite': QUESTION1
          },
          document_ids[1]: {
              'rewrite': PROCESSED2,
              'raw_rewrite': QUESTION2
          }
      }

    return answers_dict, questions_dict, 0


class BidafServerTest(unittest.TestCase):

  def setUp(self):
    with mock.patch.object(bidaf_server.BidafServer,
                           '_InitializeEnvironment') as mock_method:
      port = portpicker.pick_unused_port()
      server_pool = logging_pool.pool(max_workers=10)
      self._server = grpc.server(server_pool)
      self._server.add_insecure_port('[::]:{}'.format(port))

      servicer = bidaf_server.BidafServer('BidafServer', 'test BiDAF server')