mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-03 03:31:05 +06:00
Multi-line examples can be tested + ALBERT patch for CircleCI
All tests should now work fine.
This commit is contained in:
parent
837577256b
commit
64abd3e0aa
@ -79,6 +79,7 @@ class AlbertConfig(PretrainedConfig):
|
||||
|
||||
Example::
|
||||
|
||||
from transformers import AlbertConfig, AlbertModel
|
||||
# Initializing an ALBERT-xxlarge style configuration
|
||||
albert_xxlarge_configuration = AlbertConfig()
|
||||
|
||||
@ -90,7 +91,7 @@ class AlbertConfig(PretrainedConfig):
|
||||
)
|
||||
|
||||
# Initializing a model from the ALBERT-base style configuration
|
||||
model = AlbertModel(bert_base_configuration)
|
||||
model = AlbertModel(albert_xxlarge_configuration)
|
||||
|
||||
# Accessing the model configuration
|
||||
configuration = model.config
|
||||
|
@ -13,8 +13,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import unittest
|
||||
|
||||
|
||||
def get_examples_from_file(file):
|
||||
@ -37,7 +37,7 @@ def get_examples_from_file(file):
|
||||
example_mode = True
|
||||
example_indentation = line.lower().find("example::")
|
||||
|
||||
return examples
|
||||
return ['\n'.join(example) for example in examples]
|
||||
|
||||
|
||||
class TestCodeExamples(unittest.TestCase):
|
||||
@ -51,8 +51,7 @@ class TestCodeExamples(unittest.TestCase):
|
||||
print("Testing", configuration_file, str(len(examples)) + "/" + str(len(examples)))
|
||||
|
||||
def execute_example(code_example):
|
||||
for line in code_example:
|
||||
exec(line)
|
||||
exec(code_example)
|
||||
|
||||
with self.subTest(msg=configuration_file):
|
||||
[execute_example(code_example) for code_example in examples]
|
||||
|
Loading…
Reference in New Issue
Block a user