Repository: deeppavlov/DeepPavlov

Issue:
Setting `DP_MODELS_PATH` and `DP_DOWNLOADS_PATH` variables doesn't really work
All configs in DeepPavlov library have their own way of what is written in `MODELS_PATH`:
* some configs have just `{ROOT_PATH}/models`
* some configs have one more folder, ex. `{ROOT_PATH}/models/kbqa_mix_lowercase`
* some configs have a lot of additional folders, ex. `{ROOT_PATH}/models/classifiers/insults_kaggle_v3`

This makes pointless setting `DP_MODELS_PATH` environment variable because it will overwrite `MODELS_PATH` and all paths that have additional folders cannot be found then.

I think it could be fixed by standardizing `MODELS_PATH` in all configs as `{ROOT_PATH}/models`, and all additional folders should be in a different variable (` MY_FOLDER = {MODELS_PATH/whatever/folders}`).


Discussion:

Resolving patch:
diff --git a/deeppavlov/models/evolution/evolution_param_generator.py b/deeppavlov/models/evolution/evolution_param_generator.py
--- a/deeppavlov/models/evolution/evolution_param_generator.py
+++ b/deeppavlov/models/evolution/evolution_param_generator.py
@@ -67,7 +67,7 @@ class ParamsEvolution(ParamsSearch):
                 with relative paths to evolving parameters
         n_params: number of evolving parameters
         evolution_model_id: identity number of model (the same for loaded pre-trained models)
-        models_path: path to models given in config variable `MODELS_PATH`. This variable \
+        models_path: path to models given in config variable `MODEL_PATH`. This variable \
             should be used as prefix to all fitted and trained model in config~
         eps: EPS value
         paths_to_fiton_dicts: list of lists of keys and/or integers (for list)\
