Skip to content

Commit e187fa4

Browse files
ENH NotImplementedError
1 parent 5a840c8 commit e187fa4

5 files changed

Lines changed: 56 additions & 10 deletions

File tree

openml/datasets/dataset.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,11 @@ def _get_arff(self, format: str) -> dict: # noqa: A002
420420
file_size = filepath.stat().st_size
421421
if file_size > MB_120:
422422
raise NotImplementedError(
423-
f"File {filename} too big for {file_size}-bit system ({bits} bytes).",
423+
f"File '{filename}' ({file_size / 1e6:.1f} MB)"
424+
f"exceeds the maximum supported size of 120 MB. "
425+
f"This limitation applies to {bits}-bit systems. "
426+
f"Large dataset handling is currently not fully supported. "
427+
f"Please consider using a smaller dataset"
424428
)
425429

426430
if format.lower() == "arff":
@@ -780,7 +784,12 @@ def get_data( # noqa: C901
780784
# All the assumptions below for the target are dependant on the number of targets being 1
781785
n_targets = len(target_names)
782786
if n_targets > 1:
783-
raise NotImplementedError(f"Number of targets {n_targets} not implemented.")
787+
raise NotImplementedError(
788+
f"Multi-target prediction is not yet supported."
789+
f"Found {n_targets} target columns: {target_names}. "
790+
f"Currently, only single-target datasets are supported. "
791+
f"Please select a single target column."
792+
)
784793

785794
target_name = target_names[0]
786795
x = data.drop(columns=[target_name])

openml/runs/functions.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,12 @@ def _run_task_get_arffcontent_parallel_helper( # noqa: PLR0913
755755
test_x = None
756756
test_y = None
757757
else:
758-
raise NotImplementedError(task.task_type)
758+
raise NotImplementedError(
759+
f"Task type '{task.task_type}' is not supported. "
760+
f"Only OpenMLSupervisedTask and OpenMLClusteringTask are currently implemented. "
761+
f"Task details: task_id={getattr(task, 'task_id', 'unknown')}, "
762+
f"task_class={task.__class__.__name__}"
763+
)
759764

760765
config.logger.info(
761766
f"Going to run model {model!s} on "
@@ -982,7 +987,13 @@ def obtain_field(xml_obj, fieldname, from_server, cast=None): # type: ignore
982987
if "predictions" not in files and from_server is True:
983988
task = openml.tasks.get_task(task_id)
984989
if task.task_type_id == TaskType.SUBGROUP_DISCOVERY:
985-
raise NotImplementedError("Subgroup discovery tasks are not yet supported.")
990+
raise NotImplementedError(
991+
f"Subgroup discovery tasks are not yet supported. "
992+
f"Task ID: {task_id}. Please check the OpenML documentation"
993+
f"for supported task types. "
994+
f"Currently supported task types: Classification, Regression,"
995+
f"Clustering, and Learning Curve."
996+
)
986997

987998
# JvR: actually, I am not sure whether this error should be raised.
988999
# a run can consist without predictions. But for now let's keep it
@@ -1282,7 +1293,12 @@ def format_prediction( # noqa: PLR0913
12821293
if isinstance(task, OpenMLRegressionTask):
12831294
return [repeat, fold, index, prediction, truth]
12841295

1285-
raise NotImplementedError(f"Formatting for {type(task)} is not supported.")
1296+
raise NotImplementedError(
1297+
f"Formatting predictions for task type '{type(task).__name__}' is not supported. "
1298+
f"Supported task types: OpenMLClassificationTask, OpenMLRegressionTask,"
1299+
f"and OpenMLLearningCurveTask. "
1300+
f"Please ensure your task is one of these types."
1301+
)
12861302

12871303

12881304
def delete_run(run_id: int) -> bool:

openml/runs/run.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,12 @@ def _generate_arff_dict(self) -> OrderedDict[str, Any]:
480480
]
481481

482482
else:
483-
raise NotImplementedError(f"Task type {task.task_type!s} is not yet supported.")
483+
raise NotImplementedError(
484+
f"Task type '{task.task_type}' is not yet supported. "
485+
f"Supported task types: Classification, Regression, Clustering, Learning Curve. "
486+
f"Task ID: {task.task_id}. "
487+
f"Please check the OpenML documentation for supported task types."
488+
)
484489

485490
return arff_dict
486491

openml/tasks/functions.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,12 @@ def _create_task_from_xml(xml: str) -> OpenMLTask:
526526
TaskType.LEARNING_CURVE: OpenMLLearningCurveTask,
527527
}.get(task_type)
528528
if cls is None:
529-
raise NotImplementedError(f"Task type {common_kwargs['task_type']} not supported.")
529+
raise NotImplementedError(
530+
f"Task type '{common_kwargs['task_type']}' is not supported. "
531+
f"Supported task types: SUPERVISED_CLASSIFICATION,"
532+
f"SUPERVISED_REGRESSION, CLUSTERING, LEARNING_CURVE."
533+
f"Please check the OpenML documentation for available task types."
534+
)
530535
return cls(**common_kwargs) # type: ignore
531536

532537

@@ -582,7 +587,13 @@ def create_task(
582587
elif task_type == TaskType.SUPERVISED_REGRESSION:
583588
task_cls = OpenMLRegressionTask # type: ignore
584589
else:
585-
raise NotImplementedError(f"Task type {task_type:d} not supported.")
590+
raise NotImplementedError(
591+
f"Task type ID {task_type:d} is not supported. "
592+
f"Supported task type IDs: {TaskType.SUPERVISED_CLASSIFICATION.value},"
593+
f"{TaskType.SUPERVISED_REGRESSION.value}, "
594+
f"{TaskType.CLUSTERING.value}, {TaskType.LEARNING_CURVE.value}. "
595+
f"Please refer to the TaskType enum for valid task type identifiers."
596+
)
586597

587598
return task_cls(
588599
task_type_id=task_type,

openml/tasks/task.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,12 @@ def get_X_and_y(self) -> tuple[pd.DataFrame, pd.Series | pd.DataFrame | None]:
290290
TaskType.SUPERVISED_REGRESSION,
291291
TaskType.LEARNING_CURVE,
292292
):
293-
raise NotImplementedError(self.task_type)
293+
raise NotImplementedError(
294+
f"Task type '{self.task_type}' is not implemented for get_X_and_y(). "
295+
f"Supported types: SUPERVISED_CLASSIFICATION, SUPERVISED_REGRESSION,"
296+
f"LEARNING_CURVE."
297+
f"Task ID: {getattr(self, 'task_id', 'unknown')}. "
298+
)
294299

295300
X, y, _, _ = dataset.get_data(target=self.target_name)
296301
return X, y
@@ -382,7 +387,7 @@ def __init__( # noqa: PLR0913
382387
self.cost_matrix = cost_matrix
383388

384389
if cost_matrix is not None:
385-
raise NotImplementedError("Costmatrix")
390+
raise NotImplementedError("Costmatrix functionality is not yet implemented.")
386391

387392

388393
class OpenMLRegressionTask(OpenMLSupervisedTask):

0 commit comments

Comments
 (0)