apply_func has been moved, need to update import
lizziesilver opened this issue · 5 comments
apply_func
has been moved out of pytorch_lightning
, so this import no longer works:
I think it has been moved to lightning_utilities
so the line just needs to be replaced with:
from lightning_utilities.core.apply_func import apply_to_collection
Right now the import error prevents me from importing flash
. When I run import flash
in a notebook I get:
ModuleNotFoundError Traceback (most recent call last)
Cell In [4], line 1
----> 1 import flash
2 flash.__version__
File /opt/conda/lib/python3.9/site-packages/flash/__init__.py:22
18 from flash.core.utilities.imports import _TORCH_AVAILABLE
20 if _TORCH_AVAILABLE:
---> 22 from flash.core.data.callback import FlashCallback
23 from flash.core.data.data_module import DataModule
24 from flash.core.data.io.input import DataKeys, Input
File /opt/conda/lib/python3.9/site-packages/flash/core/data/callback.py:8
5 from torch import Tensor
7 import flash
----> 8 from flash.core.data.utils import _STAGES_PREFIX
9 from flash.core.utilities.stages import RunningStage
12 class FlashCallback(Callback):
File /opt/conda/lib/python3.9/site-packages/flash/core/data/utils.py:22
20 import requests
21 import urllib3
---> 22 from pytorch_lightning.utilities.apply_func import apply_to_collection
23 from torch import nn
24 from tqdm.auto import tqdm as tq
ModuleNotFoundError: No module named 'pytorch_lightning.utilities.apply_func'
When I install via pip, it installs pytorch_lightning
version 2.0.0, and this issue occurs.
However when I install via git, it installs pytorch_lightning
version 1.8.6, at which point apply_to_collection
was still in the original location, so the issue does not occur.
I've forked the repo and I was planning to write a one-line PR, but I'm not sure how to ensure the pytorch_lightning
dependency is updated as this fix is made - or what else might break if that dependency is updated. So for now I'll just install via git.
@lizziesilver I think the version pinning here https://github.com/Lightning-Universe/lightning-flash/blob/master/requirements.txt should prevent flash from installing lightning 2.0 (which flash is not compatible with). @Borda Any idea how this could have happened?
pipdeptree:
lightning-flash==0.8.1.post0
- click [required: >=7.1.2, installed: 8.1.3]
- fsspec [required: Any, installed: 2023.3.0]
- jsonargparse [required: >=3.17.0,<=4.9.0, installed: 4.9.0]
- PyYAML [required: >=3.13, installed: 6.0]
- lightning-utilities [required: >=0.3.0, installed: 0.8.0]
- packaging [required: >=17.1, installed: 23.0]
- typing-extensions [required: Any, installed: 4.5.0]
- numpy [required: <1.24, installed: 1.23.5]
- packaging [required: Any, installed: 23.0]
- pandas [required: >=1.1.0, installed: 2.0.0]
- numpy [required: >=1.21.0, installed: 1.23.5]
- python-dateutil [required: >=2.8.2, installed: 2.8.2]
- six [required: >=1.5, installed: 1.16.0]
- pytz [required: >=2020.1, installed: 2023.3]
- tzdata [required: >=2022.1, installed: 2023.3]
- protobuf [required: <=3.20.1, installed: 3.20.1]
- pyDeprecate [required: Any, installed: 0.3.2]
- pytorch-lightning [required: >=1.3.6, installed: 2.0.1]
- fsspec [required: >2021.06.0, installed: 2023.3.0]
- lightning-utilities [required: >=0.7.0, installed: 0.8.0]
- packaging [required: >=17.1, installed: 23.0]
- typing-extensions [required: Any, installed: 4.5.0]
- numpy [required: >=1.17.2, installed: 1.23.5]
- packaging [required: >=17.1, installed: 23.0]
- PyYAML [required: >=5.4, installed: 6.0]
- torch [required: >=1.11.0, installed: 2.0.0]
- filelock [required: Any, installed: 3.10.7]
- jinja2 [required: Any, installed: 3.1.2]
- MarkupSafe [required: >=2.0, installed: 2.1.2]
- networkx [required: Any, installed: 3.1]
- sympy [required: Any, installed: 1.11.1]
- mpmath [required: >=0.19, installed: 1.3.0]
- typing-extensions [required: Any, installed: 4.5.0]
- torchmetrics [required: >=0.7.0, installed: 0.10.3]
- numpy [required: >=1.17.2, installed: 1.23.5]
- packaging [required: Any, installed: 23.0]
- torch [required: >=1.3.1, installed: 2.0.0]
- filelock [required: Any, installed: 3.10.7]
- jinja2 [required: Any, installed: 3.1.2]
- MarkupSafe [required: >=2.0, installed: 2.1.2]
- networkx [required: Any, installed: 3.1]
- sympy [required: Any, installed: 1.11.1]
- mpmath [required: >=0.19, installed: 1.3.0]
- typing-extensions [required: Any, installed: 4.5.0]
- tqdm [required: >=4.57.0, installed: 4.65.0]
- typing-extensions [required: >=4.0.0, installed: 4.5.0]
- setuptools [required: <=59.5.0, installed: 59.5.0]
- torch [required: >=1.7.1, installed: 2.0.0]
- filelock [required: Any, installed: 3.10.7]
- jinja2 [required: Any, installed: 3.1.2]
- MarkupSafe [required: >=2.0, installed: 2.1.2]
- networkx [required: Any, installed: 3.1]
- sympy [required: Any, installed: 1.11.1]
- mpmath [required: >=0.19, installed: 1.3.0]
- typing-extensions [required: Any, installed: 4.5.0]
- torchmetrics [required: >=0.5.0,<0.11.0,!=0.5.1, installed: 0.10.3]
- numpy [required: >=1.17.2, installed: 1.23.5]
- packaging [required: Any, installed: 23.0]
- torch [required: >=1.3.1, installed: 2.0.0]
- filelock [required: Any, installed: 3.10.7]
- jinja2 [required: Any, installed: 3.1.2]
- MarkupSafe [required: >=2.0, installed: 2.1.2]
- networkx [required: Any, installed: 3.1]
- sympy [required: Any, installed: 1.11.1]
- mpmath [required: >=0.19, installed: 1.3.0]
- typing-extensions [required: Any, installed: 4.5.0]
Yes, we are running some update; WIP
if you install from source the pin shall be applied, not sure about some past versions on pypi