Skip to content

Commit

Permalink
App: Move AutoScaler dependency to extra requirements (#15971)
Browse files Browse the repository at this point in the history
* Make autoscaler dependency optional
* update chglog
* dont directly import aiohttp
  • Loading branch information
akihironitta authored Dec 9, 2022
1 parent dd83587 commit 346e936
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
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
aiohttp>=3.8.0, <=3.8.3
1 change: 1 addition & 0 deletions requirements/app/components.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/lightning_app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

-

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


### Deprecated

Expand Down
8 changes: 6 additions & 2 deletions src/lightning_app/components/auto_scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)


Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/lightning_app/utilities/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit 346e936

Please sign in to comment.