Skip to content

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

Description

@jiawei2912

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions