Skip to content

Flora Parser Bugs #112

Description

@abhishekreddyallu

FLORA parser workflows have optional-file guard and dataset-shape inconsistencies

1. OpenEA attribute file guard is inverted

Location: ontoaligner/ontology/kg.py:1028

Current code:

if not attribute_path:
            with open(attribute_path, 'r', encoding='UTF-8') as attribute_file:

This skips valid attribute files and tries to open None when no attribute file is provided.

Observed before fix:

Case 1: attribute path is provided
BUG: no FileNotFoundError, so attribute_path was ignored

Case 2: attribute path is None
BUG: TypeError expected str, bytes or os.PathLike object, not NoneType

Fix:

if attribute_path:
      with open(attribute_path, 'r', encoding='UTF-8') as attribute_file:

2. OpenEA dataset output shape breaks FLORAEncoder

Location: ontoaligner/ontology/kg.py:1644-1645

Current code:

"source": source_kg,
"target": target_kg,

But FLORAEncoder expects:

kwargs["source"][0]["graph"]
kwargs["target"][0]["graph"]

Observed before fix:

source type: <class 'dict'>
target type: <class 'dict'>
FAIL: KeyError 0

Fix:

"source": [source_kg],
"target": [target_kg],

Verified after fix:

source type: <class 'list'>
target type: <class 'list'>
PASS: FLORAEncoder accepted OpenEA dataset output
encoded length: 2
encoded[0] type: <class 'ontoaligner.ontology.kg.Graph'>
encoded[1] type: <class 'ontoaligner.ontology.kg.Graph'>

3. DBpedia optional translated names and attributes use inverted guards

Locations: ontoaligner/ontology/kg.py:1188, ontoaligner/ontology/kg.py:1222

Current code:

if (not translated_name_path) and ent_ids_path.endswith('_1'):
    ent_name_trans = {}
                with open(translated_name_path, encoding='UTF-8') as f2:

and:

if not att_triples_path:
   for triple in parse_turtle_triples(att_triples_path):

This ignores provided optional files and crashes when optional paths are missing.

Observed before fix:

translated label loaded: False
attribute triple loaded: False
FAIL: TypeError expected str, bytes or os.PathLike object, not NoneType

Fix:

if translated_name_path and ent_ids_path.endswith('_1'):

and:

if att_triples_path:

Verified after fix:

translated label loaded: True
attribute triple loaded: True
PASS: optional paths did not crash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions