diff --git a/requirements/app/base.txt b/requirements/app/base.txt index 37e91689bb54d..9590f2c1a2fbd 100644 --- a/requirements/app/base.txt +++ b/requirements/app/base.txt @@ -12,4 +12,3 @@ 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 diff --git a/requirements/app/components.txt b/requirements/app/components.txt index 38180a480a59b..dd2cadfc1c17e 100644 --- a/requirements/app/components.txt +++ b/requirements/app/components.txt @@ -1,2 +1,3 @@ # deps required by components in the lightning app repository (src/lightning_app/components) lightning_api_access>=0.0.3 +aiohttp>=3.8.0, <=3.8.3 diff --git a/src/lightning_app/CHANGELOG.md b/src/lightning_app/CHANGELOG.md index 889bf82b8e42a..05240adc46668 100644 --- a/src/lightning_app/CHANGELOG.md +++ b/src/lightning_app/CHANGELOG.md @@ -43,6 +43,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Apps without UIs no longer activate the "Open App" button when running in the cloud ([#15875](https://github.com/Lightning-AI/lightning/pull/15875)) +- Remove the `AutoScaler` dependency `aiohttp` from the base requirements ([#15971](https://github.com/Lightning-AI/lightning/pull/15971)) + ### Deprecated diff --git a/src/lightning_app/components/auto_scaler.py b/src/lightning_app/components/auto_scaler.py index 62e6180c49665..629e771c50600 100644 --- a/src/lightning_app/components/auto_scaler.py +++ b/src/lightning_app/components/auto_scaler.py @@ -8,8 +8,6 @@ from itertools import cycle from typing import Any, Dict, List, Tuple, Type -import aiohttp -import aiohttp.client_exceptions import requests import uvicorn from fastapi import Depends, FastAPI, HTTPException, Request @@ -22,8 +20,13 @@ from lightning_app.core.flow import LightningFlow from lightning_app.core.work import LightningWork from lightning_app.utilities.app_helpers import Logger +from lightning_app.utilities.imports import _is_aiohttp_available, requires from lightning_app.utilities.packaging.cloud_compute import CloudCompute +if _is_aiohttp_available(): + import aiohttp + import aiohttp.client_exceptions + logger = Logger(__name__) @@ -114,6 +117,7 @@ class _LoadBalancer(LightningWork): \**kwargs: Arguments passed to :func:`LightningWork.init` like ``CloudCompute``, ``BuildConfig``, etc. """ + @requires(["aiohttp"]) def __init__( self, input_type: BaseModel, diff --git a/src/lightning_app/utilities/imports.py b/src/lightning_app/utilities/imports.py index b484110d3811e..19978fcf5d137 100644 --- a/src/lightning_app/utilities/imports.py +++ b/src/lightning_app/utilities/imports.py @@ -141,4 +141,8 @@ def _is_sqlmodel_available() -> bool: return module_available("sqlmodel") +def _is_aiohttp_available() -> bool: + return module_available("aiohttp") + + _CLOUD_TEST_RUN = bool(os.getenv("CLOUD", False))