[FIX] 'OfflineModeIsEnabled' is no longer provided in 'datasets.utils.file_utils'
I'm not sure in which version of datasets the 'OfflineModeIsEnabled' Class was removed, but datasets was refactored to import 'OfflineModeIsEnabled' from huggingface instead.
Link to older version of datasets: link). Link to current (as of this post) version of datasets: link
This was causing the issue below, with modelscope==1.21.0 and datasets==3.2.0:
from modelscope.msdatasets.utils.hf_datasets_util import load_dataset_with_ctx File "A:\Stable Diffusion\stable-diffusion-webui\venv\lib\site-packages\modelscope\msdatasets\utils\hf_datasets_util.py", line 44, in <module>
from datasets.utils.file_utils import (OfflineModeIsEnabled, ImportError: cannot import name 'OfflineModeIsEnabled' from 'datasets.utils.file_utils' (A:\Stable Diffusion\stable-diffusion-webui\venv\lib\site-packages\datasets\utils\file_utils.py)
This can be fixed by either specifying an older compatible version of datasets or by updating modelscope\msdatasets\utils\hf_datasets_util.py by removing the old import for 'OfflineModeIsEnabled' at 44 and by adding in a new line to import it from huggingface_hub.errors.
Example modelscope\msdatasets\utils\hf_datasets_util.py:
from datasets.utils.file_utils import (_raise_if_offline_mode_is_enabled, cached_path, is_local_path, is_relative_path, relative_to_absolute_path)
(existing imports)
from huggingface_hub.errors import OfflineModeIsEnabled
Thank a lot
I am currently having a same issue
modelscope==1.21.1
downgrade datasets version to 2.16.0
pip install datasets==2.16.0