log#

class Logger(name: str | None = None)[source]#

Bases: object

Default logger in PaddleNLP

Parameters:

name (str) – Logger name, default is ‘PaddleNLP’

processing(msg: str, interval: float = 0.1)[source]#

Continuously print a progress bar with rotating special effects.

Parameters:
  • msg (str) – Message to be printed.

  • interval (float) – Rotation interval. Default to 0.1.

warning_once(*args, **kwargs)[source]#

This method is identical to logger.warning(), but will emit the warning with the same message only once

Note: The cache is for the function arguments, so 2 different callers using the same arguments will hit the cache. The assumption here is that all warning messages are unique across the code. If they aren’t then need to switch to another type of cache that includes the caller frame information in the hashing function.

class MetricsDumper(filename: str | None = None)[source]#

Bases: object

Default JSONDumper in PaddleNLP

Parameters:

name (str) – Logger name, default is ‘PaddleNLP’

append(data)[source]#

Append a JSON object to the queue for background writing.

Parameters:

data – The JSON object to append.

close()[source]#

Close the background process and ensure all data is written.