Created
February 6, 2019 18:00
-
-
Save mrdrozdov/e6bb6137e509561c725dc9541b283864 to your computer and use it in GitHub Desktop.
debug-allennlp.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
candidates = [ | |
'from allennlp.common.file_utils import cached_path', | |
'from allennlp.common.checks import ConfigurationError', | |
'from allennlp.common import Params', | |
'from allennlp.common.util import lazy_groups_of', | |
'from allennlp.modules.elmo_lstm import ElmoLstm', | |
'from allennlp.modules.highway import Highway', | |
'from allennlp.modules.scalar_mix import ScalarMix', | |
'from allennlp.nn.util import remove_sentence_boundaries, add_sentence_boundary_token_ids, get_device_of', | |
'from allennlp.data.token_indexers.elmo_indexer import ELMoCharacterMapper, ELMoTokenCharactersIndexer', | |
'from allennlp.data.dataset import Batch', | |
'from allennlp.data import Token, Vocabulary, Instance', | |
'from allennlp.data.fields import TextField', | |
] | |
template = """ | |
import logging | |
{} | |
logger = logging.getLogger('asdf') | |
logger.setLevel(logging.INFO) | |
# Also log to console. | |
ch = logging.StreamHandler() | |
ch.setLevel(logging.INFO) | |
# create formatter and add it to the handlers | |
formatter = logging.Formatter('notallennlp - %(message)s') | |
ch.setFormatter(formatter) | |
# add the handlers to the logger | |
logger.addHandler(ch) | |
logger.info('test') | |
""" | |
for i, x in enumerate(candidates): | |
path = './scripts/test-{:03}.py'.format(i) | |
with open(path, 'w') as f: | |
f.write(template.format(x)) | |
print('RUNNING:') | |
print(path) | |
print(x) | |
os.system('python {}'.format(path)) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment