Skip to content

Commit 6887919

Browse files
author
Ann Kuruvilla
committed
Added exception handling for dataset loading
Signed-off-by: Ann Kuruvilla <akuruvil@qti.qualcomm.com>
1 parent 2d6d60b commit 6887919

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

QEfficient/finetune/experimental/core/dataset.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ def _initialize_dataset(self):
140140
if self.config_name is not None:
141141
load_kwargs["name"] = self.config_name
142142

143-
db = load_dataset_builder(self.dataset_name, **load_kwargs)
143+
try:
144+
db = load_dataset_builder(self.dataset_name, **load_kwargs)
145+
except Exception as e:
146+
raise RuntimeError(
147+
f"Failed to load dataset builder for '{self.dataset_name}': {e}. "
148+
"Please check the dataset name and your network connection."
149+
)
144150
available_splits = []
145151
if db.info.splits is not None:
146152
available_splits = list(db.info.splits.keys())
@@ -151,7 +157,13 @@ def _initialize_dataset(self):
151157
if self.split not in available_splits:
152158
load_split = "train"
153159
# FIXME: Add streaming support for larger datasets.
154-
self.dataset = load_dataset(self.dataset_name, split=load_split, **load_kwargs)
160+
try:
161+
self.dataset = load_dataset(self.dataset_name, split=load_split, **load_kwargs)
162+
except Exception as e:
163+
raise RuntimeError(
164+
f"Failed to load dataset '{self.dataset_name}' with split '{load_split}': {e}. "
165+
"Please verify the dataset exists and is accessible."
166+
)
155167
self.dataset = self.dataset.shuffle(seed=self.seed)
156168
if self.dataset_disc_style:
157169
available_styles = set(self.dataset["category"])

0 commit comments

Comments
 (0)