Skip to content

Commit c3ef35b

Browse files
fix: fix some lint errors
1 parent 9ace0e1 commit c3ef35b

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

graphgen/graphgen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from tqdm.asyncio import tqdm as tqdm_async
99

1010
from models import Chunk, JsonKVStorage, OpenAIModel, NetworkXStorage, WikiSearch, Tokenizer, TraverseStrategy
11-
from utils import create_event_loop, logger, compute_content_hash
1211
from models.storage.base_storage import StorageNameSpace
13-
from .operators import *
12+
from utils import create_event_loop, logger, compute_content_hash
13+
from .operators import extract_kg, search_wikipedia, quiz_relations, judge_relations, traverse_graph_by_edge
1414

1515

1616
sys_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
@@ -145,7 +145,7 @@ async def async_insert(self, data: Union[List[list], List[dict]], data_type: str
145145

146146
logger.info(f"[Wiki Search] is {'enabled' if self.if_web_search else 'disabled'}")
147147
if self.if_web_search:
148-
logger.info(f"[Wiki Search]...")
148+
logger.info("[Wiki Search]...")
149149
_add_wiki_data = await search_wikipedia(
150150
llm_client= self.teacher_llm_client,
151151
wiki_search_client=self.wiki_client,

models/storage/json_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class JsonKVStorage(BaseKVStorage):
1212
def __post_init__(self):
1313
self._file_name = os.path.join(self.working_dir, f"{self.namespace}.json")
1414
self._data = load_json(self._file_name) or {}
15-
logger.info(f"Load KV {self.namespace} with {len(self._data)} data")
15+
logger.info("Load KV %s with %d data", self.namespace, len(self._data))
1616

1717
async def all_keys(self) -> list[str]:
1818
return list(self._data.keys())

models/storage/networkx_storage.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import os
22
import html
3-
import networkx as nx
4-
53
from typing import Any, Union, cast, Optional
64
from dataclasses import dataclass
5+
import networkx as nx
76

8-
from .base_storage import BaseGraphStorage
97
from utils import logger
8+
from .base_storage import BaseGraphStorage
109

1110
@dataclass
1211
class NetworkXStorage(BaseGraphStorage):
@@ -120,6 +119,9 @@ async def get_node_edges(self, source_node_id: str) -> Union[list[tuple[str, str
120119
return list(self._graph.edges(source_node_id, data=True))
121120
return None
122121

122+
async def get_graph(self) -> nx.Graph:
123+
return self._graph
124+
123125
async def upsert_node(self, node_id: str, node_data: dict[str, str]):
124126
self._graph.add_node(node_id, **node_data)
125127

0 commit comments

Comments
 (0)