Skip to content

Commit

Permalink
create dir reuse method
Browse files Browse the repository at this point in the history
Signed-off-by: ravi-kumar-pilla <[email protected]>
  • Loading branch information
ravi-kumar-pilla committed Jun 21, 2024
1 parent 50cf015 commit d63cd85
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions package/kedro_viz/integrations/kedro/sqlite_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ def _is_json_serializable(obj: Any):
return False


def _get_session_path(session_path: str) -> str:
"""Returns the session path by creating its parent directory
if unavailable.
"""
session_file_path = Path(session_path)
session_file_path.parent.mkdir(parents=True, exist_ok=True)
return str(session_file_path)


class SQLiteStore(BaseSessionStore):
"""Stores the session data on the sqlite db."""

Expand All @@ -55,12 +64,11 @@ def location(self) -> str:
"""Returns location of the sqlite_store database"""
if "path" not in settings.SESSION_STORE_ARGS:
kedro_project_path = _find_kedro_project(Path.cwd()) or self._path
session_file_path = Path(
return _get_session_path(
f"{kedro_project_path}/{VIZ_SESSION_STORE_ARGS['path']}/session_store.db"
)
session_file_path.parent.mkdir(parents=True, exist_ok=True)
return str(session_file_path)
return str(Path(self._path) / "session_store.db")

return _get_session_path(f"{self._path}/session_store.db")

@property
def remote_location(self) -> Optional[str]:
Expand Down

0 comments on commit d63cd85

Please sign in to comment.