newgene / bte-py

0 stars 0 forks source link

Create a new version of call-apis module #1

Open newgene opened 4 months ago

newgene commented 4 months ago

We want to create a new module, let's call it call-apis_v2 module for now. It can be at a new folder of biothings_explorer.call-apis_v2 for now.

Class SmartAPI:
    url    # https://raw.githubusercontent.com/NCATS-Tangerine/translator-api-registry/master/mygene.info/openapi_full.yml
    metadata # content of the above url, the OpenAPI metadata of this API
    metakg # parsed metakg object for this API, see below

    def list_metakg(self):
           <return a list of metakg edges from self.metakg>

    def get_edge(self, one_metakg_edge, input_id):
          <call API with the input_id, based on one_metakg_edge, process response, then return response edge(s)>

    def get_edges(self, one_metakg_edge, a_list_of_input_ids):
          <batch of the get_edge>

Parsing of the metakg can reference this get_metakg method, using utils.metakg.parser (which is a slightly modified version of smartapi-kg module here): https://github.com/SmartAPI/smartAPI/blob/aaebe5ac65b9cf67987afb1c69b2387960fce83e/src/controller/smartapi.py#L378

Let's start with this one API, there will be other types of APIs in the future (e.g. TRAPI APIs, or APIs with different metakg fields).

newgene commented 4 months ago

A reference metakg object for the above API is here:

https://github.com/newgene/bte-py/blob/main/mygene_metakg.json

newgene commented 4 months ago

we should also have a validate_metakg method to validate bte.query_operation against the API metadata, e.g. api endpoint, parameters should match.