biothings / biothings_explorer

TRAPI service for BioThings Explorer
https://explorer.biothings.io
Apache License 2.0
10 stars 11 forks source link

Use globally-loaded metakg /v1/meta_knowledge_graph endpoint #851

Open tokebe opened 3 months ago

tokebe commented 3 months ago

As of https://github.com/biothings/bte-server/pull/21, the metakg is globally-loaded to avoid reading the locally-cached file while it's being written (and to short-cut the extra time of having to re-parse a large file).

The /v1/meta_knowledge_graph endpoint does not currently attempt to make use of this and so occasionally will fail with an 'unexpected end of json input'. A simple fix should be to read from the global metakg.

tokebe commented 3 months ago

Relatedly, it appears the file is still read in findUnregisteredAPIs(), leading to the same error on occasion. If possible, this should also be changed to avoid re-reading the file.

rjawesome commented 3 months ago

findUnregisteredAPIs should not be reading the file since it is supposed to use options.smartapi (https://github.com/biothings/bte_trapi_query_graph_handler/blob/5789f6c0ff426fbcbcbf01a5fa061687f094ea56/src/index.ts#L78). However, it would be a good idea to confirm this behavior is working as intended and that the option is passed correctly in the BTE server.

NeuralFlux commented 3 months ago

@tokebe we pass options when we call findUnregisteredAPIs() in query routes. According to this, options should have a valid smartapi unless it's the initial startup phase. Does that suffice?

tokebe commented 3 months ago

Yes, that should suffice so long as you have file fallback implemented.

NeuralFlux commented 3 months ago

This seems like it, right?