Skip to content

Commit 8038c7a

Browse files
akihironittaBorda
authored andcommitted
App: Move AutoScaler dependency to extra requirements (#15971)
* Make autoscaler dependency optional * update chglog * dont directly import aiohttp (cherry picked from commit 346e936) # Conflicts: # requirements/app/base.txt # src/lightning_app/CHANGELOG.md
1 parent 81ff938 commit 8038c7a

File tree

6 files changed

+17
-5
lines changed

6 files changed

+17
-5
lines changed

requirements/app/base.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +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-
s3fs>=2022.5.0, <2022.8.3
16-
aiohttp>=3.8.0, <=3.8.3

requirements/app/cloud.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
redis>=4.0.1, <=4.2.4
44
docker>=5.0.0, <=5.0.3
55
# setuptools==59.5.0
6+
s3fs>=2022.5.0, <2022.8.3
7+
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1313
- Added the CLI command `lightning delete app` to delete a lightning app on the cloud ([#15783](https://github.com/Lightning-AI/lightning/pull/15783))
1414
- Added a CloudMultiProcessBackend which enables running a child App from within the Flow in the cloud ([#15800](https://github.com/Lightning-AI/lightning/pull/15800))
1515
- Utility for pickling work object safely even from a child process ([#15836](https://github.com/Lightning-AI/lightning/pull/15836))
16-
- Added `AutoScaler` component ([#15769](https://github.com/Lightning-AI/lightning/pull/15769))
16+
- Added `AutoScaler` component (
17+
[#15769](https://github.com/Lightning-AI/lightning/pull/15769),
18+
[#15971](https://github.com/Lightning-AI/lightning/pull/15971)
19+
)
1720
- Added the property `ready` of the LightningFlow to inform when the `Open App` should be visible ([#15921](https://github.com/Lightning-AI/lightning/pull/15921))
1821
- Added private work attributed `_start_method` to customize how to start the works ([#15923](https://github.com/Lightning-AI/lightning/pull/15923))
1922
- Added a `configure_layout` method to the `LightningWork` which can be used to control how the work is handled in the layout of a parent flow ([#15926](https://github.com/Lightning-AI/lightning/pull/15926))

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)