diff --git a/gpt_index/indices/base.py b/gpt_index/indices/base.py index 61a7bfecd88d55298f79a831985f2687c80e8a54..e66eee6f684ffbe907f99233cc73b52d6a6114bb 100644 --- a/gpt_index/indices/base.py +++ b/gpt_index/indices/base.py @@ -1,4 +1,5 @@ """Base data structure classes.""" +import json from abc import abstractmethod from typing import Any, Generic, List, Optional, TypeVar, cast @@ -92,6 +93,7 @@ class BaseGPTIndex(Generic[IS]): def load_from_disk(cls, save_path: str, **kwargs: Any) -> "BaseGPTIndex": """Load from disk.""" - @abstractmethod def save_to_disk(self, save_path: str) -> None: """Safe to file.""" + with open(save_path, "w") as f: + json.dump(self.index_struct.to_dict(), f) diff --git a/gpt_index/indices/keyword_table/__init__.py b/gpt_index/indices/keyword_table/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1d4640565ae2765d9ca96a509dc9809217f62f2f 100644 --- a/gpt_index/indices/keyword_table/__init__.py +++ b/gpt_index/indices/keyword_table/__init__.py @@ -0,0 +1 @@ +"""Init file.""" diff --git a/gpt_index/indices/list/__init__.py b/gpt_index/indices/list/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1d4640565ae2765d9ca96a509dc9809217f62f2f 100644 --- a/gpt_index/indices/list/__init__.py +++ b/gpt_index/indices/list/__init__.py @@ -0,0 +1 @@ +"""Init file.""" diff --git a/gpt_index/indices/list/base.py b/gpt_index/indices/list/base.py index 1f763cf1f6db351a84a707eee6f8af232b1e367f..a8c09056addd5c74987f4d666c4c92f1575cd2c1 100644 --- a/gpt_index/indices/list/base.py +++ b/gpt_index/indices/list/base.py @@ -72,8 +72,3 @@ class GPTListIndex(BaseGPTIndex[IndexList]): """Load from disk.""" with open(save_path, "r") as f: return cls(index_struct=IndexList.from_dict(json.load(f)), **kwargs) - - def save_to_disk(self, save_path: str) -> None: - """Safe to file.""" - with open(save_path, "w") as f: - json.dump(self.index_struct.to_dict(), f) diff --git a/gpt_index/indices/tree/__init__.py b/gpt_index/indices/tree/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1d4640565ae2765d9ca96a509dc9809217f62f2f 100644 --- a/gpt_index/indices/tree/__init__.py +++ b/gpt_index/indices/tree/__init__.py @@ -0,0 +1 @@ +"""Init file.""" diff --git a/gpt_index/indices/tree/base.py b/gpt_index/indices/tree/base.py index a94d82d5e2f0b9fad5596a699ba4bf23111c78a4..0bd36731d6690c02b97bf8018ff45929f6600db7 100644 --- a/gpt_index/indices/tree/base.py +++ b/gpt_index/indices/tree/base.py @@ -136,8 +136,3 @@ class GPTTreeIndex(BaseGPTIndex[IndexGraph]): """Load from disk.""" with open(save_path, "r") as f: return cls(index_struct=IndexGraph.from_dict(json.load(f)), **kwargs) - - def save_to_disk(self, save_path: str) -> None: - """Safe to file.""" - with open(save_path, "w") as f: - json.dump(self.index_struct.to_dict(), f) diff --git a/pyproject.toml b/pyproject.toml index 619e1edb280ec4eef47408153bc38e022da274e1..b545d6ada302f1b4f43a714dd4063b52e0cbe0a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,4 +4,4 @@ profile = "black" [tool.mypy] ignore_missing_imports = "True" disallow_untyped_defs = "True" -exclude = ["notebooks"] \ No newline at end of file +exclude = ["notebooks", "build"] \ No newline at end of file