Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit huggingface cache policy - BREAKING CHANGE #1564

Merged
merged 35 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
db2b74b
Revisit huggingface cache policy
elronbandel Jan 29, 2025
c863ee7
Enable streaming for LoadFromHFSpace and clean up commented code
elronbandel Jan 29, 2025
0e36f1a
Disable Hugging Face datasets cache in CatalogPreparationTestCase
elronbandel Jan 29, 2025
e672ca1
Enable streaming for wiki_bio loader in TaskCard and update JSON conf…
elronbandel Jan 29, 2025
81873b7
Merge branch 'main' into hf-cache
elronbandel Jan 29, 2025
3d91e20
Add conditional test card execution for 'doqa_travel' subset in chat_…
elronbandel Jan 29, 2025
0968633
Merge branch 'hf-cache' of https://github.com/IBM/unitxt into hf-cache
elronbandel Jan 29, 2025
119d07e
Enhance memory and performance logging in catalog preparation tests
elronbandel Jan 29, 2025
6b84f81
Return parallel execution to 1 and adjust modulo for deterministic te…
elronbandel Jan 29, 2025
a43910c
Try 1
elronbandel Jan 30, 2025
b5a5ff0
try 1 fixed
elronbandel Jan 30, 2025
1a421af
trial 2
elronbandel Jan 30, 2025
db75df8
Stop testing social iqa until problem resolved
elronbandel Jan 30, 2025
412e90b
Update social iqa card to use specific revision and enable testing
elronbandel Jan 30, 2025
f6e5388
Refactor translation card testing logic and remove unused dataset loa…
elronbandel Jan 30, 2025
a0e7d0d
Update head_qa card loader path and streamline dataset configuration
elronbandel Jan 30, 2025
a6fd3dd
Enable streaming for websrc card loader in configuration
elronbandel Jan 30, 2025
700b26a
Add revision reference to Winogrande card loaders
elronbandel Jan 30, 2025
4e5fd67
Add revision reference to PIQA card loader
elronbandel Jan 30, 2025
edc0ae7
Update
elronbandel Jan 30, 2025
5e3e4cf
Another trial
elronbandel Jan 30, 2025
a94be8f
Refactor dataset loading to support dynamic streaming and improve con…
elronbandel Feb 2, 2025
95db421
Add streaming support to turl_col_type configuration
elronbandel Feb 2, 2025
f20529b
Remove unused skip files from test preparation
elronbandel Feb 2, 2025
2d53e07
Merge branch 'main' into hf-cache
elronbandel Feb 2, 2025
1935ef0
Refactor LoadHF class to improve dataset filtering and add streaming …
elronbandel Feb 2, 2025
c2ed1b6
Merge branch 'hf-cache' of https://github.com/IBM/unitxt into hf-cache
elronbandel Feb 2, 2025
e94b812
Update load_dataset function documentation to clarify caching behavio…
elronbandel Feb 2, 2025
4c0b494
Update dataset loading to support caching and streaming options
elronbandel Feb 2, 2025
fdd1a2e
Import UnitxtDataset in load_dataset function for improved dataset ha…
elronbandel Feb 2, 2025
0c31189
Remove unused load function import from __init__.py
elronbandel Feb 2, 2025
7f1f762
Remove streaming option from SEED-Bench loader configuration
elronbandel Feb 2, 2025
060af54
Refactor dataset loading to utilize caching and improve dataset handling
elronbandel Feb 2, 2025
937552b
Add missing imports for dataset module functionality
elronbandel Feb 2, 2025
4dfb45f
Increase loader cache size to improve performance and update test set…
elronbandel Feb 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/unitxt/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def load_dataset(
dataset_query: Optional[str] = None,
split: Optional[str] = None,
streaming: bool = False,
disable_cache: Optional[bool] = None,
disable_cache: Optional[bool] = True,
**kwargs,
) -> Union[DatasetDict, IterableDatasetDict, Dataset, IterableDataset]:
"""Loads dataset.
Expand Down Expand Up @@ -188,9 +188,6 @@ def load_dataset(
if split is not None:
stream = stream[split]

if disable_cache is None:
disable_cache = settings.disable_hf_datasets_cache

if streaming:
dataset = stream.to_iterable_dataset(
features=UNITXT_DATASET_SCHEMA,
Expand Down
42 changes: 2 additions & 40 deletions src/unitxt/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class LoadHF(Loader):
Union[str, Sequence[str], Mapping[str, Union[str, Sequence[str]]]]
] = None
revision: Optional[str] = None
streaming: bool = True
streaming: bool = False
filtering_lambda: Optional[str] = None
num_proc: Optional[int] = None
requirements_list: List[str] = OptionalField(default_factory=list)
Expand Down Expand Up @@ -823,6 +823,7 @@ class LoadFromHFSpace(LoadHF):
use_token: Optional[bool] = None
token_env: Optional[str] = None
requirements_list: List[str] = ["huggingface_hub"]
streaming = True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Once the files are downloaded to local file system, what benefit you get here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont, It just dosent work otherwise. We should base this loader on dictionary loader.


def _get_token(self) -> Optional[Union[bool, str]]:
if self.token_env:
Expand Down Expand Up @@ -953,45 +954,6 @@ def load_data(self):
self._map_wildcard_path_to_full_paths()
self.path = self._download_data()
return super().load_data()

# url: str

# _requirements_list: List[str] = ["opendatasets"]
# data_classification_policy = ["public"]

# def verify(self):
# super().verify()
# if not os.path.isfile("kaggle.json"):
# raise MissingKaggleCredentialsError(
# "Please obtain kaggle credentials https://christianjmills.com/posts/kaggle-obtain-api-key-tutorial/ and save them to local ./kaggle.json file"
# )

# if self.streaming:
# raise NotImplementedError("LoadFromKaggle cannot load with streaming.")

# def prepare(self):
# super().prepare()
# from opendatasets import download

# self.downloader = download

# def load_iterables(self):
# with TemporaryDirectory() as temp_directory:
# self.downloader(self.url, temp_directory)
# return hf_load_dataset(temp_directory, streaming=False)

# class LoadFromAPI(Loader):
# """Loads data from from API"""

# urls: Dict[str, str]
# chunksize: int = 100000
# loader_limit: Optional[int] = None
# streaming: bool = False

# def _maybe_set_classification_policy(self):
# self.set_default_data_classification(["proprietary"], "when loading from API")

# def load_iterables(self):
self.api_key = os.getenv("SQL_API_KEY", None)
if not self.api_key:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion src/unitxt/settings_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __getattr__(self, key):
settings.skip_artifacts_prepare_and_verify = (bool, False)
settings.data_classification_policy = None
settings.mock_inference_mode = (bool, False)
settings.disable_hf_datasets_cache = (bool, True)
settings.disable_hf_datasets_cache = (bool, False)
settings.loader_cache_size = (int, 1)
settings.task_data_as_text = (bool, True)
settings.default_provider = "watsonx"
Expand Down
Loading