diff --git a/reasoner_pydantic/base_model.py b/reasoner_pydantic/base_model.py index dad0e81..ed8ea6d 100644 --- a/reasoner_pydantic/base_model.py +++ b/reasoner_pydantic/base_model.py @@ -27,6 +27,9 @@ def update(self, other): f"Model {self.__class__.__name__} has no update method" ) + def get_field(self, field): + getattr(self, field, None) + # After running validation on all known properties, make sure everything else is hashable @root_validator(allow_reuse=True, pre=False) def make_hashable_root(cls, values): diff --git a/reasoner_pydantic/kgraph.py b/reasoner_pydantic/kgraph.py index 0f9a8f0..286cf4b 100644 --- a/reasoner_pydantic/kgraph.py +++ b/reasoner_pydantic/kgraph.py @@ -103,7 +103,15 @@ class Config: def update(self, other): if other.attributes: if self.attributes: - self.attributes.update(other.attributes) + # We need to make sure we don't add a second KL/AT + new_attributes = HashableSet[Attribute] + for attribute in other.attributes: + if attribute.attribute_type_id not in ( + "biolink:knowledge_level", + "biolink:agent_type", + ): + new_attributes.add(attribute) + self.attributes.update(new_attributes) else: self.attributes = other.attributes if other.sources: diff --git a/setup.py b/setup.py index 9fb04a1..fa7eb62 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name="reasoner-pydantic", - version="5.0.4", + version="5.0.5", author="Abrar Mesbah", author_email="amesbah@covar.com", url="https://github.com/TranslatorSRI/reasoner-pydantic",