From c93952cb2cf395d0b805c8249bb457db5f471570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20W=C3=A4lchli?= Date: Tue, 14 Mar 2023 02:55:32 +0100 Subject: [PATCH] Make BYOT imports forward compatible (#16997) --- examples/fabric/build_your_own_trainer/trainer.py | 9 ++++++--- requirements/app/base.txt | 2 +- requirements/fabric/base.txt | 2 +- requirements/fabric/examples.txt | 1 + requirements/pytorch/base.txt | 2 +- requirements/pytorch/examples.txt | 1 + 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/fabric/build_your_own_trainer/trainer.py b/examples/fabric/build_your_own_trainer/trainer.py index 8619b54404..4b93ea171d 100644 --- a/examples/fabric/build_your_own_trainer/trainer.py +++ b/examples/fabric/build_your_own_trainer/trainer.py @@ -4,11 +4,14 @@ from functools import partial from typing import Any, cast, Iterable, List, Literal, Optional, Tuple, Union import torch -from lightning_utilities.core import apply_to_collection, is_overridden +from lightning_utilities import apply_to_collection, is_overridden from tqdm import tqdm import lightning as L -from lightning.fabric.fabric import _unwrap_objects, Accelerator, Fabric, Logger, Strategy +from lightning.fabric.accelerators import Accelerator +from lightning.fabric.loggers import Logger +from lightning.fabric.strategies import Strategy +from lightning.fabric.wrappers import _unwrap_objects class MyCustomTrainer: @@ -82,7 +85,7 @@ class MyCustomTrainer: callbacks written for the lightning trainer (especially making assumptions on the trainer), won't work! """ - self.fabric = Fabric( + self.fabric = L.Fabric( accelerator=accelerator, strategy=strategy, devices=devices, diff --git a/requirements/app/base.txt b/requirements/app/base.txt index 31f0dd92dc..515e53d5d5 100644 --- a/requirements/app/base.txt +++ b/requirements/app/base.txt @@ -7,7 +7,7 @@ fsspec>=2022.5.0, <=2022.7.1 croniter>=1.3.0, <1.4.0 # strict; TODO: for now until we find something more robust. traitlets>=5.3.0, <5.9.0 arrow>=1.2.0, <1.2.4 -lightning-utilities>=0.7.0, <0.8.0 +lightning-utilities>=0.7.0, <0.9.0 beautifulsoup4>=4.8.0, <4.11.2 inquirer>=2.10.0, <=3.1.2 psutil<5.9.5 diff --git a/requirements/fabric/base.txt b/requirements/fabric/base.txt index c5dc652e09..0b4a002e1f 100644 --- a/requirements/fabric/base.txt +++ b/requirements/fabric/base.txt @@ -6,4 +6,4 @@ torch>=1.11.0, <=2.0.0 fsspec[http]>2021.06.0, <2023.2.0 packaging>=17.1, <=23.0 typing-extensions>=4.0.0, <=4.4.0 -lightning-utilities>=0.7.0, <0.8.0 +lightning-utilities>=0.7.0, <0.9.0 diff --git a/requirements/fabric/examples.txt b/requirements/fabric/examples.txt index f862163fc7..6e9842ae0a 100644 --- a/requirements/fabric/examples.txt +++ b/requirements/fabric/examples.txt @@ -3,3 +3,4 @@ torchvision>=0.10.0, <=0.14.1 torchmetrics>=0.10.0, <0.12.0 +lightning-utilities>=0.8.0, <0.9.0 diff --git a/requirements/pytorch/base.txt b/requirements/pytorch/base.txt index d0c62116df..162e6b8508 100644 --- a/requirements/pytorch/base.txt +++ b/requirements/pytorch/base.txt @@ -9,4 +9,4 @@ fsspec[http]>2021.06.0, <2023.2.0 torchmetrics>=0.7.0, <0.12.0 # needed for using fixed compare_version packaging>=17.1, <=23.0 typing-extensions>=4.0.0, <=4.4.0 -lightning-utilities>=0.7.0, <0.8.0 +lightning-utilities>=0.7.0, <0.9.0 diff --git a/requirements/pytorch/examples.txt b/requirements/pytorch/examples.txt index e4f52ac11b..d432880099 100644 --- a/requirements/pytorch/examples.txt +++ b/requirements/pytorch/examples.txt @@ -5,3 +5,4 @@ torchvision>=0.11.1, <=0.14.1 gym[classic_control]>=0.17.0, <0.26.3 ipython[all] <8.7.1 torchmetrics>=0.10.0, <0.12.0 +lightning-utilities>=0.7.0, <0.9.0