Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kl/at merging #82

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions reasoner_pydantic/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def update(self, other):
f"Model {self.__class__.__name__} has no update method"
)

def get_field(self, field):
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this used for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was originally going to use this method, but this is what we had discussed before, which provides a method to get an arbitrary field, if it exists for that model.

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):
Expand Down
10 changes: 9 additions & 1 deletion reasoner_pydantic/kgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="reasoner-pydantic",
version="5.0.4",
version="5.0.5",
author="Abrar Mesbah",
author_email="[email protected]",
url="https://github.com/TranslatorSRI/reasoner-pydantic",
Expand Down
Loading