ranking-agent / aragorn-ranker

Exposes TRAPI functions to add literature co-occurrence edges, convert publications to edge weights, and provide scores for answers.
MIT License
0 stars 1 forks source link

Output data returns "key": null #5

Closed PhillipsOwen closed 4 years ago

PhillipsOwen commented 4 years ago

the output of omnicorp-overlay returns a node with the property "curie": null.

not only is this bad json it should not even return properties that do not have a value.

patrickkwang commented 4 years ago

Pydantic and FastAPI do this, they treat key: None as if key were absent. I don't know that it's a problem really, as long as the client is prepared to deal with it. But there may be a way to change this behavior.

patrickkwang commented 4 years ago

https://pydantic-docs.helpmanual.io/usage/exporting_models/ See exclude_unset and/or exclude_none.

PhillipsOwen commented 4 years ago

the model exporting worked after some tweaking. however since the API specified the Message pydantic model it always reverted back to including the None keys.

the solution i chose was to use"response_model_exclude_none=True" in the post definition. e.g.

APP.post('/' + operation, response_model=Message, response_model_exclude_none=True)(log_exception(md.query))