graph2mat.tools.server.server_app
Implements a fastapi server API that accepts requests to predict matrices.
Functions
|
Creates a flask app to listen to requests and predict matrices. |
Launches a server that serves predictions from trained models stored in checkpoint files. |
Classes
- class graph2mat.tools.server.server_app.ModelSpecification[source]
Bases:
TypedDict
- data_processor: MatrixDataProcessor
- graph2mat.tools.server.server_app.create_server_app(models: Dict[str, ModelSpecification], local: bool = False) FastAPI [source]
Creates a flask app to listen to requests and predict matrices.
The app is to be ran with uvicorn. For example:
>>> import uvicorn >>> models = {} >>> app = server_app(models) >>> uvicorn.run(app, host="localhost", port=56000)
- Parameters:
models (Dict[str, ModelSpecification]) – A dictionary with the models to be used. The keys are the names of the models, and the values are dictionaries with everything that we need/know about the model.
local (bool, optional) – If True, the server allows the user to ask for changes in the local file system.
- graph2mat.tools.server.server_app.create_server_app_from_filesystem(model_files: Dict[str, str] = {}, local: bool = False, cpu: bool = True)[source]
Launches a server that serves predictions from trained models stored in checkpoint files.
This function just builds the dictionary of models from the ckpt files and then calls
server_app
.