Skip to content

Commit 7fc95e9

Browse files
authored
refactor: info replaced with debug messages, nltk download muted (#1601)
1 parent 6887604 commit 7fc95e9

23 files changed

+59
-59
lines changed

deeppavlov/core/data/simple_vocab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def load(self):
109109
self.reset()
110110
if self.load_path:
111111
if self.load_path.is_file():
112-
log.info("[loading vocabulary from {}]".format(self.load_path))
112+
log.debug("[loading vocabulary from {}]".format(self.load_path))
113113
tokens, counts = [], []
114114
for ln in self.load_path.open('r', encoding='utf8'):
115115
token, cnt = self.load_line(ln)

deeppavlov/core/models/torch_model.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __init__(self, device: str = "gpu",
9999
# we need to switch to eval mode here because by default it's in `train` mode.
100100
# But in case of `interact/build_model` usage, we need to have model in eval mode.
101101
self.model.eval()
102-
log.info(f"Model was successfully initialized! Model summary:\n {self.model}")
102+
log.debug(f"Model was successfully initialized! Model summary:\n {self.model}")
103103

104104
def init_from_opt(self, model_func: str) -> None:
105105
"""Initialize from scratch `self.model` with the architecture built in `model_func` method of this class
@@ -150,22 +150,22 @@ def load(self, fname: Optional[str] = None, *args, **kwargs) -> None:
150150
model_func = getattr(self, self.opt.get("model_name", ""), None)
151151

152152
if self.load_path:
153-
log.info(f"Load path {self.load_path} is given.")
153+
log.debug(f"Load path {self.load_path} is given.")
154154
if isinstance(self.load_path, Path) and not self.load_path.parent.is_dir():
155155
raise ConfigError("Provided load path is incorrect!")
156156

157157
weights_path = Path(self.load_path.resolve())
158158
weights_path = weights_path.with_suffix(f".pth.tar")
159159
if weights_path.exists():
160-
log.info(f"Load path {weights_path} exists.")
161-
log.info(f"Initializing `{self.__class__.__name__}` from saved.")
160+
log.debug(f"Load path {weights_path} exists.")
161+
log.debug(f"Initializing `{self.__class__.__name__}` from saved.")
162162

163163
# firstly, initialize with random weights and previously saved parameters
164164
if model_func:
165165
self.init_from_opt(model_func)
166166

167167
# now load the weights, optimizer from saved
168-
log.info(f"Loading weights from {weights_path}.")
168+
log.debug(f"Loading weights from {weights_path}.")
169169
checkpoint = torch.load(weights_path, map_location=self.device)
170170
model_state = checkpoint["model_state_dict"]
171171
optimizer_state = checkpoint["optimizer_state_dict"]
@@ -181,10 +181,10 @@ def load(self, fname: Optional[str] = None, *args, **kwargs) -> None:
181181
self.optimizer.load_state_dict(optimizer_state)
182182
self.epochs_done = checkpoint.get("epochs_done", 0)
183183
elif model_func:
184-
log.info(f"Init from scratch. Load path {weights_path} does not exist.")
184+
log.debug(f"Init from scratch. Load path {weights_path} does not exist.")
185185
self.init_from_opt(model_func)
186186
elif model_func:
187-
log.info(f"Init from scratch. Load path {self.load_path} is not provided.")
187+
log.debug(f"Init from scratch. Load path {self.load_path} is not provided.")
188188
self.init_from_opt(model_func)
189189

190190
@overrides

deeppavlov/core/trainers/fit_trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(self, chainer_config: dict, *, batch_size: int = -1,
6363
max_test_batches: int = -1,
6464
**kwargs) -> None:
6565
if kwargs:
66-
log.info(f'{self.__class__.__name__} got additional init parameters {list(kwargs)} that will be ignored:')
66+
log.warning(f'{self.__class__.__name__} got additional init parameters {list(kwargs)} that will be ignored:')
6767
self.chainer_config = chainer_config
6868
self._chainer = Chainer(chainer_config['in'], chainer_config['out'], chainer_config.get('in_y'))
6969
self.batch_size = batch_size

deeppavlov/models/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
if not os.environ.get('DP_SKIP_NLTK_DOWNLOAD'):
2222
with RedirectedPrints():
23-
nltk.download('punkt')
24-
nltk.download('stopwords')
25-
nltk.download('perluniprops')
26-
nltk.download('nonbreaking_prefixes')
23+
nltk.download('punkt', quiet=True)
24+
nltk.download('stopwords', quiet=True)
25+
nltk.download('perluniprops', quiet=True)
26+
nltk.download('nonbreaking_prefixes', quiet=True)

deeppavlov/models/classifiers/cos_sim_classifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,5 @@ def save(self) -> None:
130130

131131
def load(self) -> None:
132132
"""Load classifier parameters"""
133-
logger.info("Loading faq_model from {}".format(self.load_path))
133+
logger.debug("Loading faq_model from {}".format(self.load_path))
134134
self.x_train_features, self.y_train = load_pickle(self.load_path)

deeppavlov/models/classifiers/re_bert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def get_hrt(self, sequence_output: Tensor, attention: Tensor, entity_pos: List)
156156

157157
def load(self) -> None:
158158
if self.pretrained_bert:
159-
log.info(f"From pretrained {self.pretrained_bert}.")
159+
log.debug(f"From pretrained {self.pretrained_bert}.")
160160
self.config = AutoConfig.from_pretrained(
161161
self.pretrained_bert, num_labels=self.n_classes, output_attentions=True, output_hidden_states=True
162162
)

deeppavlov/models/doc_retrieval/pop_ranker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class PopRanker(Component):
5757
def __init__(self, pop_dict_path: str, load_path: str, top_n: int = 3, active: bool = True,
5858
**kwargs) -> None:
5959
pop_dict_path = expand_path(pop_dict_path)
60-
logger.info(f"Reading popularity dictionary from {pop_dict_path}")
60+
logger.debug(f"Reading popularity dictionary from {pop_dict_path}")
6161
self.pop_dict = read_json(pop_dict_path)
6262
self.mean_pop = np.mean(list(self.pop_dict.values()))
6363
load_path = expand_path(load_path)
64-
logger.info(f"Loading popularity ranker from {load_path}")
64+
logger.debug(f"Loading popularity ranker from {load_path}")
6565
self.clf = joblib.load(load_path)
6666
self.top_n = top_n
6767
self.active = active

deeppavlov/models/embedders/fasttext_embedder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def load(self) -> None:
5050
"""
5151
Load fastText binary model from self.load_path
5252
"""
53-
log.info(f"[loading fastText embeddings from `{self.load_path}`]")
53+
log.debug(f"[loading fastText embeddings from `{self.load_path}`]")
5454
self.model = fasttext.load_model(str(self.load_path))
5555
self.dim = self.model.get_dimension()
5656

deeppavlov/models/kbqa/query_generator_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def get_entity_ids(self, entities: List[str], tags: List[str], question: str) ->
164164
try:
165165
el_output = self.entity_linker([entities], [tags], [[question]], [None], [None])
166166
except json.decoder.JSONDecodeError:
167-
log.info("not received output from entity linking")
167+
log.warning("not received output from entity linking")
168168
if el_output:
169169
if self.use_el_api_requester:
170170
el_output = el_output[0]
@@ -262,7 +262,7 @@ def find_top_rels(self, question: str, entity_ids: List[List[str]], triplet_info
262262
try:
263263
ex_rels = self.wiki_parser(parser_info_list, queries_list)
264264
except json.decoder.JSONDecodeError:
265-
log.info("find_top_rels, not received output from wiki parser")
265+
log.warning("find_top_rels, not received output from wiki parser")
266266
if self.use_wp_api_requester and ex_rels:
267267
ex_rels = [rel[0] for rel in ex_rels]
268268
ex_rels = list(set(ex_rels))

deeppavlov/models/kbqa/rel_ranking_infer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def __call__(self, questions_list: List[str],
170170
try:
171171
answer = sentence_answer(question, answer, entities, template_answer)
172172
except:
173-
log.info("Error in sentence answer")
173+
log.warning("Error in sentence answer")
174174
confidence = answers_with_scores[0][2]
175175
if self.return_confidences:
176176
answers.append((answer, confidence))

0 commit comments

Comments
 (0)