facechain icon indicating copy to clipboard operation
facechain copied to clipboard

[FIX] 'OfflineModeIsEnabled' is no longer provided in 'datasets.utils.file_utils'

Open jiawei2912 opened this issue 1 year ago • 3 comments

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

jiawei2912 avatar Dec 12 '24 08:12 jiawei2912

Thank a lot

sunbaigui avatar Dec 16 '24 06:12 sunbaigui

I am currently having a same issue

park-jay avatar Dec 22 '24 11:12 park-jay

modelscope==1.21.1

downgrade datasets version to 2.16.0

pip install datasets==2.16.0

yunlzheng avatar Jan 07 '25 03:01 yunlzheng