Skip to content

Commit db10422

Browse files
BordaSherin Thomas
andauthored
dependencies (#15994)
* 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 <[email protected]> (cherry picked from commit 4bdc185) Co-authored-by: Sherin Thomas <[email protected]>
1 parent 6a39743 commit db10422

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

.github/workflows/release-pypi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ jobs:
9292
signaling:
9393
runs-on: ubuntu-20.04
9494
needs: [release-version]
95+
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
9596
env:
9697
TAG: ${{ needs.release-version.outputs.tag }}
9798
steps:

requirements/app/base.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ beautifulsoup4>=4.8.0, <4.11.2
1212
inquirer>=2.10.0
1313
psutil<5.9.4
1414
click<=8.1.3
15+
aiohttp>=3.8.0, <=3.8.3

requirements/app/cloud.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ redis>=4.0.1, <=4.2.4
44
docker>=5.0.0, <=5.0.3
55
# setuptools==59.5.0
66
s3fs>=2022.5.0, <2022.8.3
7-
aiohttp>=3.8.0, <=3.8.3

src/lightning_app/components/serve/python_server.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import uvicorn
99
from fastapi import FastAPI
10-
from lightning_utilities.core.imports import compare_version, module_available
10+
from lightning_utilities.core.imports import compare_version
1111
from pydantic import BaseModel
1212

1313
from lightning_app.core.work import LightningWork
@@ -16,10 +16,8 @@
1616

1717
logger = Logger(__name__)
1818

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

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

7371
_start_method = "spawn"
7472

75-
@requires(["torch", "lightning_api_access"])
73+
@requires(["torch"])
7674
def __init__( # type: ignore
7775
self,
7876
input_type: type = _DefaultInputData,
@@ -193,29 +191,32 @@ def predict_fn(request: input_type): # type: ignore
193191
fastapi_app.post("/predict", response_model=output_type)(predict_fn)
194192

195193
def configure_layout(self) -> None:
196-
if module_available("lightning_api_access"):
194+
try:
197195
from lightning_api_access import APIAccessFrontend
198-
199-
class_name = self.__class__.__name__
200-
url = f"{self.url}/predict"
201-
202-
try:
203-
request = self._get_sample_dict_from_datatype(self.configure_input_type())
204-
response = self._get_sample_dict_from_datatype(self.configure_output_type())
205-
except TypeError:
206-
return None
207-
208-
return APIAccessFrontend(
209-
apis=[
210-
{
211-
"name": class_name,
212-
"url": url,
213-
"method": "POST",
214-
"request": request,
215-
"response": response,
216-
}
217-
]
218-
)
196+
except ModuleNotFoundError:
197+
logger.warn("APIAccessFrontend not found. Please install lightning-api-access to enable the UI")
198+
return
199+
200+
class_name = self.__class__.__name__
201+
url = f"{self.url}/predict"
202+
203+
try:
204+
request = self._get_sample_dict_from_datatype(self.configure_input_type())
205+
response = self._get_sample_dict_from_datatype(self.configure_output_type())
206+
except TypeError:
207+
return None
208+
209+
return APIAccessFrontend(
210+
apis=[
211+
{
212+
"name": class_name,
213+
"url": url,
214+
"method": "POST",
215+
"request": request,
216+
"response": response,
217+
}
218+
]
219+
)
219220

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

0 commit comments

Comments
 (0)