Skip to content

Commit ed4675c

Browse files
fix(graphgen): align time stamp
1 parent c649d8f commit ed4675c

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

graphgen/graphgen.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,6 @@
2020
class GraphGen:
2121
unique_id: int = int(time.time())
2222
working_dir: str = os.path.join(sys_path, "cache")
23-
full_docs_storage: JsonKVStorage = JsonKVStorage(
24-
working_dir, namespace="full_docs"
25-
)
26-
text_chunks_storage: JsonKVStorage = JsonKVStorage(
27-
working_dir, namespace="text_chunks"
28-
)
29-
wiki_storage: JsonKVStorage = JsonKVStorage(
30-
working_dir, namespace="wiki"
31-
)
32-
graph_storage: NetworkXStorage = NetworkXStorage(
33-
working_dir, namespace="graph"
34-
)
35-
rephrase_storage: JsonKVStorage = JsonKVStorage(
36-
working_dir, namespace="rephrase"
37-
)
38-
qa_storage: JsonKVStorage = JsonKVStorage(
39-
os.path.join(working_dir, "data", "graphgen", str(unique_id)), namespace=f"qa-{unique_id}"
40-
)
4123

4224
# text chunking
4325
chunk_size: int = 1024
@@ -55,6 +37,26 @@ class GraphGen:
5537
# traverse strategy
5638
traverse_strategy: TraverseStrategy = TraverseStrategy()
5739

40+
def __post_init__(self):
41+
self.full_docs_storage: JsonKVStorage = JsonKVStorage(
42+
self.working_dir, namespace="full_docs"
43+
)
44+
self.text_chunks_storage: JsonKVStorage = JsonKVStorage(
45+
self.working_dir, namespace="text_chunks"
46+
)
47+
self.wiki_storage: JsonKVStorage = JsonKVStorage(
48+
self.working_dir, namespace="wiki"
49+
)
50+
self.graph_storage: NetworkXStorage = NetworkXStorage(
51+
self.working_dir, namespace="graph"
52+
)
53+
self.rephrase_storage: JsonKVStorage = JsonKVStorage(
54+
self.working_dir, namespace="rephrase"
55+
)
56+
self.qa_storage: JsonKVStorage = JsonKVStorage(
57+
os.path.join(self.working_dir, "data", "graphgen", str(self.unique_id)), namespace=f"qa-{self.unique_id}"
58+
)
59+
5860
async def async_split_chunks(self, data: Union[List[list], List[dict]], data_type: str) -> dict:
5961
# TODO: 是否进行指代消解
6062
if len(data) == 0:

graphgen/operators/traverse_graph.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ async def _process_single_batch(
208208
elif question.startswith("问题:"):
209209
question = question[len("问题:"):].strip()
210210

211+
logger.info("Question: %s", question)
212+
logger.info("Answer: %s", context)
213+
211214
return {
212215
compute_content_hash(context): {
213216
"question": question,

0 commit comments

Comments
 (0)