docstr: Creates a server running SEMPRE that we can send logical forms to for evaluation.  This
  uses inter-process communication, because SEMPRE is java code.  We also need to be careful
  to clean up the process when our program exits.
docstr_tok: ["Creates","a","server","running","SEMPRE","that","we","can","send","logical","forms","to","for","evaluation",".","This","uses","inter-process","communication",",","because","SEMPRE","is","java","code",".","We","also","need","to","be","careful","to","clean","up","the","process","when","our","program","exits","."]
code: def _create_sempre_executor(self):
      """
      Creates a server running SEMPRE that we can send logical forms to for evaluation.  This
      uses inter-process communication, because SEMPRE is java code.  We also need to be careful
      to clean up the process when our program exits.
      """
      if self._executor_process:
          return
  
      # It'd be much nicer to just use `cached_path` for these files.  However, the SEMPRE jar
      # that we're using expects to find these files in a particular location, so we need to make
      # sure we put the files in that location.
      os.makedirs(SEMPRE_DIR, exist_ok=True)
      abbreviations_path = os.path.join(SEMPRE_DIR, "abbreviations.tsv")
      if not os.path.exists(abbreviations_path):
          subprocess.run("wget {ABBREVIATIONS_FILE}", shell=True)
          subprocess.run(
              "mv wikitables-abbreviations.tsv {abbreviations_path}",
              shell=True,
          )
  
      grammar_path = os.path.join(SEMPRE_DIR, "grow.grammar")
      if not os.path.exists(grammar_path):
          subprocess.run("wget {GROW_FILE}", shell=True)
          subprocess.run(
              "mv wikitables-grow.grammar {grammar_path}", shell=True
          )
  
      args = [
          "java",
          "-jar",
          cached_path(SEMPRE_EXECUTOR_JAR),
          "serve",
          self._table_directory,
      ]
      self._executor_process = subprocess.Popen(
          args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1
      )
  
      lines = []
      for _ in range(6):
          # SEMPRE outputs six lines of stuff when it loads that I can't disable.  So, we clear
          # that here.
          lines.append(
              unicode(self._executor_process.stdout.readline())
          )
      assert (
          "Parser" in lines[-1]
      ), "SEMPRE server output unexpected; the server may have changed"
      logger.info("Started SEMPRE server for evaluating logical forms")
  
      # This is supposed to ensure that the subprocess gets killed when python exits.
      atexit.register(self._stop_sempre_executor)
  
file_path: magnitude/pymagnitude/third_party/allennlp/training/metrics/wikitables_accuracy.py
imports: from __future__ import division
  from __future__ import absolute_import
  import atexit
  import logging
  import os
  import pathlib
  import subprocess
  from allennlp.common.file_utils import cached_path
  from allennlp.training.metrics.metric import Metric
label_desc: Use image node_id 7 for calling the WikiTablesAccuracy obj's underlying member method code with example usage: obj._create_sempre_executor() without return types