Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

dependencies #15994

Merged
merged 5 commits into from Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release-pypi.yml
Expand Up @@ -92,6 +92,7 @@ jobs:
signaling:
runs-on: ubuntu-20.04
needs: [release-version]
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
env:
TAG: ${{ needs.release-version.outputs.tag }}
steps:
Expand Down
1 change: 1 addition & 0 deletions requirements/app/base.txt
Expand Up @@ -12,3 +12,4 @@ beautifulsoup4>=4.8.0, <4.11.2
inquirer>=2.10.0
psutil<5.9.4
click<=8.1.3
aiohttp>=3.8.0, <=3.8.3
1 change: 0 additions & 1 deletion requirements/app/cloud.txt
Expand Up @@ -4,4 +4,3 @@ redis>=4.0.1, <=4.2.4
docker>=5.0.0, <=5.0.3
# setuptools==59.5.0
s3fs>=2022.5.0, <2022.8.3
aiohttp>=3.8.0, <=3.8.3
Borda marked this conversation as resolved.
Show resolved Hide resolved
57 changes: 29 additions & 28 deletions src/lightning_app/components/serve/python_server.py
Expand Up @@ -7,7 +7,7 @@

import uvicorn
from fastapi import FastAPI
from lightning_utilities.core.imports import compare_version, module_available
from lightning_utilities.core.imports import compare_version
from pydantic import BaseModel

from lightning_app.core.work import LightningWork
Expand All @@ -16,10 +16,8 @@

logger = Logger(__name__)

__doctest_skip__ = []
# Skip doctests if requirements aren't available
if not module_available("lightning_api_access"):
__doctest_skip__ += ["PythonServer", "PythonServer.*"]
__doctest_skip__ = ["PythonServer", "PythonServer.*"]


# Skip doctests if requirements aren't available
if not _is_torch_available():
Expand Down Expand Up @@ -72,7 +70,7 @@ class PythonServer(LightningWork, abc.ABC):

_start_method = "spawn"

@requires(["torch", "lightning_api_access"])
@requires(["torch"])
def __init__( # type: ignore
self,
input_type: type = _DefaultInputData,
Expand Down Expand Up @@ -193,29 +191,32 @@ def predict_fn(request: input_type): # type: ignore
fastapi_app.post("/predict", response_model=output_type)(predict_fn)

def configure_layout(self) -> None:
if module_available("lightning_api_access"):
try:
from lightning_api_access import APIAccessFrontend

class_name = self.__class__.__name__
url = f"{self.url}/predict"

try:
request = self._get_sample_dict_from_datatype(self.configure_input_type())
response = self._get_sample_dict_from_datatype(self.configure_output_type())
except TypeError:
return None

return APIAccessFrontend(
apis=[
{
"name": class_name,
"url": url,
"method": "POST",
"request": request,
"response": response,
}
]
)
except ModuleNotFoundError:
logger.warn("APIAccessFrontend not found. Please install lightning-api-access to enable the UI")
return

class_name = self.__class__.__name__
url = f"{self.url}/predict"

try:
request = self._get_sample_dict_from_datatype(self.configure_input_type())
response = self._get_sample_dict_from_datatype(self.configure_output_type())
except TypeError:
return None

return APIAccessFrontend(
apis=[
{
"name": class_name,
"url": url,
"method": "POST",
"request": request,
"response": response,
}
]
)

def run(self, *args: Any, **kwargs: Any) -> Any:
"""Run method takes care of configuring and setting up a FastAPI server behind the scenes.
Expand Down