Skip to content

Commit 29ab42f

Browse files
committed
fix: fix pylint problems
1 parent b6e65c0 commit 29ab42f

8 files changed

Lines changed: 22 additions & 22 deletions

File tree

graphgen/models/generator/omics_qa_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def parse_response(response: str) -> Any:
6868
return qa_pairs
6969

7070
@staticmethod
71-
def _extract_caption(node_data: dict, molecule_type: str) -> Optional[dict]:
71+
def _extract_caption(node_data: dict, molecule_type: str) -> Optional[dict]: # pylint: disable=too-many-branches
7272
"""
7373
Extract molecule-specific caption information from node data.
7474
@@ -341,7 +341,7 @@ def format_generation_results(
341341
}
342342
for qa in qa_items
343343
]
344-
if output_data_format == "ChatML":
344+
elif output_data_format == "ChatML":
345345
return [
346346
{
347347
"messages": [
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from .light_rag_kg_builder import LightRAGKGBuilder
22
from .mm_kg_builder import MMKGBuilder
3-
from .omics_kg_builder import OmicsKGBuilder
3+
from .omics_kg_builder import OmicsKGBuilder

graphgen/models/partitioner/anchor_bfs_partitioner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def partition(
6666
if comm_n or comm_e:
6767
yield Community(id=seed_node, nodes=comm_n, edges=comm_e)
6868

69-
def _pick_anchor_ids(
69+
def _pick_anchor_ids( # pylint: disable=too-many-branches
7070
self,
7171
nodes: List[tuple[str, dict]],
7272
) -> Set[str]:

graphgen/models/searcher/db/rnacentral_searcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def _local_blast(self, seq: str, threshold: float) -> Optional[str]:
276276
pass
277277
return None
278278

279-
def get_by_fasta(self, sequence: str, threshold: float = 0.01) -> Optional[dict]:
279+
def get_by_fasta(self, sequence: str, threshold: float = 0.01) -> Optional[dict]: # pylint: disable=too-many-return-statements
280280
"""
281281
Search RNAcentral with an RNA sequence.
282282
Tries local BLAST first if enabled, falls back to RNAcentral API.

graphgen/models/searcher/db/uniprot_searcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def get_best_hit(self, keyword: str) -> Optional[Dict]:
111111
self.logger.error("Keyword %s not found: %s", keyword, e)
112112
return None
113113

114-
def get_by_fasta(self, fasta_sequence: str, threshold: float) -> Optional[Dict]:
114+
def get_by_fasta(self, fasta_sequence: str, threshold: float) -> Optional[Dict]: # pylint: disable=too-many-return-statements
115115
"""
116116
Search UniProt with a FASTA sequence and return the best hit.
117117
:param fasta_sequence: The FASTA sequence.

graphgen/operators/partition/partition_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def _pre_tokenize(self) -> None:
127127
self.kg_instance.index_done_callback()
128128
logger.info("Pre-tokenization completed.")
129129

130-
def _attach_additional_data_to_node(self, batch: tuple) -> tuple:
130+
def _attach_additional_data_to_node(self, batch: tuple) -> tuple: # pylint: disable=too-many-branches,too-many-statements
131131
"""
132132
Attach additional data from chunk_storage to nodes in the batch.
133133
:param batch: tuple of (nodes_data, edges_data)

graphgen/operators/search/search_service.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,18 @@ def _is_already_searched(self, doc: dict) -> bool:
215215

216216
return False
217217

218-
def _normalize_searched_data(self, doc: dict) -> dict:
218+
@staticmethod
219+
def _clean_value(v):
220+
"""Recursively convert numpy arrays and other problematic types to Python-native types."""
221+
if isinstance(v, np.ndarray):
222+
return v.tolist()
223+
if isinstance(v, (list, tuple)):
224+
return [SearchService._clean_value(item) for item in v]
225+
if isinstance(v, dict):
226+
return {k: SearchService._clean_value(val) for k, val in v.items()}
227+
return v
228+
229+
def _normalize_searched_data(self, doc: dict) -> dict: # pylint: disable=too-many-branches
219230
"""
220231
Normalize a document that already contains search results to the expected format.
221232
@@ -289,7 +300,7 @@ def _normalize_searched_data(self, doc: dict) -> dict:
289300

290301
return normalized_doc
291302

292-
def process(self, batch: pd.DataFrame) -> pd.DataFrame:
303+
def process(self, batch: pd.DataFrame) -> pd.DataFrame: # pylint: disable=too-many-branches
293304
"""
294305
Process a batch of documents and perform searches.
295306
This is the Ray Data operator interface.
@@ -397,18 +408,7 @@ def process(self, batch: pd.DataFrame) -> pd.DataFrame:
397408

398409
# Convert numpy arrays and complex types to Python-native types
399410
# to avoid Ray Data tensor extension casting issues
400-
def clean_value(v):
401-
"""Recursively convert numpy arrays and other problematic types to Python-native types."""
402-
if isinstance(v, np.ndarray):
403-
return v.tolist()
404-
elif isinstance(v, (list, tuple)):
405-
return [clean_value(item) for item in v]
406-
elif isinstance(v, dict):
407-
return {k: clean_value(val) for k, val in v.items()}
408-
else:
409-
return v
410-
411-
cleaned_result = {k: clean_value(v) for k, v in result.items()}
411+
cleaned_result = {k: self._clean_value(v) for k, v in result.items()}
412412

413413
# Create document row with all result fields plus required fields
414414
row = {

graphgen/templates/kg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .kg_summarization import KG_SUMMARIZATION_PROMPT
33
from .mm_kg_extraction import MMKG_EXTRACTION_PROMPT
44
from .omics_kg_extraction import OMICS_KG_EXTRACTION_PROMPT
5-
from .protein_kg_extraction import PROTEIN_KG_EXTRACTION_PROMPT
5+
from .protein_kg_extraction import PROTEIN_KG_EXTRACTION_PROMPT

0 commit comments

Comments
 (0)