Add logging statement when EVALB is compiled.
-
from typing import List
+import logging
import os
import tempfile
import subprocess
@@ -11,6 +11,8 @@ from nltk import Tree
from allennlp.common.checks import ConfigurationError
from allennlp.training.metrics.metric import Metric
+logger = logging.getLogger(__name__) # pylint: disable=invalid-name
+
DEFAULT_EVALB_DIR = os.path.abspath(os.path.join(
os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, "tools", "EVALB"))
@@ -68,14 +70,15 @@ class EvalbBracketingScorer(Metric):
A list of gold NLTK Trees to use as a reference.
"""
if not os.path.exists(self._evalb_program_path):
- # Try compiling EVALB
+ logger.warning(f"EVALB not found at {self._evalb_program_path}. Attempting to compile it.")
EvalbBracketingScorer.compile_evalb()
# If EVALB executable still doesn't exist, raise an error.
if not os.path.exists(self._evalb_program_path):
compile_command = ("python -c 'from allennlp.training.metrics import EvalbBracketingScorer; "
"EvalbBracketingScorer.compile_evalb()'")
- raise ConfigurationError("You must compile the EVALB scorer before using it."
+ raise ConfigurationError(f"EVALB still not found at {self._evalb_program_path}. "
+ "You must compile the EVALB scorer before using it."
" Run 'make' in the '{}' directory or run: {}".format(
self._evalb_program_path, compile_command))
tempdir = tempfile.mkdtemp()
@@ -129,6 +132,7 @@ class EvalbBracketingScorer(Metric):
@staticmethod
def compile_evalb(evalb_directory_path: str = DEFAULT_EVALB_DIR):
+ logger.info(f"Compiling EVALB by running make in {evalb_directory_path}.")
os.system("cd {} && make && cd ../../../".format(evalb_directory_path))
@staticmethod
