Skip to content

Commit

Permalink
refactor: further nesting in curation_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Palucha committed Oct 3, 2024
1 parent 4fc4f19 commit 680e22d
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions kazu/ontology_preprocessing/curation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,7 @@ def _update_candidate_lookups(
for idx in equiv_ids.ids:
self._candidates_by_id[idx].add(candidate)
return LinkingCandidateModificationResult.LINKING_CANDIDATE_ADDED
else:
return LinkingCandidateModificationResult.NO_ACTION
return LinkingCandidateModificationResult.NO_ACTION

def _drop_linking_candidate(self, synonym: NormalisedSynonymStr) -> None:
"""Remove a linking candidate from the database, so that it cannot be used as a
Expand Down Expand Up @@ -883,10 +882,9 @@ def _drop_id_from_linking_candidate(
== 0
):
return LinkingCandidateModificationResult.NO_ACTION
else:
return self._modify_or_drop_linking_candidate_after_id_set_change(
new_associated_id_sets=new_assoc_id_frozenset, candidate=candidate_to_modify
)
return self._modify_or_drop_linking_candidate_after_id_set_change(
new_associated_id_sets=new_assoc_id_frozenset, candidate=candidate_to_modify
)

def _drop_id_from_associated_id_sets(
self, id_to_drop: Idx, associated_id_sets: AssociatedIdSets
Expand Down Expand Up @@ -986,8 +984,7 @@ def _process_resource_action(
raise ValueError(f"unknown behaviour for parser {self.parser_name}, {resource}")
if result is LinkingCandidateModificationResult.LINKING_CANDIDATE_DROPPED:
return None
else:
return resource
return resource

def _process_global_actions(self) -> None:
if self.global_actions is None:
Expand Down Expand Up @@ -1135,12 +1132,12 @@ def _attempt_to_add_database_entry_for_resource(
log_formatting_dict,
)
return LinkingCandidateModificationResult.NO_ACTION
else:
logger.debug(
log_prefix
+ " . Will remove existing syn_norm <%(syn_norm)s> as an ID set override has been specified",
log_formatting_dict,
)

logger.debug(
log_prefix
+ " . Will remove existing syn_norm <%(syn_norm)s> as an ID set override has been specified",
log_formatting_dict,
)

# no candidate exists, or we want to override so one will be made
assert resource_associated_id_set is not None
Expand Down Expand Up @@ -1169,5 +1166,4 @@ def _attempt_to_add_database_entry_for_resource(
aggregated_by=EquivalentIdAggregationStrategy.MODIFIED_BY_CURATION,
)
return self._update_candidate_lookups(new_candidate, True)
else:
return LinkingCandidateModificationResult.NO_ACTION
return LinkingCandidateModificationResult.NO_ACTION

0 comments on commit 680e22d

Please sign in to comment.