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
7bc00569
Unverified
Commit
7bc00569
authored
Aug 14, 2020
by
Kevin Canwen Xu
Committed by
GitHub
Aug 14, 2020
Browse files
Clean directory after script testing (#6453)
* Clean Dir after testing * remove pabee ignore
parent
e92efcf7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
examples/bert-loses-patience/test_run_glue_with_pabee.py
examples/bert-loses-patience/test_run_glue_with_pabee.py
+7
-1
examples/test_examples.py
examples/test_examples.py
+9
-0
No files found.
examples/bert-loses-patience/test_run_glue_with_pabee.py
View file @
7bc00569
import
argparse
import
argparse
import
logging
import
logging
import
shutil
import
sys
import
sys
import
unittest
import
unittest
from
unittest.mock
import
patch
from
unittest.mock
import
patch
...
@@ -19,8 +20,11 @@ def get_setup_file():
...
@@ -19,8 +20,11 @@ def get_setup_file():
return
args
.
f
return
args
.
f
def
clean_test_dir
(
path
=
"./tests/fixtures/tests_samples/temp_dir"
):
shutil
.
rmtree
(
path
,
ignore_errors
=
True
)
class
PabeeTests
(
unittest
.
TestCase
):
class
PabeeTests
(
unittest
.
TestCase
):
@
unittest
.
skip
(
"Disable while Canwen investigates."
)
def
test_run_glue
(
self
):
def
test_run_glue
(
self
):
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
logger
.
addHandler
(
stream_handler
)
logger
.
addHandler
(
stream_handler
)
...
@@ -47,3 +51,5 @@ class PabeeTests(unittest.TestCase):
...
@@ -47,3 +51,5 @@ class PabeeTests(unittest.TestCase):
result
=
run_glue_with_pabee
.
main
()
result
=
run_glue_with_pabee
.
main
()
for
value
in
result
.
values
():
for
value
in
result
.
values
():
self
.
assertGreaterEqual
(
value
,
0.75
)
self
.
assertGreaterEqual
(
value
,
0.75
)
clean_test_dir
()
examples/test_examples.py
View file @
7bc00569
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
import
argparse
import
argparse
import
logging
import
logging
import
os
import
os
import
shutil
import
sys
import
sys
import
unittest
import
unittest
from
unittest.mock
import
patch
from
unittest.mock
import
patch
...
@@ -51,6 +52,10 @@ def get_setup_file():
...
@@ -51,6 +52,10 @@ def get_setup_file():
return
args
.
f
return
args
.
f
def
clean_test_dir
(
path
=
"./tests/fixtures/tests_samples/temp_dir"
):
shutil
.
rmtree
(
path
,
ignore_errors
=
True
)
class
ExamplesTests
(
unittest
.
TestCase
):
class
ExamplesTests
(
unittest
.
TestCase
):
def
test_run_glue
(
self
):
def
test_run_glue
(
self
):
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
...
@@ -78,6 +83,7 @@ class ExamplesTests(unittest.TestCase):
...
@@ -78,6 +83,7 @@ class ExamplesTests(unittest.TestCase):
del
result
[
"eval_loss"
]
del
result
[
"eval_loss"
]
for
value
in
result
.
values
():
for
value
in
result
.
values
():
self
.
assertGreaterEqual
(
value
,
0.75
)
self
.
assertGreaterEqual
(
value
,
0.75
)
clean_test_dir
()
def
test_run_pl_glue
(
self
):
def
test_run_pl_glue
(
self
):
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
...
@@ -113,6 +119,7 @@ class ExamplesTests(unittest.TestCase):
...
@@ -113,6 +119,7 @@ class ExamplesTests(unittest.TestCase):
# for k, v in result.items():
# for k, v in result.items():
# self.assertGreaterEqual(v, 0.75, f"({k})")
# self.assertGreaterEqual(v, 0.75, f"({k})")
#
#
clean_test_dir
()
def
test_run_language_modeling
(
self
):
def
test_run_language_modeling
(
self
):
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
...
@@ -136,6 +143,7 @@ class ExamplesTests(unittest.TestCase):
...
@@ -136,6 +143,7 @@ class ExamplesTests(unittest.TestCase):
with
patch
.
object
(
sys
,
"argv"
,
testargs
):
with
patch
.
object
(
sys
,
"argv"
,
testargs
):
result
=
run_language_modeling
.
main
()
result
=
run_language_modeling
.
main
()
self
.
assertLess
(
result
[
"perplexity"
],
35
)
self
.
assertLess
(
result
[
"perplexity"
],
35
)
clean_test_dir
()
def
test_run_squad
(
self
):
def
test_run_squad
(
self
):
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
...
@@ -162,6 +170,7 @@ class ExamplesTests(unittest.TestCase):
...
@@ -162,6 +170,7 @@ class ExamplesTests(unittest.TestCase):
result
=
run_squad
.
main
()
result
=
run_squad
.
main
()
self
.
assertGreaterEqual
(
result
[
"f1"
],
25
)
self
.
assertGreaterEqual
(
result
[
"f1"
],
25
)
self
.
assertGreaterEqual
(
result
[
"exact"
],
21
)
self
.
assertGreaterEqual
(
result
[
"exact"
],
21
)
clean_test_dir
()
def
test_generation
(
self
):
def
test_generation
(
self
):
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
...
...
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