allennlp.service.db

Database utilities for the service

class allennlp.service.db.DemoDatabase[source]

Bases: object

This class represents a database backing the demo server. Currently it is used to store predictions, in order to enable permalinks. In the future it could also be used to store user-submitted feedback about predictions.

add_result(headers: typing.Dict[str, typing.Any], model_name: str, inputs: typing.Dict[str, typing.Any], outputs: typing.Dict[str, typing.Any]) → typing.Union[int, NoneType][source]

Add the prediction to the database so that it can later be retrieved via permalink.

classmethod from_environment() → typing.Union[_ForwardRef('DemoDatabase'), NoneType][source]

Instantiate a database using parameters (host, port, user, password, etc...) from environment variables.

get_result(perma_id: int) → allennlp.service.permalinks.Permadata[source]

Gets the result from the database with the given id. Returns None if no such result.

class allennlp.service.db.InMemoryDemoDatabase[source]

Bases: allennlp.service.db.DemoDatabase

This is just for unit tests, please don’t use it in production.

add_result(headers: typing.Dict[str, typing.Any], model_name: str, inputs: typing.Dict[str, typing.Any], outputs: typing.Dict[str, typing.Any]) → typing.Union[int, NoneType][source]
classmethod from_environment() → typing.Union[_ForwardRef('InMemoryDemoDatabase'), NoneType][source]
get_result(perma_id: int) → allennlp.service.permalinks.Permadata[source]
class allennlp.service.db.PostgresDemoDatabase(dbname: str, host: str, port: str, user: str, password: str) → None[source]

Bases: allennlp.service.db.DemoDatabase

Concrete Postgres implementation.

add_result(headers: typing.Dict[str, typing.Any], model_name: str, inputs: typing.Dict[str, typing.Any], outputs: typing.Dict[str, typing.Any]) → typing.Union[int, NoneType][source]
classmethod from_environment() → typing.Union[_ForwardRef('PostgresDemoDatabase'), NoneType][source]
get_result(perma_id: int) → typing.Union[allennlp.service.permalinks.Permadata, NoneType][source]