Skip to content

Commit 9696713

Browse files
authored
Merge pull request #58 from guardrails-ai/dtam/fix_config_path_none_handling
pull default config from where were running the start command from
2 parents c33f718 + 3908ef4 commit 9696713

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ open-api-spec.yml
2727
requirements-lock-old.txt
2828
opensearch
2929
build
30-
*.egg-info
30+
*.egg-info
31+
config.py

guardrails_api/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ def __call__(self, environ, start_response):
3434

3535

3636
def register_config(config: Optional[str] = None):
37-
default_config_file = os.path.join(os.path.dirname(__file__), "config.py")
38-
37+
default_config_file = os.path.join(os.getcwd(), "./config.py")
3938
config_file = config or default_config_file
4039
config_file_path = os.path.abspath(config_file)
4140
if os.path.isfile(config_file_path):

guardrails_api/utils/configuration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import os
44

55
def valid_configuration(config: Optional[str]=""):
6-
default_config_file = os.path.join(os.path.dirname(__file__), "config.py")
6+
default_config_file = os.path.join(os.getcwd(), "./config.py")
77

8-
config_file_path = os.path.abspath(config)
98
default_config_file_path = os.path.abspath(default_config_file)
109
# If config.py is not present and
1110
# if a config filepath is not passed and
1211
# if postgres is not there (i.e. we’re using in-mem db)
1312
# then raise ConfigurationError
1413
has_default_config_file = os.path.isfile(default_config_file_path)
15-
has_config_file = config != "" and os.path.isfile(config_file_path)
14+
15+
has_config_file = (config != "" and config is not None) and os.path.isfile(os.path.abspath(config))
1616
if not has_default_config_file and not has_config_file and not postgres_is_enabled():
1717
raise ConfigurationError("Can not start. Configuration not provided and default"
1818
" configuration not found and postgres is not enabled.")

0 commit comments

Comments
 (0)