From f2fabedbab053d5484f32bb72f16a3778a1c122b Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Wed, 27 Jan 2021 03:39:11 -0500 Subject: [PATCH] Setup logging with a stdout handler (#9816) --- examples/language-modeling/run_clm.py | 3 ++- examples/language-modeling/run_mlm.py | 3 ++- examples/language-modeling/run_mlm_wwm.py | 3 ++- examples/language-modeling/run_plm.py | 3 ++- examples/multiple-choice/run_swag.py | 3 ++- examples/question-answering/run_qa.py | 1 + examples/question-answering/run_qa_beam_search.py | 1 + examples/seq2seq/run_seq2seq.py | 3 ++- examples/text-classification/run_glue.py | 3 ++- examples/token-classification/run_ner.py | 3 ++- .../run_{{cookiecutter.example_shortcut}}.py | 3 ++- 11 files changed, 20 insertions(+), 9 deletions(-) diff --git a/examples/language-modeling/run_clm.py b/examples/language-modeling/run_clm.py index 57f8f3cd2d..bc3da2d586 100644 --- a/examples/language-modeling/run_clm.py +++ b/examples/language-modeling/run_clm.py @@ -179,8 +179,9 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", - level=logging.INFO if is_main_process(training_args.local_rank) else logging.WARN, + handlers=[logging.StreamHandler(sys.stdout)], ) + logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) # Log on each process the small summary: logger.warning( diff --git a/examples/language-modeling/run_mlm.py b/examples/language-modeling/run_mlm.py index bf72a09a30..d9e4302d95 100644 --- a/examples/language-modeling/run_mlm.py +++ b/examples/language-modeling/run_mlm.py @@ -190,8 +190,9 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", - level=logging.INFO if is_main_process(training_args.local_rank) else logging.WARN, + handlers=[logging.StreamHandler(sys.stdout)], ) + logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) # Log on each process the small summary: logger.warning( diff --git a/examples/language-modeling/run_mlm_wwm.py b/examples/language-modeling/run_mlm_wwm.py index ab80b25c3a..94f571ea64 100644 --- a/examples/language-modeling/run_mlm_wwm.py +++ b/examples/language-modeling/run_mlm_wwm.py @@ -203,8 +203,9 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", - level=logging.INFO if is_main_process(training_args.local_rank) else logging.WARN, + handlers=[logging.StreamHandler(sys.stdout)], ) + logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) # Log on each process the small summary: logger.warning( diff --git a/examples/language-modeling/run_plm.py b/examples/language-modeling/run_plm.py index 589b53ded2..f27303ca9f 100644 --- a/examples/language-modeling/run_plm.py +++ b/examples/language-modeling/run_plm.py @@ -187,8 +187,9 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", - level=logging.INFO if is_main_process(training_args.local_rank) else logging.WARN, + handlers=[logging.StreamHandler(sys.stdout)], ) + logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) # Log on each process the small summary: logger.warning( diff --git a/examples/multiple-choice/run_swag.py b/examples/multiple-choice/run_swag.py index 7726debc58..504f5f3c94 100644 --- a/examples/multiple-choice/run_swag.py +++ b/examples/multiple-choice/run_swag.py @@ -213,8 +213,9 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", - level=logging.INFO if is_main_process(training_args.local_rank) else logging.WARN, + handlers=[logging.StreamHandler(sys.stdout)], ) + logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) # Log on each process the small summary: logger.warning( diff --git a/examples/question-answering/run_qa.py b/examples/question-answering/run_qa.py index b87359642b..55f113de9a 100644 --- a/examples/question-answering/run_qa.py +++ b/examples/question-answering/run_qa.py @@ -188,6 +188,7 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", + handlers=[logging.StreamHandler(sys.stdout)], ) logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) diff --git a/examples/question-answering/run_qa_beam_search.py b/examples/question-answering/run_qa_beam_search.py index 92b77a7483..1bf8f9aa08 100644 --- a/examples/question-answering/run_qa_beam_search.py +++ b/examples/question-answering/run_qa_beam_search.py @@ -187,6 +187,7 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", + handlers=[logging.StreamHandler(sys.stdout)], ) logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) diff --git a/examples/seq2seq/run_seq2seq.py b/examples/seq2seq/run_seq2seq.py index e8a6faf6f6..c32e7c34db 100644 --- a/examples/seq2seq/run_seq2seq.py +++ b/examples/seq2seq/run_seq2seq.py @@ -244,8 +244,9 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", - level=logging.INFO if is_main_process(training_args.local_rank) else logging.WARN, + handlers=[logging.StreamHandler(sys.stdout)], ) + logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) # Log on each process the small summary: logger.warning( diff --git a/examples/text-classification/run_glue.py b/examples/text-classification/run_glue.py index 2ba141185d..d48d3cc103 100644 --- a/examples/text-classification/run_glue.py +++ b/examples/text-classification/run_glue.py @@ -180,8 +180,9 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", - level=logging.INFO if is_main_process(training_args.local_rank) else logging.WARN, + handlers=[logging.StreamHandler(sys.stdout)], ) + logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) # Log on each process the small summary: logger.warning( diff --git a/examples/token-classification/run_ner.py b/examples/token-classification/run_ner.py index 8079597bba..8c2d4d897d 100644 --- a/examples/token-classification/run_ner.py +++ b/examples/token-classification/run_ner.py @@ -173,8 +173,9 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", - level=logging.INFO if is_main_process(training_args.local_rank) else logging.WARN, + handlers=[logging.StreamHandler(sys.stdout)], ) + logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) # Log on each process the small summary: logger.warning( diff --git a/templates/adding_a_new_example_script/{{cookiecutter.directory_name}}/run_{{cookiecutter.example_shortcut}}.py b/templates/adding_a_new_example_script/{{cookiecutter.directory_name}}/run_{{cookiecutter.example_shortcut}}.py index 5857db4867..3d9d7c0529 100644 --- a/templates/adding_a_new_example_script/{{cookiecutter.directory_name}}/run_{{cookiecutter.example_shortcut}}.py +++ b/templates/adding_a_new_example_script/{{cookiecutter.directory_name}}/run_{{cookiecutter.example_shortcut}}.py @@ -188,8 +188,9 @@ def main(): logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", - level=logging.INFO if is_main_process(training_args.local_rank) else logging.WARN, + handlers=[logging.StreamHandler(sys.stdout)], ) + logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN) # Log on each process the small summary: logger.warning(