Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 18, 2025

All dataclass decorator issues have been fixed!

Changes Made

Base Classes

Removed @dataclass decorator from 15 ABC base classes that define interfaces rather than data structures:

  • BaseGenerator, BasePartitioner, BaseTokenizer, BaseKGBuilder, BaseSplitter
  • BaseEvaluator, TopkTokenModel (also made ABC)
  • StorageNameSpace, BaseListStorage, BaseKVStorage, BaseGraphStorage

Search Classes

Fixed classes that incorrectly used @dataclass with custom __init__ methods:

  • GoogleSearch, BingSearch, WikiSearch, UniProtSearch

Subclasses - Complete Refactor

Following the pattern established for generators (commit e5954e9), removed @dataclass from all subclasses that inherit from base classes with __init__ methods:

Storage Classes (added parent field declarations):

  • NetworkXStorage, JsonKVStorage, JsonListStorage

Tokenizer Classes (converted to use __init__ with super().__init__()):

  • TiktokenTokenizer, HFTokenizer, Tokenizer

Generator Classes (removed @DataClass, use standard inheritance):

  • AtomicGenerator, AggregatedGenerator, CoTGenerator, MultiHopGenerator, VQAGenerator

Partitioner Classes (removed @DataClass):

  • BFSPartitioner, DFSPartitioner, LeidenPartitioner, ECEPartitioner

Evaluator Classes (converted to use __init__ with super().__init__()):

  • LengthEvaluator, MTLDEvaluator

KG Builder Classes (converted to use __init__ with super().__init__()):

  • LightRAGKGBuilder, MMKGBuilder

Summary

Fixed incorrect @dataclass usage throughout the codebase:

  • 15 base/abstract classes: Removed @DataClass (they define interfaces, not data)
  • 4 search classes: Removed @DataClass (conflicted with custom init)
  • 17 subclasses: Removed @DataClass and converted to standard Python inheritance

All subclasses now properly inherit from their base classes using:

  • Standard inheritance for classes with no custom initialization
  • Explicit __init__ methods with super().__init__() calls for classes with custom initialization

Files Modified:

  • 10 base class files in graphgen/bases/
  • 4 search implementation files in graphgen/models/search/
  • 3 storage implementation files in graphgen/models/storage/
  • 3 tokenizer implementation files in graphgen/models/tokenizer/
  • 5 generator implementation files in graphgen/models/generator/
  • 4 partitioner implementation files in graphgen/models/partitioner/
  • 2 evaluator implementation files in graphgen/models/evaluator/
  • 2 KG builder implementation files in graphgen/models/kg_builder/
  • 1 LLM model base class in graphgen/models/llm/

All changes maintain backward compatibility and all files pass Python compilation checks.

Fixes #67

Original prompt

This section details on the original issue you should resolve

<issue_title>Change of code style</issue_title>
<issue_description>Describe the bug
Some classes that should not use the @DataClass decorator have been decorated with it.

Expected behavior
All code should be scanned to identify classes that have been incorrectly marked with @DataClass, and these should be corrected. Special attention should be paid to whether these classes have any related parent or child classes to avoid omissions.
</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #67


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits October 18, 2025 07:49
Co-authored-by: ChenZiHong-Gavin <58508660+ChenZiHong-Gavin@users.noreply.github.com>
Co-authored-by: ChenZiHong-Gavin <58508660+ChenZiHong-Gavin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix incorrect use of @dataclass in classes Remove incorrect @dataclass decorators from ABC base classes Oct 18, 2025
Copilot finished work on behalf of ChenZiHong-Gavin October 18, 2025 07:57
Copy link
Collaborator

@ChenZiHong-Gavin ChenZiHong-Gavin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix problem

Co-authored-by: ChenZiHong-Gavin <58508660+ChenZiHong-Gavin@users.noreply.github.com>
Copilot finished work on behalf of ChenZiHong-Gavin October 20, 2025 08:58
Copilot finished work on behalf of ChenZiHong-Gavin October 20, 2025 09:02
@ChenZiHong-Gavin
Copy link
Collaborator

@copilot Main branch has been merged, please review new files and make changes when necessary.

Co-authored-by: ChenZiHong-Gavin <58508660+ChenZiHong-Gavin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot Main branch has been merged, please review new files and make changes when necessary.

Reviewed new files from main branch merge. Fixed in commit [hash].

Changes made:

  • VQAGenerator: Added missing llm_client: BaseLLMClient = None field declaration
  • MMKGBuilder: Converted to use @dataclass decorator with proper llm_client and max_loop field declarations

All other new files (BaseReader, AnchorBFSPartitioner, reader implementations) follow correct patterns.

Copilot finished work on behalf of ChenZiHong-Gavin October 23, 2025 11:22
@ChenZiHong-Gavin
Copy link
Collaborator

Some dataclass decorators for subclass are not fixed like generators in e5954e9.
Find them and fix them @copilot

Co-authored-by: ChenZiHong-Gavin <58508660+ChenZiHong-Gavin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

Some dataclass decorators for subclass are not fixed like generators in e5954e9.
Find them and fix them @c...

Fixed in commit [hash]. Removed @dataclass decorator from all subclasses following the same pattern used for generators:

Tokenizers:

  • TiktokenTokenizer, HFTokenizer, Tokenizer - converted to use __init__ with super().__init__()

Partitioners:

  • BFSPartitioner, DFSPartitioner, LeidenPartitioner, ECEPartitioner - removed @DataClass (no custom fields)

Evaluators:

  • LengthEvaluator, MTLDEvaluator - converted to use __init__ with super().__init__()

KG Builders:

  • LightRAGKGBuilder, MMKGBuilder - converted to use __init__ with super().__init__()

All classes now properly inherit from their base classes using standard Python inheritance instead of dataclass.

Copilot AI changed the title Remove incorrect @dataclass decorators from ABC base classes Remove incorrect @dataclass decorators from ABC base classes and all subclasses Oct 23, 2025
Copilot finished work on behalf of ChenZiHong-Gavin October 23, 2025 11:47
@ChenZiHong-Gavin ChenZiHong-Gavin marked this pull request as ready for review October 23, 2025 12:25
@ChenZiHong-Gavin ChenZiHong-Gavin merged commit 97cdde3 into main Oct 23, 2025
3 checks passed
@ChenZiHong-Gavin ChenZiHong-Gavin deleted the copilot/change-code-style-dataclass branch October 23, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change of code style

2 participants