Skip to content

Conversation

@thomwolf
Copy link
Member

@thomwolf thomwolf commented Aug 28, 2020

Add a nlp.logging module to set the global logging level easily. The verbosity level also controls the tqdm bars (disabled when set higher than INFO).

You can use:

nlp.logging.set_verbosity(verbosity: int)
nlp.logging.set_verbosity_info()
nlp.logging.set_verbosity_warning()
nlp.logging.set_verbosity_debug()
nlp.logging.set_verbosity_error()
nlp.logging.get_verbosity() -> int

And use the levels:

nlp.logging.CRITICAL
nlp.logging.DEBUG
nlp.logging.ERROR
nlp.logging.FATAL
nlp.logging.INFO
nlp.logging.NOTSET
nlp.logging.WARN
nlp.logging.WARNING

@thomwolf thomwolf requested a review from lhoestq August 31, 2020 08:05
Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition !

@@ -1 +1 @@
{"write_array2d": 0.07093274600629229, "read_unformated after write_array2d": 0.03530075500020757, "read_formatted_as_numpy after write_array2d": 0.10929270699853078, "read_batch_unformated after write_array2d": 0.03727920600795187, "read_batch_formatted_as_numpy after write_array2d": 0.018853643006877974, "read_col_unformated after write_array2d": 0.05644163000397384, "read_col_formatted_as_numpy after write_array2d": 0.011610292000113986, "write_nested_sequence": 1.6535991109994939, "read_unformated after write_nested_sequence": 0.3739209540071897, "read_formatted_as_numpy after write_nested_sequence": 0.40762836500653066, "read_batch_unformated after write_nested_sequence": 0.3337586460111197, "read_batch_formatted_as_numpy after write_nested_sequence": 0.054717567007173784, "read_col_unformated after write_nested_sequence": 0.3173944180016406, "read_col_formatted_as_numpy after write_nested_sequence": 0.004956340009812266, "write_flattened_sequence": 1.4975415869994322, "read_unformated after write_flattened_sequence": 0.26713552299770527, "read_formatted_as_numpy after write_flattened_sequence": 0.07673935199272819, "read_batch_unformated after write_flattened_sequence": 0.25450974798877724, "read_batch_formatted_as_numpy after write_flattened_sequence": 0.009374254994327202, "read_col_unformated after write_flattened_sequence": 0.25912448299641255, "read_col_formatted_as_numpy after write_flattened_sequence": 0.004277604995877482}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these files supposed to be part of the PR ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't care that much I guess but let me remove them indeed

if os.path.exists(indices_cache_file_name) and load_from_cache_file:
if verbose:
logger.info("Loading cached shuffled indices for dataset at %s", indices_cache_file_name)
logger.warn("Loading cached shuffled indices for dataset at %s", indices_cache_file_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use logger.warning instead ? iirc warn is deprecated

train_indices_cache_file_name,
test_indices_cache_file_name,
)
logger.warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

if os.path.exists(indices_cache_file_name) and load_from_cache_file:
if verbose:
logger.info("Loading cached sorted indices for dataset at %s", indices_cache_file_name)
logger.warn("Loading cached sorted indices for dataset at %s", indices_cache_file_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

if os.path.exists(cache_file_name) and load_from_cache_file:
if verbose:
logger.info("Loading cached processed dataset at %s", cache_file_name)
logger.warn("Loading cached processed dataset at %s", cache_file_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


def enable_propagation() -> None:
"""Enable propagation of the library log outputs.
Please disable the HuggingFace Transformers's default handler to prevent double logging if the root logger has
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would be the issue with transformers exactly ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy-past error

@thomwolf thomwolf merged commit df94a7c into master Aug 31, 2020
@thomwolf thomwolf deleted the logging branch August 31, 2020 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants