Repository: flairNLP/flair

Issue:
Logging overwrite less sweeping
To be removed, once it is done: Please add the appropriate label to this ticket, e.g. feature or enhancement.

**Is your feature/enhancement request related to a problem? Please describe.**
When using flair in other applications, the fact that it disables existing logs in `__init__.py` can be detrimental. For instance when wrapping it up as a component in a tool like rasa_nlu, importing flair overrides all logging except its own, breaking functionality in rasa_nlu.

This is the [line that does so ](https://github.com/zalandoresearch/flair/blob/c2bb0d8776f25493a5b994dcd89a96f71ac175b8/flair/__init__.py#L13) and it was done on purpose to disable BERT logging in #282 .

**Describe the solution you'd like**
Ideally, the problem of disabling logging from certain known dependencies should be much more limited in scope. Importing flair as a package shouldn't disable all the other loggers. At a minimum, perhaps the logging could only *optionally* disable all existing logs



Discussion:
Also worth noting re: #282  it seems like the issue was solved upstream

https://github.com/huggingface/pytorch-pretrained-BERT/issues/117
Thanks for pointing this out! 

@tabergma could you take a look?

Resolving patch:
diff --git a/flair/__init__.py b/flair/__init__.py
--- a/flair/__init__.py
+++ b/flair/__init__.py
@@ -10,7 +10,7 @@
 
 logging.config.dictConfig({
     'version': 1,
-    'disable_existing_loggers': True,
+    'disable_existing_loggers': False,
     'formatters': {
         'standard': {
             'format': '%(asctime)-15s %(message)s'


Test patch:
diff --git a/tests/test_embeddings.py b/tests/test_embeddings.py
--- a/tests/test_embeddings.py
+++ b/tests/test_embeddings.py
@@ -1,8 +1,7 @@
 import pytest
-import os
 
-from flair.embeddings import WordEmbeddings, TokenEmbeddings, CharLMEmbeddings, StackedEmbeddings, \
-    DocumentLSTMEmbeddings, DocumentMeanEmbeddings, DocumentPoolEmbeddings
+from flair.embeddings import WordEmbeddings, TokenEmbeddings, StackedEmbeddings, DocumentLSTMEmbeddings, \
+    DocumentPoolEmbeddings, FlairEmbeddings
 
 from flair.data import Sentence
 
@@ -84,7 +83,7 @@ def test_loading_not_existing_embedding():
 
 def test_loading_not_existing_char_lm_embedding():
     with pytest.raises(ValueError):
-        CharLMEmbeddings('other')
+        FlairEmbeddings('other')
 
 
 @pytest.mark.integration
@@ -158,7 +157,7 @@ def init_document_embeddings():
     sentence: Sentence = Sentence(text)
 
     glove: TokenEmbeddings = WordEmbeddings('en-glove')
-    charlm: TokenEmbeddings = CharLMEmbeddings('news-forward-fast')
+    charlm: TokenEmbeddings = FlairEmbeddings('news-forward-fast')
 
     return sentence, glove, charlm
 
@@ -180,7 +179,7 @@ def load_and_apply_word_embeddings(emb_type: str):
 def load_and_apply_char_lm_embeddings(emb_type: str):
     text = 'I love Berlin.'
     sentence: Sentence = Sentence(text)
-    embeddings: TokenEmbeddings = CharLMEmbeddings(emb_type)
+    embeddings: TokenEmbeddings = FlairEmbeddings(emb_type)
     embeddings.embed(sentence)
 
     for token in sentence.tokens:
diff --git a/tests/test_visual.py b/tests/test_visual.py
--- a/tests/test_visual.py
+++ b/tests/test_visual.py
@@ -4,7 +4,7 @@
 
 from flair.visual import *
 from flair.data import Sentence
-from flair.embeddings import CharLMEmbeddings, StackedEmbeddings
+from flair.embeddings import FlairEmbeddings, StackedEmbeddings
 import numpy
 
 from flair.visual.manifold import Visualizer, tSNE
@@ -19,8 +19,8 @@ def test_visualize_word_emeddings(resources_path):
 
     sentences = [Sentence(x) for x in sentences]
 
-    charlm_embedding_forward = CharLMEmbeddings('news-forward')
-    charlm_embedding_backward = CharLMEmbeddings('news-backward')
+    charlm_embedding_forward = FlairEmbeddings('news-forward')
+    charlm_embedding_backward = FlairEmbeddings('news-backward')
 
     embeddings = StackedEmbeddings([charlm_embedding_backward, charlm_embedding_forward])
 
@@ -39,7 +39,7 @@ def test_visualize_word_emeddings(resources_path):
 
     sentences = [Sentence(x) for x in sentences]
 
-    charlm_embedding_forward = CharLMEmbeddings('news-forward')
+    charlm_embedding_forward = FlairEmbeddings('news-forward')
 
     visualizer = Visualizer()
     visualizer.visualize_char_emeddings(charlm_embedding_forward, sentences, str(resources_path / 'visual/sentence_embeddings.html'))
@@ -56,13 +56,13 @@ def test_visualize(resources_path):
 
     sentences = [Sentence(x) for x in sentences]
 
-    embeddings = CharLMEmbeddings('news-forward')
+    embeddings = FlairEmbeddings('news-forward')
 
     visualizer = Visualizer()
 
     X_forward = visualizer.prepare_char_embeddings(embeddings, sentences)
 
-    embeddings = CharLMEmbeddings('news-backward')
+    embeddings = FlairEmbeddings('news-backward')
 
     X_backward = visualizer.prepare_char_embeddings(embeddings, sentences)
 
@@ -83,7 +83,7 @@ def test_highlighter(resources_path):
     with (resources_path / 'visual/snippet.txt').open() as f:
         sentences = [x for x in f.read().split('\n') if x]
 
-    embeddings = CharLMEmbeddings('news-forward')
+    embeddings = FlairEmbeddings('news-forward')
 
     features = embeddings.lm.get_representation(sentences[0]).squeeze()