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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving lightning_api_access out of base requirements #15844

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements/app/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ beautifulsoup4>=4.8.0, <4.11.2
inquirer>=2.10.0
psutil<5.9.4
click<=8.1.3
lightning_api_access>=0.0.1
2 changes: 2 additions & 0 deletions requirements/app/components.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# deps required by components in the lightning app repository (src/lightning_app/components)
lightning_api_access>=0.0.1
3 changes: 3 additions & 0 deletions requirements/app/devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
# extended list of dependencies for UI
-r ./ui.txt

# extended list of dependencies for UI
-r ./components.txt

-r ./examples.txt
10 changes: 9 additions & 1 deletion src/lightning_app/components/serve/python_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
from pathlib import Path
from typing import Any, Dict, Optional

import torch
import uvicorn
from fastapi import FastAPI
from lightning_utilities.core.imports import module_available
from pydantic import BaseModel
from starlette.staticfiles import StaticFiles

from lightning_app.core.queues import MultiProcessQueue
from lightning_app.core.work import LightningWork
from lightning_app.utilities.app_helpers import Logger
from lightning_app.utilities.imports import requires
from lightning_app.utilities.proxies import _proxy_setattr, unwrap, WorkRunExecutor, WorkStateObserver

logger = Logger(__name__)

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


class _PyTorchSpawnRunExecutor(WorkRunExecutor):

Expand Down Expand Up @@ -86,6 +91,7 @@ def _get_sample_data() -> Dict[Any, Any]:


class PythonServer(LightningWork, abc.ABC):
@requires("lightning_api_access")
def __init__( # type: ignore
self,
host: str = "127.0.0.1",
Expand Down Expand Up @@ -203,6 +209,8 @@ def _attach_predict_fn(self, fastapi_app: FastAPI) -> None:
output_type: type = self.configure_output_type()

def predict_fn(request: input_type): # type: ignore
import torch

with torch.inference_mode():
return self.predict(request)

Expand Down