Skip to content

Commit

Permalink
fix: missing file in v1.1.2 (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
gventuri committed Sep 8, 2023
1 parent 1b5e942 commit 3b2be92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 15 additions & 4 deletions pandasai/config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import json
import logging
from typing import Optional, Union

from . import llm, middlewares, callbacks
from .helpers.path import find_closest
from .schemas.df_config import Config

logger = logging.getLogger(__name__)

def load_config(
override_config: Optional[Union[Config, dict]] = None,
):
"""
Load the configuration from the pandasai.json file.
Args:
override_config (Optional[Union[Config, dict]], optional): The configuration to
override the one in the file. Defaults to None.
Returns:
dict: The configuration.
"""

def load_config(override_config: Optional[Union[Config, dict]] = None):
config = {}

if override_config is None:
Expand All @@ -32,7 +42,8 @@ def load_config(override_config: Optional[Union[Config, dict]] = None):
if config.get("callback") and not override_config.get("callback"):
config["callback"] = getattr(callbacks, config["callback"])()
except Exception:
logger.error("Could not load configuration", exc_info=True)
# Ignore the error if the file does not exist, will use the default config
pass

if override_config:
config.update(override_config)
Expand Down
6 changes: 3 additions & 3 deletions pandasai/helpers/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def find_project_root(filename=None):
def find_closest(filename):
return os.path.join(find_project_root(filename), filename)


def create_directory(path):

if not os.path.exists(path):
# Create the directory
try:
os.makedirs(path)
os.makedirs(path)
except OSError as e:
raise OSError(f"Error creating directory: {e}")
raise OSError(f"Error creating directory: {e}")

0 comments on commit 3b2be92

Please sign in to comment.