Skip to content

Commit

Permalink
[logging] Add centralized logging - Bump-up cache loads to warnings (h…
Browse files Browse the repository at this point in the history
…uggingface#538)

* add centralized logging - Bump-up cache loads to warnings

* add logging in the doc

* fix following Q's comments
  • Loading branch information
thomwolf authored Aug 31, 2020
1 parent 00a1524 commit dc64a7d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
50 changes: 50 additions & 0 deletions docs/source/package_reference/logging_methods.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Logging methods
----------------------------------------------------

`nlp` tries to be very transparent and explicit about it's inner working bt this can be quite verbose at some time.
A series of logging methods let you easily adjust the level of logging of the whole library.

Functions
~~~~~~~~~~~~~~~~~~~~~

.. autofunction:: nlp.logging.get_verbosity

.. autofunction:: nlp.logging.set_verbosity

.. autofunction:: nlp.logging.set_verbosity_info

.. autofunction:: nlp.logging.set_verbosity_warning

.. autofunction:: nlp.logging.set_verbosity_debug

.. autofunction:: nlp.logging.set_verbosity_error

.. autofunction:: nlp.logging.disable_default_handler

.. autofunction:: nlp.logging.enable_default_handler

.. autofunction:: nlp.logging.disable_propagation

.. autofunction:: nlp.logging.enable_propagation

.. autofunction:: nlp.logging.get_logger

Levels
~~~~~~~~~~~~~~~~~~~~~

.. autodata:: nlp.logging.CRITICAL

.. autodata:: nlp.logging.DEBUG

.. autodata:: nlp.logging.ERROR

.. autodata:: nlp.logging.FATAL

.. autodata:: nlp.logging.INFO

.. autodata:: nlp.logging.NOTSET

.. autodata:: nlp.logging.WARN

.. autodata:: nlp.logging.WARNING

4 changes: 2 additions & 2 deletions metrics/bleurt/bleurt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
# limitations under the License.
""" BLEURT metric. """

import logging
import os

import nlp
from nlp.logging import get_logger
from bleurt import score # From: git+https://github.com/google-research/bleurt.git


logger = logging.getLogger(__name__)
logger = get_logger(__name__)

_CITATION = """\
@inproceedings{bleurt,
Expand Down
4 changes: 0 additions & 4 deletions tests/test_metric_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import glob
import inspect
import logging
import tempfile

from absl.testing import parameterized
Expand All @@ -25,9 +24,6 @@
from .utils import aws, local, slow


logging.basicConfig(level=logging.INFO)


def get_aws_metric_names():
api = hf_api.HfApi()
# fetch all metric names
Expand Down

0 comments on commit dc64a7d

Please sign in to comment.