diff --git a/.gitignore b/.gitignore index 8377660..5ec83ad 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ open-api-spec.yml requirements-lock-old.txt opensearch build -*.egg-info \ No newline at end of file +*.egg-info +config.py \ No newline at end of file diff --git a/guardrails_api/app.py b/guardrails_api/app.py index d43a15c..7ac5adc 100644 --- a/guardrails_api/app.py +++ b/guardrails_api/app.py @@ -34,8 +34,7 @@ def __call__(self, environ, start_response): def register_config(config: Optional[str] = None): - default_config_file = os.path.join(os.path.dirname(__file__), "config.py") - + default_config_file = os.path.join(os.getcwd(), "./config.py") config_file = config or default_config_file config_file_path = os.path.abspath(config_file) if os.path.isfile(config_file_path): diff --git a/guardrails_api/utils/configuration.py b/guardrails_api/utils/configuration.py index 742f8f4..1fdb965 100644 --- a/guardrails_api/utils/configuration.py +++ b/guardrails_api/utils/configuration.py @@ -3,16 +3,16 @@ import os def valid_configuration(config: Optional[str]=""): - default_config_file = os.path.join(os.path.dirname(__file__), "config.py") + default_config_file = os.path.join(os.getcwd(), "./config.py") - config_file_path = os.path.abspath(config) default_config_file_path = os.path.abspath(default_config_file) # If config.py is not present and # if a config filepath is not passed and # if postgres is not there (i.e. we’re using in-mem db) # then raise ConfigurationError has_default_config_file = os.path.isfile(default_config_file_path) - has_config_file = config != "" and os.path.isfile(config_file_path) + + has_config_file = (config != "" and config is not None) and os.path.isfile(os.path.abspath(config)) if not has_default_config_file and not has_config_file and not postgres_is_enabled(): raise ConfigurationError("Can not start. Configuration not provided and default" " configuration not found and postgres is not enabled.")