From 2a538bb823f2c141bd39fd97219270f118ebe1df Mon Sep 17 00:00:00 2001 From: Makar Shevchenko Date: Mon, 9 Oct 2023 17:12:34 +0300 Subject: [PATCH 1/2] PNLP-7713: add read all paths in app_config from os.env --- smart_kit/configs/__init__.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/smart_kit/configs/__init__.py b/smart_kit/configs/__init__.py index 1c633ae8..436881df 100644 --- a/smart_kit/configs/__init__.py +++ b/smart_kit/configs/__init__.py @@ -25,9 +25,11 @@ def get_app_config(environment_variable=ENVIRONMENT_VARIABLE): static_path = os.getenv("STATIC_PATH") or get_static_path(app_config.__file__) set_default(app_config, "STATIC_PATH", static_path) - set_default(app_config, "CONFIGS_PATH", os.path.join(static_path, "./configs")) - set_default(app_config, "SECRET_PATH", os.path.join(static_path, "./configs")) - references_path = os.path.join(static_path, "./references") + configs_path = os.getenv("CONFIGS_PATH") or os.path.join(static_path, "./configs") + set_default(app_config, "CONFIGS_PATH", configs_path) + secret_path = os.getenv("SECRET_PATH") or os.path.join(static_path, "./configs") + set_default(app_config, "SECRET_PATH", secret_path) + references_path = os.getenv("REFERENCES_PATH") or os.path.join(static_path, "./references") set_default(app_config, "REFERENCES_PATH", references_path) # import and init monitoring first - because other classes use a singleton instance of Monitoring @@ -78,8 +80,11 @@ def get_app_config(environment_variable=ENVIRONMENT_VARIABLE): set_default(app_config, "FROM_MSG_VALIDATORS", ()) set_default(app_config, "AUTO_LISTENING", True) - set_default(app_config, "STATIC_CLASSIFIERS_PATH", os.path.join(references_path, "./classifiers")) - set_default(app_config, "STATIC_CLASSIFIERS_DATA_PATH", os.path.join(references_path, "./classifiers_data")) + static_classifiers_path = os.getenv("STATIC_CLASSIFIERS_PATH") or os.path.join(references_path, "./classifiers") + set_default(app_config, "STATIC_CLASSIFIERS_PATH", static_classifiers_path) + static_classifiers_data_path = os.getenv("STATIC_CLASSIFIERS_DATA_PATH") \ + or os.path.join(references_path, "./classifiers_data") + set_default(app_config, "STATIC_CLASSIFIERS_DATA_PATH", static_classifiers_data_path) # Переменной можно присвоить значение среды, где запускается апп, # например: "ift", "uat", "pt", "prod" (это ИФТ, ПСИ, НТ, ПРОМ) From 6cf5eb69884aef73f5624f4ebe113b3df1c8a5e8 Mon Sep 17 00:00:00 2001 From: Makar Shevchenko Date: Tue, 10 Oct 2023 13:36:19 +0300 Subject: [PATCH 2/2] PNLP-7713: formatting --- smart_kit/configs/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smart_kit/configs/__init__.py b/smart_kit/configs/__init__.py index 436881df..1bf6213c 100644 --- a/smart_kit/configs/__init__.py +++ b/smart_kit/configs/__init__.py @@ -82,8 +82,8 @@ def get_app_config(environment_variable=ENVIRONMENT_VARIABLE): static_classifiers_path = os.getenv("STATIC_CLASSIFIERS_PATH") or os.path.join(references_path, "./classifiers") set_default(app_config, "STATIC_CLASSIFIERS_PATH", static_classifiers_path) - static_classifiers_data_path = os.getenv("STATIC_CLASSIFIERS_DATA_PATH") \ - or os.path.join(references_path, "./classifiers_data") + static_classifiers_data_path = (os.getenv("STATIC_CLASSIFIERS_DATA_PATH") + or os.path.join(references_path, "./classifiers_data")) # noqa: W503 set_default(app_config, "STATIC_CLASSIFIERS_DATA_PATH", static_classifiers_data_path) # Переменной можно присвоить значение среды, где запускается апп,