From b29355c6e58aa4323e76e89bfa4eb027f97027b5 Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Thu, 8 Dec 2022 13:38:27 +0900 Subject: [PATCH] [docs] Include all components in the API reference (#15805) * Update docs Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com> (cherry picked from commit e6f4c8484baaa82e75cfd37d1719ecfadb04a7d9) --- docs/source-app/api_references.rst | 8 +++++++ .../components/serve/python_server.py | 24 +++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/docs/source-app/api_references.rst b/docs/source-app/api_references.rst index 2540633838502..2272f7bf13c41 100644 --- a/docs/source-app/api_references.rst +++ b/docs/source-app/api_references.rst @@ -32,11 +32,19 @@ ___________________ :nosignatures: :template: classtemplate_no_index.rst + ~database.client.DatabaseClient + ~database.server.Database ~python.popen.PopenPythonScript ~python.tracer.TracerPythonScript ~training.LightningTrainerScript ~serve.gradio.ServeGradio ~serve.serve.ModelInferenceAPI + ~serve.python_server.PythonServer + ~serve.streamlit.ServeStreamlit + ~multi_node.base.MultiNode + ~multi_node.lite.LiteMultiNode + ~multi_node.pytorch_spawn.PyTorchSpawnMultiNode + ~multi_node.trainer.LightningTrainerMultiNode ~auto_scaler.AutoScaler ---- diff --git a/src/lightning_app/components/serve/python_server.py b/src/lightning_app/components/serve/python_server.py index 99d51ac1cf4fc..209135e27f0c1 100644 --- a/src/lightning_app/components/serve/python_server.py +++ b/src/lightning_app/components/serve/python_server.py @@ -114,26 +114,26 @@ def __init__( # type: ignore The default data type is good enough for the basic usecases and it expects the data to be a json object that has one key called `payload` - ``` - input_data = {"payload": "some data"} - ``` + .. code-block:: python + + input_data = {"payload": "some data"} and this can be accessed as `request.payload` in the `predict` method. - ``` - def predict(self, request): - data = request.payload - ``` + .. code-block:: python + + def predict(self, request): + data = request.payload output_type: Optional `output_type` to be provided. This needs to be a pydantic BaseModel class. The default data type is good enough for the basic usecases. It expects the return value of the `predict` method to be a dictionary with one key called `prediction`. - ``` - def predict(self, request): - # some code - return {"prediction": "some data"} - ``` + .. code-block:: python + + def predict(self, request): + # some code + return {"prediction": "some data"} and this can be accessed as `response.json()["prediction"]` in the client if you are using requests library