Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
b29e2dca
Unverified
Commit
b29e2dca
authored
Feb 28, 2023
by
Sylvain Gugger
Committed by
GitHub
Feb 28, 2023
Browse files
Fix flaky test for log level (#21776)
* Fix flaky test for log level * Fix other flaky test
parent
acfb714b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
tests/trainer/test_trainer.py
tests/trainer/test_trainer.py
+6
-4
tests/utils/test_logging.py
tests/utils/test_logging.py
+1
-0
No files found.
tests/trainer/test_trainer.py
View file @
b29e2dca
...
...
@@ -1093,17 +1093,19 @@ class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon):
self
.
assertTrue
(
np
.
array_equal
(
2
*
expected
+
1
,
seen
[:
expected
.
shape
[
0
]]))
self
.
assertTrue
(
np
.
all
(
seen
[
expected
.
shape
[
0
]
:]
==
-
100
))
# FIXME: sgugger
@
unittest
.
skip
(
reason
=
"might be flaky after PR #21700. Skip for now."
)
def
test_log_level
(
self
):
# testing only --log_level (--log_level_replica requires multiple gpus and DDP and is tested elsewhere)
logger
=
logging
.
get_logger
()
log_info_string
=
"Running training"
# test with the default log_level - should be warning and thus not log on the main process
# test with the default log_level - should be the same as before and thus we test depending on is_info
is_info
=
logging
.
get_verbosity
()
<=
20
with
CaptureLogger
(
logger
)
as
cl
:
trainer
=
get_regression_trainer
()
trainer
.
train
()
if
is_info
:
self
.
assertIn
(
log_info_string
,
cl
.
out
)
else
:
self
.
assertNotIn
(
log_info_string
,
cl
.
out
)
# test with low log_level - lower than info
...
...
tests/utils/test_logging.py
View file @
b29e2dca
...
...
@@ -109,6 +109,7 @@ class HfArgumentParserTest(unittest.TestCase):
def
test_advisory_warnings
(
self
):
# testing `logger.warning_advice()`
transformers
.
utils
.
logging
.
_reset_library_root_logger
()
logger
=
logging
.
get_logger
(
"transformers.models.bart.tokenization_bart"
)
msg
=
"Testing 1, 2, 3"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment