Skip to content

Commit 346e936

Browse files
authored
App: Move AutoScaler dependency to extra requirements (#15971)
* Make autoscaler dependency optional * update chglog * dont directly import aiohttp
1 parent dd83587 commit 346e936

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

requirements/app/base.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ 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/components.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# deps required by components in the lightning app repository (src/lightning_app/components)
22
lightning_api_access>=0.0.3
3+
aiohttp>=3.8.0, <=3.8.3

src/lightning_app/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1515

1616
-
1717

18+
- Remove the `AutoScaler` dependency `aiohttp` from the base requirements ([#15971](https://github.com/Lightning-AI/lightning/pull/15971))
19+
1820

1921
### Deprecated
2022

src/lightning_app/components/auto_scaler.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from itertools import cycle
99
from typing import Any, Dict, List, Tuple, Type
1010

11-
import aiohttp
12-
import aiohttp.client_exceptions
1311
import requests
1412
import uvicorn
1513
from fastapi import Depends, FastAPI, HTTPException, Request
@@ -22,8 +20,13 @@
2220
from lightning_app.core.flow import LightningFlow
2321
from lightning_app.core.work import LightningWork
2422
from lightning_app.utilities.app_helpers import Logger
23+
from lightning_app.utilities.imports import _is_aiohttp_available, requires
2524
from lightning_app.utilities.packaging.cloud_compute import CloudCompute
2625

26+
if _is_aiohttp_available():
27+
import aiohttp
28+
import aiohttp.client_exceptions
29+
2730
logger = Logger(__name__)
2831

2932

@@ -114,6 +117,7 @@ class _LoadBalancer(LightningWork):
114117
\**kwargs: Arguments passed to :func:`LightningWork.init` like ``CloudCompute``, ``BuildConfig``, etc.
115118
"""
116119

120+
@requires(["aiohttp"])
117121
def __init__(
118122
self,
119123
input_type: BaseModel,

src/lightning_app/utilities/imports.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,8 @@ def _is_sqlmodel_available() -> bool:
141141
return module_available("sqlmodel")
142142

143143

144+
def _is_aiohttp_available() -> bool:
145+
return module_available("aiohttp")
146+
147+
144148
_CLOUD_TEST_RUN = bool(os.getenv("CLOUD", False))

0 commit comments

Comments
 (0)