Skip to content

Commit

Permalink
dependencies (#15994)
Browse files Browse the repository at this point in the history
* dependencies

* 0.0.4

* CI: hotfix signal if (#15995)

signal if

(cherry picked from commit 1706ccd)

* revert

* [App] Fix import errors for the packages installed by shebang (#15996)

* import fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* import fix

* move req

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update requirements/app/base.txt

* revert

* skip doctest

* import fix

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jirka <jirka.borovec@seznam.cz>
(cherry picked from commit 4bdc185)

Co-authored-by: Sherin Thomas <sherin@lightning.ai>
  • Loading branch information
Borda and Sherin Thomas committed Dec 9, 2022
1 parent 6a39743 commit db10422
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
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
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

0 comments on commit db10422

Please sign in to comment.