@@ -86,7 +86,7 @@ def __init__(self,
                  train_partition: int = 1,
                  elitism_with_weights: bool = False,
                  prefix: str = "evolve",
-                 models_path_variable: str = "MODELS_PATH",
+                 models_path_variable: str = "MODEL_PATH",
                  **kwargs):
         """
         Initialize evolution with random population
@@ -114,11 +114,11 @@ def __init__(self,
             for ppath in occured_mpaths:
                 new_path = self.get_value_from_config(
                     self.basic_config,
-                    ppath + [path_name]).replace(models_path_variable, "MODELS_" + path_name.upper())
+                    ppath + [path_name]).replace(models_path_variable, "MODEL_" + path_name.upper())
                 self.insert_value_or_dict_into_config(self.basic_config, ppath + [path_name], new_path)
 
-        self.path_to_models_save_path = ["metadata", "variables", "MODELS_SAVE_PATH"]
-        self.path_to_models_load_path = ["metadata", "variables", "MODELS_LOAD_PATH"]
+        self.path_to_models_save_path = ["metadata", "variables", "MODEL_SAVE_PATH"]
+        self.path_to_models_load_path = ["metadata", "variables", "MODEL_LOAD_PATH"]
         self.insert_value_or_dict_into_config(self.basic_config, self.path_to_models_save_path, str(self.models_path))
         self.insert_value_or_dict_into_config(self.basic_config, self.path_to_models_load_path, str(self.models_path))
 


Test patch:
diff --git a/tests/test_configs/ranking/ranking_ubuntu_v2_bert_sep_interact_test.json b/tests/test_configs/ranking/ranking_ubuntu_v2_bert_sep_interact_test.json
--- a/tests/test_configs/ranking/ranking_ubuntu_v2_bert_sep_interact_test.json
+++ b/tests/test_configs/ranking/ranking_ubuntu_v2_bert_sep_interact_test.json
@@ -15,8 +15,8 @@
       {
         "class_name": "response_base_loader",
         "id": "loader",
-        "save_path": "{MODELS_PATH}",
-        "load_path": "{MODELS_PATH}"
+        "save_path": "{MODEL_PATH}",
+        "load_path": "{MODEL_PATH}"
       },
       {
         "class_name": "bert_sep_ranker_predictor_preprocessor",
@@ -42,8 +42,8 @@
         "interact_mode": 3,
         "bert_config_file": "{DOWNLOADS_PATH}/bert_models/uncased_L-12_H-768_A-12/bert_config.json",
         "pretrained_bert": "{DOWNLOADS_PATH}/bert_models/uncased_L-12_H-768_A-12/bert_model.ckpt",
-        "save_path": "{MODELS_PATH}",
-        "load_path": "{MODELS_PATH}/model",
+        "save_path": "{MODEL_PATH}",
+        "load_path": "{MODEL_PATH}/model",
         "learning_rate": 2e-05,
         "in": ["bert_features"],
         "in_y": ["y"],
@@ -63,13 +63,14 @@
     "log_every_n_batches": -1,
     "validate_best": true,
     "test_best": true,
-    "tensorboard_log_dir": "{MODELS_PATH}/"
+    "tensorboard_log_dir": "{MODEL_PATH}/"
   },
   "metadata": {
     "variables": {
       "ROOT_PATH": "~/.deeppavlov",
       "DOWNLOADS_PATH": "{ROOT_PATH}/downloads",
-      "MODELS_PATH": "{ROOT_PATH}/models/ubuntu_v2_uncased_bert_sep_predictor_model"
+      "MODELS_PATH": "{ROOT_PATH}/models",
+      "MODEL_PATH": "{MODELS_PATH}/ubuntu_v2_uncased_bert_sep_predictor_model"
     },
     "requirements": [
       "{DEEPPAVLOV_PATH}/requirements/tf.txt",
@@ -86,7 +87,7 @@
       },
       {
         "url": "http://files.deeppavlov.ai/deeppavlov_data/ubuntu_v2_uncased_bert_sep_predictor_model.tar.gz",
-        "subdir": "{ROOT_PATH}/models"
+        "subdir": "{MODELS_PATH}"
       }
 
     ]
diff --git a/tests/test_configs/ranking/ranking_ubuntu_v2_bert_sep_test.json b/tests/test_configs/ranking/ranking_ubuntu_v2_bert_sep_test.json
--- a/tests/test_configs/ranking/ranking_ubuntu_v2_bert_sep_test.json
+++ b/tests/test_configs/ranking/ranking_ubuntu_v2_bert_sep_test.json
@@ -24,8 +24,8 @@
         "class_name": "bert_sep_ranker",
         "bert_config_file": "{DOWNLOADS_PATH}/bert_models/uncased_L-12_H-768_A-12/bert_config.json",
         "pretrained_bert": "{DOWNLOADS_PATH}/bert_models/uncased_L-12_H-768_A-12/bert_model.ckpt",
-        "save_path": "{MODELS_PATH}/model",
-        "load_path": "{MODELS_PATH}/model",
+        "save_path": "{MODEL_PATH}/model",
+        "load_path": "{MODEL_PATH}/model",
         "learning_rate": 2e-05,
         "in": ["bert_features"],
         "in_y": ["y"],
@@ -45,13 +45,14 @@
     "log_every_n_batches": -1,
     "validate_best": true,
     "test_best": true,
-    "tensorboard_log_dir": "{MODELS_PATH}/"
+    "tensorboard_log_dir": "{MODEL_PATH}/"
   },
   "metadata": {
     "variables": {
       "ROOT_PATH": "~/.deeppavlov",
       "DOWNLOADS_PATH": "{ROOT_PATH}/downloads",
-      "MODELS_PATH": "{ROOT_PATH}/models/ubuntu_v2_uncased_bert_sep_model"
+      "MODELS_PATH": "{ROOT_PATH}/models",
+      "MODEL_PATH": "{MODELS_PATH}/ubuntu_v2_uncased_bert_sep_model"
     },
     "requirements": [
       "{DEEPPAVLOV_PATH}/requirements/tf.txt",
@@ -68,7 +69,7 @@
       },
       {
         "url": "http://files.deeppavlov.ai/deeppavlov_data/ubuntu_v2_uncased_bert_sep_model.tar.gz",
-        "subdir": "{ROOT_PATH}/models"
+        "subdir": "{MODELS_PATH}"
       }
     ]
   }
diff --git a/tests/test_configs/ranking/ranking_ubuntu_v2_bert_uncased_test.json b/tests/test_configs/ranking/ranking_ubuntu_v2_bert_uncased_test.json
--- a/tests/test_configs/ranking/ranking_ubuntu_v2_bert_uncased_test.json
+++ b/tests/test_configs/ranking/ranking_ubuntu_v2_bert_uncased_test.json
@@ -24,8 +24,8 @@
         "one_hot_labels": false,
         "bert_config_file": "{DOWNLOADS_PATH}/bert_models/uncased_L-12_H-768_A-12/bert_config.json",
         "pretrained_bert": "{DOWNLOADS_PATH}/bert_models/uncased_L-12_H-768_A-12/bert_model.ckpt",
-        "save_path": "{MODELS_PATH}/model",
-        "load_path": "{MODELS_PATH}/model",
+        "save_path": "{MODEL_PATH}/model",
+        "load_path": "{MODEL_PATH}/model",
         "learning_rate": 2e-05,
         "in": ["bert_features"],
         "in_y": ["y"],
@@ -45,13 +45,14 @@
     "log_every_n_batches": -1,
     "validate_best": true,
     "test_best": true,
-    "tensorboard_log_dir": "{MODELS_PATH}/"
+    "tensorboard_log_dir": "{MODEL_PATH}/"
   },
   "metadata": {
     "variables": {
       "ROOT_PATH": "~/.deeppavlov",
       "DOWNLOADS_PATH": "{ROOT_PATH}/downloads",
-      "MODELS_PATH": "{ROOT_PATH}/models/ubuntu_v2_uncased_bert_model"
+      "MODELS_PATH": "{ROOT_PATH}/models",
+      "MODEL_PATH": "{MODELS_PATH}/ubuntu_v2_uncased_bert_model"
     },
     "requirements": [
       "{DEEPPAVLOV_PATH}/requirements/tf.txt",
@@ -68,7 +69,7 @@
       },
       {
         "url": "http://files.deeppavlov.ai/deeppavlov_data/ubuntu_v2_uncased_bert_model.tar.gz",
-        "subdir": "{ROOT_PATH}/models"
+        "subdir": "{MODELS_PATH}"
       }
     ]
   }