Closed anitacaron closed 2 years ago
Big oversight on my part: I didn't realize at first that get_sssom_mappings_by_curie
is already a method on SparqlImplementation
(actually via its superclass AbstractSparqlImplementation
). It looks like the implementation here is adding some additional where
clauses to the query. I wonder if that's functionality that would be useful to have in the OAK library core. I'll take a look at it and if it makes sense to do that this can be simplified considerably. But don't let that hold up these changes in the meantime.
Thank you for the comments, Patrick!
The idea is to replace the get_sssom_mappings_by_curie
in AbstractSparqlImplementation
! The query is written differently from the RDF we get from the sssom-py. This method is related to SSSOM but does not use the RDF structure expected/generated by sssom-py lib. Also, we might need to add an OPTIONAL attribute to the SparqlQuery
class to retrieve all optional fields from SSSOM.
I'm going to check FastAPI's Query
. It makes sense to use it in this case. Thanks!
Overall this looks like a nice start! I just have two comments:
SparqImpl
class insrc/database/sparql_implementation.py
. Maybe there are future plans for it that I'm failing to grasp, but it seems like a bit of an unneeded abstraction on top of its superclass,SparqlImplementation
. SinceSparqImpl
doesn't hold any state, I could easily imagine the work being done inget_sssom_mappings_by_curie
moved to theget_mappings
function and haveget_mappings
accept aSparqlImplementation
instance instead. I wonder if perhaps the hesitation to do it that way was because of accessing the "private" members_sparql_values
and_parse
. It might be a conversation to have with the OAK development team about why those are underscored.Query
and itsregex
parameter: https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#add-regular-expressions.Query
can be used either with or withoutDepends
(Depends
is helpful if many endpoints will need the same parameter validation, otherwise directly usingQuery
in the response handler parameters is probably fine). UsingQuery
might give better error response handling out-of-the-box.