Skip to content

Commit

Permalink
Add FileExtensionNotFoundError (#1564)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-chu authored Oct 1, 2024
1 parent b517297 commit 8cf3d87
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
7 changes: 3 additions & 4 deletions llmfoundry/data/finetuning/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from llmfoundry.data.text_data import build_streams
from llmfoundry.utils.config_utils import to_dict_container
from llmfoundry.utils.exceptions import (
FinetuningFileNotFoundError,
MissingHuggingFaceURLSplitError,
NotEnoughDatasetSamplesError,
)
Expand Down Expand Up @@ -585,10 +586,8 @@ def _download_remote_hf_dataset(remote_path: str, split: str) -> str:
f'{name}/{split}{ext}'
for ext in SUPPORTED_EXTENSIONS
]
raise FileNotFoundError(
f'Could not find a file with any of ' + \
f'the supported extensions: {SUPPORTED_EXTENSIONS}\n' + \
f'at {files_searched}',
raise FinetuningFileNotFoundError(
files_searched=files_searched,
) from e
else:
log.debug(
Expand Down
16 changes: 16 additions & 0 deletions llmfoundry/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,19 @@ def __reduce__(self):

def __str__(self):
return self.message


class FinetuningFileNotFoundError(UserError):
"""Error thrown when a file can't be found with any supported extension."""

def __init__(self, files_searched: list[str]) -> None:
from llmfoundry.data.finetuning.tasks import SUPPORTED_EXTENSIONS
message = (
f'Could not find a file with any of ' + \
f'the supported extensions: {SUPPORTED_EXTENSIONS}\n' + \
f'at {files_searched}'
)
super().__init__(
message,
files_searched=files_searched,
)

0 comments on commit 8cf3d87

Please sign in to comment.