Repository: piskvorky/gensim

Issue:
Missplaced logging
Running the `segment_wiki.py` scripts prints:

```bash
$ time python -m gensim.scripts.segment_wiki -f /data_hdd/wiki/enwiki-latest-pages-articles.xml.bz2 -o /data_hdd/wiki/enwiki-latest.json.gz

No handlers could be found for logger "gensim.models.doc2vec"

2017-11-10 22:21:25,334 : MainProcess : INFO : running /home/radim/workspace/gensim/gensim/scripts/segment_wiki.py -f /data_hdd/wiki/enwiki-latest-pages-articles.xml.bz2 -o /data_hdd/wiki/enwiki-latest.json.gz
2017-11-10 22:24:40,174 : MainProcess : INFO : Processed #100000 articles
```

which is a bug. The doc2vec module should not log anything on import -- it should behave the same as word2vec, or any other gensim module.


Discussion:
@piskvorky @menshikh-iv would you want the logs to simply be removed or be relocated? I suspect these are the [lines](https://github.com/RaRe-Technologies/gensim/blob/74dae4ddc2de36b8e656382410ad75ee747374c4/gensim/models/doc2vec.py#L75) causing the issue?
@pranaydeep-af I don't think that problem in this line.
Logging messages should stay as is, but we don't want to see this message when we import something - `No handlers could be found for logger "...."`
@menshikh-iv I think logging in doc2vec outside any function is the cause of the error. As soon as the user imports the doc2vec file, the logs are executed. In contrast to other modules like word2vec where logging is done only after the import and during object creation. Here are the corresponding [lines](https://github.com/RaRe-Technologies/gensim/blob/74dae4ddc2de36b8e656382410ad75ee747374c4/gensim/models/word2vec.py#L513) in word2vec. 
I may be wildly wrong. But I feel this is the cause.
@pranaydeep-af  you can check it easily (reproduce original problem, remove this lines & try to reproduce again)
Same stuff for `fasttext` - `No handlers could be found for logger "gensim.models.fasttext"`.

Because this happens more than one time, it will be nice, if we can add a test that checks output when we import something.
@menshikh-iv Commenting out lines [1](https://github.com/RaRe-Technologies/gensim/blob/09672b369b2ec94a06581efd060be20662d7006c/gensim/models/doc2vec.py#L75l) and [2](https://github.com/RaRe-Technologies/gensim/blob/09672b369b2ec94a06581efd060be20662d7006c/gensim/models/doc2vec.py#L77) removes the issue for doc2vec. Also commenting out the corresponding lines from the fasttext module removes the issue for fasttext too.
Should I relocate the logs to a more similar structure as in word2vec and other modules?
@pranaydeep-af yes

Resolving patch:
diff --git a/gensim/models/doc2vec.py b/gensim/models/doc2vec.py
--- a/gensim/models/doc2vec.py
+++ b/gensim/models/doc2vec.py
@@ -76,10 +76,8 @@
 try:
     from gensim.models.doc2vec_inner import train_document_dbow, train_document_dm, train_document_dm_concat
     from gensim.models.word2vec_inner import FAST_VERSION  # blas-adaptation shared from word2vec
-    logger.info("Using FAST VERSION=%d", FAST_VERSION)
 
 except ImportError:
-    logger.warning('Slow version of %s is being used', __name__)
     # failed... fall back to plain numpy (20-80x slower training than the above)
     FAST_VERSION = -1
 
diff --git a/gensim/models/fasttext.py b/gensim/models/fasttext.py
--- a/gensim/models/fasttext.py
+++ b/gensim/models/fasttext.py
@@ -48,11 +48,9 @@
 try:
     from gensim.models.fasttext_inner import train_batch_sg, train_batch_cbow
     from gensim.models.fasttext_inner import FAST_VERSION, MAX_WORDS_IN_BATCH
-    logger.info("Using FAST VERSION=%d", FAST_VERSION)
 
 except ImportError:
     # failed... fall back to plain numpy (20-80x slower training than the above)
-    logger.warning('Slow version of Fasttext is being used')
     FAST_VERSION = -1
     MAX_WORDS_IN_BATCH = 10000
 
diff --git a/gensim/models/word2vec.py b/gensim/models/word2vec.py
--- a/gensim/models/word2vec.py
+++ b/gensim/models/word2vec.py
@@ -138,7 +138,6 @@
     from gensim.models.word2vec_inner import train_batch_sg, train_batch_cbow
     from gensim.models.word2vec_inner import score_sentence_sg, score_sentence_cbow
     from gensim.models.word2vec_inner import FAST_VERSION, MAX_WORDS_IN_BATCH
-    logger.info("Using FAST VERSION=%d", FAST_VERSION)
 
 except ImportError:
     # failed... fall back to plain numpy (20-80x slower training than the above)


Test patch: