Repository: mindsdb/mindsdb

Issue:
Dependency and Import error
**Describe the bug**
I am getting this error during installation:
>ERROR: requests 2.21.0 has requirement urllib3<1.25,>=1.21.1, but you'll have 
urllib3 1.25.2 which is incompatible.

The installation completes complete but throws an error  when importing mindsdb
> Python 3.7.3 (default, Mar 26 2019, 21:43:19) 
>[GCC 8.2.1 20181127] on linux
>Type "help", "copyright", "credits" or "license" for more information.
>>import mindsdb
>/home/user/.venvs/mindsdb/lib/python3.7/site-packages/requests/__init__.py:91: >RequestsDependencyWarning: urllib3 (1.25.2) or chardet (3.0.4) doesn't match a supported >version! RequestsDependencyWarning)
>Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "/home/user/.venvs/mindsdb/lib/python3.7/site-packages/mindsdb/__init__.py", line 9, > in <module>
>    from mindsdb.libs.controllers.predictor import Predictor
>  File "/home/user/.venvs/mindsdb/lib/python3.7/site->packages/mindsdb/libs/controllers/predictor.py", line 14, in <module>
>    from mindsdb.libs.controllers.transaction import Transaction
>  File "/home/user/.venvs/mindsdb/lib/python3.7/site->packages/mindsdb/libs/controllers/transaction.py", line 7, in <module>
>    from mindsdb.libs.backends.ludwig import LudwigBackend
> File "/home/user/.venvs/mindsdb/lib/python3.7/site->packages/mindsdb/libs/backends/ludwig.py", >line 9, in <module>
>   from ludwig import LudwigModel
> ImportError: cannot import name 'LudwigModel' from 'ludwig' 
 >(/home/user/.venvs/mindsdb/lib/python3.7/site-packages/ludwig/__init__.py)

checked on requiremente text for  requests and urilib3 in requirment.txt and are met in my machine ![error](https://github.com/koyo-jakanees/codePrac/blob/master/media/images/mindsdb.png?raw=true)
**To Reproduce**
Steps to reproduce the behavior:
1. set up a venv 
2. pip3 install mindsdb --user
3.import mindsdb  
3. See error

**Expected behavior**
import mindsdb to work.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - Manjaro Linux
 -DISTRIB_ID=ManjaroLinux
 -DISTRIB_RELEASE=18.0.4
 -DISTRIB_CODENAME=Illyria
 -ID=manjaro
 -ID_LIKE=arch
hp laptop
core i3
cpu installation

**Additional context**
Works fine in conda env, 
issue arises on using  default python env


Discussion:

Resolving patch:
diff --git a/mindsdb/libs/backends/ludwig.py b/mindsdb/libs/backends/ludwig.py
--- a/mindsdb/libs/backends/ludwig.py
+++ b/mindsdb/libs/backends/ludwig.py
@@ -6,7 +6,7 @@
 from scipy.misc import imread
 import os, sys
 
-from ludwig import LudwigModel
+from ludwig.api import LudwigModel
 import pandas as pd
 
 # @TODO: Define generci interface, similar to 'base_module' in the phases
@@ -365,39 +365,39 @@ def train(self):
         if len(timeseries_cols) > 0:
             training_dataframe, model_definition =  self._translate_df_to_timeseries_format(training_dataframe, model_definition, timeseries_cols, 'train')
 
-        with disable_ludwig_output():
+        #with disable_ludwig_output():
 
-            model = LudwigModel(model_definition)
+        model = LudwigModel(model_definition)
 
-            # <---- Ludwig currently broken, since mode can't be initialized without train_set_metadata and train_set_metadata can't be obtained without running train... see this issue for any updates on the matter: https://github.com/uber/ludwig/issues/295
-            #model.initialize_model(train_set_metadata={})
-            #train_stats = model.train_online(data_df=training_dataframe) # ??Where to add model_name?? ----> model_name=self.transaction.lmd['name']
+        # <---- Ludwig currently broken, since mode can't be initialized without train_set_metadata and train_set_metadata can't be obtained without running train... see this issue for any updates on the matter: https://github.com/uber/ludwig/issues/295
+        #model.initialize_model(train_set_metadata={})
+        #train_stats = model.train_online(data_df=training_dataframe) # ??Where to add model_name?? ----> model_name=self.transaction.lmd['name']
 
-            if self.transaction.lmd['rebuild_model'] is True:
-                train_stats = model.train(data_df=training_dataframe, model_name=self.transaction.lmd['name'], skip_save_model=True)
+        if self.transaction.lmd['rebuild_model'] is True:
+            train_stats = model.train(data_df=training_dataframe, model_name=self.transaction.lmd['name'], skip_save_model=True)
+        else:
+            model = LudwigModel.load(self.transaction.lmd['ludwig_data']['ludwig_save_path'])
+            train_stats = model.train(data_df=training_dataframe, model_name=self.transaction.lmd['name'], skip_save_model=True)
+            #,model_load_path=self.transaction.lmd['ludwig_data']['ludwig_save_path'])
+
+        for k in train_stats['train']:
+            if k not in self.transaction.lmd['model_accuracy']['train']:
+                self.transaction.lmd['model_accuracy']['train'][k] = []
+                self.transaction.lmd['model_accuracy']['test'][k] = []
+            elif k is not 'combined':
+                # We should be adding the accuracy here but we only have it for combined, so, for now use that, will only affect multi-output scenarios anyway
+                pass
             else:
-                model = LudwigModel.load(self.transaction.lmd['ludwig_data']['ludwig_save_path'])
-                train_stats = model.train(data_df=training_dataframe, model_name=self.transaction.lmd['name'], skip_save_model=True)
-                #,model_load_path=self.transaction.lmd['ludwig_data']['ludwig_save_path'])
-
-            for k in train_stats['train']:
-                if k not in self.transaction.lmd['model_accuracy']['train']:
-                    self.transaction.lmd['model_accuracy']['train'][k] = []
-                    self.transaction.lmd['model_accuracy']['test'][k] = []
-                elif k is not 'combined':
-                    # We should be adding the accuracy here but we only have it for combined, so, for now use that, will only affect multi-output scenarios anyway
-                    pass
-                else:
-                    self.transaction.lmd['model_accuracy']['train'][k].extend(train_stats['train'][k]['accuracy'])
-                    self.transaction.lmd['model_accuracy']['test'][k].extend(train_stats['test'][k]['accuracy'])
-
-                '''
-                @ TRAIN ONLINE BIT That's not working
-                model = LudwigModel.load(self.transaction.lmd['ludwig_data']['ludwig_save_path'])
-                for i in range(0,100):
-                    train_stats = model.train_online(data_df=training_dataframe)
-                    # The resulting train_stats are "None"... wonderful -_-
-                '''
+                self.transaction.lmd['model_accuracy']['train'][k].extend(train_stats['train'][k]['accuracy'])
+                self.transaction.lmd['model_accuracy']['test'][k].extend(train_stats['test'][k]['accuracy'])
+
+            '''
+            @ TRAIN ONLINE BIT That's not working
+            model = LudwigModel.load(self.transaction.lmd['ludwig_data']['ludwig_save_path'])
+            for i in range(0,100):
+                train_stats = model.train_online(data_df=training_dataframe)
+                # The resulting train_stats are "None"... wonderful -_-
+            '''
 
         ludwig_model_savepath = os.path.join(CONFIG.MINDSDB_STORAGE_PATH, self.transaction.lmd['name'] + '_ludwig_data')
 
diff --git a/mindsdb/libs/controllers/predictor.py b/mindsdb/libs/controllers/predictor.py
--- a/mindsdb/libs/controllers/predictor.py
+++ b/mindsdb/libs/controllers/predictor.py
@@ -121,9 +121,10 @@ def _adapt_column(self, col_stats, col):
             'y': []
         }
         icm['data_distribution']['clusters'] = {}
-        for k, v in col_stats['histogram'].items():
-            icm['data_distribution']['data_histogram']['x'].append(k)
-            icm['data_distribution']['data_histogram']['y'].append(v)
+
+        for i in range(len(col_stats['histogram']['x'])):
+            icm['data_distribution']['data_histogram']['x'].append(col_stats['histogram']['x'][i])
+            icm['data_distribution']['data_histogram']['y'].append(col_stats['histogram']['y'][i])
 
         scores = ['consistency_score', 'redundancy_score', 'variability_score']
         for score in scores:
diff --git a/mindsdb/libs/phases/stats_generator/stats_generator.py b/mindsdb/libs/phases/stats_generator/stats_generator.py
--- a/mindsdb/libs/phases/stats_generator/stats_generator.py
+++ b/mindsdb/libs/phases/stats_generator/stats_generator.py
@@ -902,6 +902,7 @@ def run(self, input_data, modify_light_metadata):
                     if dictionary_lenght_percentage > 10 and len(col_data) > 50 and is_full_text==False:
                         dictionary = []
                         dictionary_available = False
+
                 col_stats = {
                     'data_type': data_type,
                     'data_subtype': curr_data_subtype,


Test patch:
diff --git a/integration_testing/run_travis_tests.py b/integration_testing/run_travis_tests.py
--- a/integration_testing/run_travis_tests.py
+++ b/integration_testing/run_travis_tests.py
@@ -111,8 +111,8 @@ def run_tests():
 
         # Print statements are in for debugging, remove later, but keep the funcion calls to make sure the interface is working
         models = mdb.get_models()
-        lmd = mdb.get_model_data(models[0]['name'])
-        #print(lmd)
+        amd = mdb.get_model_data(models[0]['name'])
+        print(amd)
 
     except:
         print(traceback.format_exc())