labtools/_src/config.py
def configure_logging(third_party_offset: int = 0, **offsets):
  """ Configure logging formatters and levels

  Configures logging formatters and levels for absl and third party libraries.
  Default logging levels for external libraries:

    | --------------- | --------------------------------------------|
    | `transformers`  | FLAGS.verbosity - third_party_verbosity - 1 |
    | `datasets`      | FLAGS.verbosity - third_party_verbosity - 2 |

  Example:
    A verbosity of 0 (info) would result in a verbosity of warning for
    transformers and error for datasets.
  Args:
    third_party_offset: offset to add to all third party verbosity levels. For
      example, in a dristributied configuration, one could use a value of `0` on
      the main process and `1` on all other processes.
    **offset: offsets for third party libraries
  """
  import logging as py_logging
  import warnings

  from absl import logging
  from absl.flags import FLAGS
  from absl.logging.converter import absl_to_standard

  warnings.filterwarnings("ignore",
                          message='The given NumPy array is not writeable')

  logging.get_absl_handler().setFormatter(_logging_formatter())

  # default third party offsets
  default_offsets = {'transformers': 0, 'datasets': 1}
  offsets = {**default_offsets, **offsets}

  third_party_verbosity = FLAGS.verbosity - third_party_offset

  for name, offset in offsets.items():
    logger = py_logging.getLogger(name)
    # clip verbosity
    verbosity = max(third_party_verbosity - offset, logging.FATAL)
    logger.setLevel(absl_to_standard(verbosity))
    # apply format
    for handler in logger.handlers:
      handler.setFormatter(_logging_formatter())

  # ic only in debug if installed.
  if is_installed('icecream'):
    from icecream import ic
    if FLAGS.verbosity < 1:
      ic.disable()
    else:
      ic.configureOutput(includeContext=True)
 Configure logging formatters and levels

  Configures logging formatters and levels for absl and third party libraries.
  Default logging levels for external libraries:

    | --------------- | --------------------------------------------|
    | `transformers`  | FLAGS.verbosity - third_party_verbosity - 1 |
    | `datasets`      | FLAGS.verbosity - third_party_verbosity - 2 |

  Example:
    A verbosity of 0 (info) would result in a verbosity of warning for
    transformers and error for datasets.
  Args:
    third_party_offset: offset to add to all third party verbosity levels. For
      example, in a dristributied configuration, one could use a value of `0` on
      the main process and `1` on all other processes.
    **offset: offsets for third party libraries
  
Configure logging formatters and levels
Configures logging formatters and levels for absl and third party libraries.
Default logging levels for external libraries.


Configure logging formatters and levels Configures logging formatters and levels for absl and third party libraries . Default logging levels for external libraries .
def configure_logging(third_party_offset: int = 0, **offsets):
  import logging as py_logging
  import warnings
  from absl import logging
  from absl.flags import FLAGS
  from absl.logging.converter import absl_to_standard
  warnings.filterwarnings("ignore",
                          message='The given NumPy array is not writeable')
  logging.get_absl_handler().setFormatter(_logging_formatter())
  default_offsets = {'transformers': 0, 'datasets': 1}
  offsets = {**default_offsets, **offsets}
  third_party_verbosity = FLAGS.verbosity - third_party_offset
  for name, offset in offsets.items():
    logger = py_logging.getLogger(name)
    verbosity = max(third_party_verbosity - offset, logging.FATAL)
    logger.setLevel(absl_to_standard(verbosity))
    for handler in logger.handlers:
      handler.setFormatter(_logging_formatter())
  if is_installed('icecream'):
    from icecream import ic
    if FLAGS.verbosity < 1:
      ic.disable()
    else:
      ic.configureOutput(includeContext=True)
def configure_logging ( third_party_offset : int = 0 , ** offsets ) : import logging as py_logging import warnings from absl import logging from absl . flags import FLAGS from absl . logging . converter import absl_to_standard warnings . filterwarnings ( "ignore" , message = 'The given NumPy array is not writeable' ) logging . get_absl_handler ( ) . setFormatter ( _logging_formatter ( ) ) default_offsets = { 'transformers' : 0 , 'datasets' : 1 } offsets = { ** default_offsets , ** offsets } third_party_verbosity = FLAGS . verbosity - third_party_offset for name , offset in offsets . items ( ) : logger = py_logging . getLogger ( name ) verbosity = max ( third_party_verbosity - offset , logging . FATAL ) logger . setLevel ( absl_to_standard ( verbosity ) ) for handler in logger . handlers : handler . setFormatter ( _logging_formatter ( ) ) if is_installed ( 'icecream' ) : from icecream import ic if FLAGS . verbosity < 1 : ic . disable ( ) else : ic . configureOutput ( includeContext = True )
Configure logging formatters and levels
Configures logging formatters and levels for absl and third party libraries.
Configure logging formatters and levels Configures logging formatters and levels for absl and third party libraries .
""" Configure logging formatters and levels

  Configures logging formatters and levels for absl and third party libraries.
  Default logging levels for external libraries:

    | --------------- | --------------------------------------------|
    | `transformers`  | FLAGS.verbosity - third_party_verbosity - 1 |
    | `datasets`      | FLAGS.verbosity - third_party_verbosity - 2 |

  Example:
    A verbosity of 0 (info) would result in a verbosity of warning for
    transformers and error for datasets.
  Args:
    third_party_offset: offset to add to all third party verbosity levels. For
      example, in a dristributied configuration, one could use a value of `0` on
      the main process and `1` on all other processes.
    **offset: offsets for third party libraries
  """ # default third party offsets # clip verbosity # apply format # ic only in debug if installed.
third_party_offset
int
offset to add to all third party verbosity levels. For
example, in a dristributied configuration, one could use a value of `0` on
the main process and `1` on all other processes.
offset to add to all third party verbosity levels . For example in a dristributied configuration one could use a value of ` 0 ` on the main process and ` 1 ` on all other processes .
**offset
offsets for third party libraries
offsets for third party libraries
examples
A verbosity of 0 (info) would result in a verbosity of warning for
transformers and error for datasets.
A verbosity of 0 ( info ) would result in a verbosity of warning for transformers and error for datasets .