Avoid root logger's level being changed (#28638)
* avoid root logger's level being changed --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -50,6 +50,7 @@ from transformers.testing_utils import (
|
||||
TOKEN,
|
||||
USER,
|
||||
CaptureLogger,
|
||||
LoggingLevel,
|
||||
TestCasePlus,
|
||||
backend_device_count,
|
||||
execute_subprocess_async,
|
||||
@@ -1290,17 +1291,19 @@ class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon):
|
||||
else:
|
||||
self.assertNotIn(log_info_string, cl.out)
|
||||
|
||||
# test with low log_level - lower than info
|
||||
with CaptureLogger(logger) as cl:
|
||||
trainer = get_regression_trainer(log_level="debug")
|
||||
trainer.train()
|
||||
self.assertIn(log_info_string, cl.out)
|
||||
with LoggingLevel(logging.INFO):
|
||||
# test with low log_level - lower than info
|
||||
with CaptureLogger(logger) as cl:
|
||||
trainer = get_regression_trainer(log_level="debug")
|
||||
trainer.train()
|
||||
self.assertIn(log_info_string, cl.out)
|
||||
|
||||
# test with high log_level - should be quiet
|
||||
with CaptureLogger(logger) as cl:
|
||||
trainer = get_regression_trainer(log_level="error")
|
||||
trainer.train()
|
||||
self.assertNotIn(log_info_string, cl.out)
|
||||
with LoggingLevel(logging.INFO):
|
||||
# test with high log_level - should be quiet
|
||||
with CaptureLogger(logger) as cl:
|
||||
trainer = get_regression_trainer(log_level="error")
|
||||
trainer.train()
|
||||
self.assertNotIn(log_info_string, cl.out)
|
||||
|
||||
def test_save_checkpoints(self):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
||||
Reference in New Issue
Block a user