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

.entities() typedef update #688

Closed
wants to merge 1 commit into from
Closed

.entities() typedef update #688

wants to merge 1 commit into from

Conversation

joeflack4
Copy link
Contributor

Updates

  • Update: Type definition for entities() method type definitions. Was previously just Iterable[CURIE], but it is also possible for it to return URIs.

@@ -97,7 +97,7 @@ def label(self, curie: CURIE, lang: Optional[LANGUAGE_TAG] = None) -> str:
else:
raise ValueError(f"Label must be literal, not {label}")

def entities(self, filter_obsoletes=True, owl_type=None) -> Iterable[CURIE]:
def entities(self, filter_obsoletes=True, owl_type=None) -> Iterable[Union[URI, CURIE]]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The update

This is a minor update. I just happened to notice that while I was using this for SqlImplementation, I was getting back URIs sometimes. I assume this should always be a possible thing for the other implementations as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks @joeflack4 !

@@ -97,7 +97,7 @@ def label(self, curie: CURIE, lang: Optional[LANGUAGE_TAG] = None) -> str:
else:
raise ValueError(f"Label must be literal, not {label}")

def entities(self, filter_obsoletes=True, owl_type=None) -> Iterable[CURIE]:
def entities(self, filter_obsoletes=True, owl_type=None) -> Iterable[Union[URI, CURIE]]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatives?

LinkML has URIorCURIE but I don't know if it's something that should be used here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No The URI and CURIE definition are oaklib specific. So the sis correct.

@@ -97,7 +97,7 @@ def label(self, curie: CURIE, lang: Optional[LANGUAGE_TAG] = None) -> str:
else:
raise ValueError(f"Label must be literal, not {label}")

def entities(self, filter_obsoletes=True, owl_type=None) -> Iterable[CURIE]:
def entities(self, filter_obsoletes=True, owl_type=None) -> Iterable[Union[URI, CURIE]]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Order of types?

This is a super minor thing, but I am going to guess that if there is a Python convention, maybe it should be Union[CURIE, URI] for alphabetical reasons, but I hose Union[URI, CURIE] because that's usually the order we speak them in the semantic web world.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does not matter.

… previously just Iterable[CURIE], but it is also possible for it to return URIs.
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (09bf298) 76.50% compared to head (7e667d8) 76.50%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #688   +/-   ##
=======================================
  Coverage   76.50%   76.50%           
=======================================
  Files         252      252           
  Lines       29368    29368           
=======================================
  Hits        22468    22468           
  Misses       6900     6900           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@hrshdhgd hrshdhgd left a comment

Choose a reason for hiding this comment

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

I think it's good. I'll let @cmungall make the final decision.

@cmungall
Copy link
Collaborator

Hi @joeflack4 - it's best to discuss what you want to do in an issue first. The intent is that CURIEs are input and output. Yes, I know that when using semsql URIs that have no prefixes get turned into quoted URIs (different from URIs), but this should be fixed elsewhere.

Is this a blocker for you?

@joeflack4
Copy link
Contributor Author

joeflack4 commented Dec 19, 2023

@cmungall Not a blocker. Just thought it was a quick way to contribute.

Agreed it's generally good practice to make an issue. I thought this one would be an easy merge and not merit that, but it looks like this does require discussion.

Here are my thoughts (also added to the issue).

Details

I guess you're right, they are "quoted URIs". Here's an example of one I see:

'<http://identifiers.org/hgnc/10004>'

Why don't we add something like QUOTED_URI to oaklib.types?:

CURIE = str
QUOTED_URI = str
URI = str

When you say "should be fixed elsewhere", I assume you are referring to them being "quoted" URI strings rather than plain URI strings. I'm definitely down with that. If you mean that URIs should never be returned (you probably don't), I don't think that's possible 100% of the time.

@joeflack4 joeflack4 linked an issue Dec 19, 2023 that may be closed by this pull request
@cmungall cmungall closed this Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.entities() typedef update
4 participants