Skip to content

Commit 2e128cd

Browse files
committed
updates qualities methods
1 parent e180557 commit 2e128cd

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

openml/_api/resources/base/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _download_file(self, url_ext: str) -> Path: ...
103103
def download_features_file(self, dataset_id: int) -> Path: ...
104104

105105
@abstractmethod
106-
def download_qualities_file(self, dataset_id: int) -> Path: ...
106+
def download_qualities_file(self, dataset_id: int) -> Path | None: ...
107107

108108
@abstractmethod
109109
def download_dataset_parquet(

openml/_api/resources/dataset.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ def download_features_file(self, dataset_id: int) -> Path:
689689
self.parse_features_file(file)
690690
return file
691691

692-
def download_qualities_file(self, dataset_id: int) -> Path:
692+
def download_qualities_file(self, dataset_id: int) -> Path | None:
693693
"""Download qualities file.
694694
695695
Parameters
@@ -702,7 +702,15 @@ def download_qualities_file(self, dataset_id: int) -> Path:
702702
Path
703703
"""
704704
path = f"data/qualities/{dataset_id}"
705-
file = self._download_file(path)
705+
try:
706+
file = self._download_file(path)
707+
except OpenMLServerException as e:
708+
if e.code == 362 and str(e) == "No qualities found - None":
709+
# quality file stays as None
710+
logger.warning(f"No qualities found for dataset {dataset_id}")
711+
return None
712+
raise e
713+
706714
self.parse_qualities_file(file)
707715
return file
708716

@@ -1394,7 +1402,7 @@ def download_features_file(self, dataset_id: int) -> Path:
13941402
self.parse_features_file(file)
13951403
return file
13961404

1397-
def download_qualities_file(self, dataset_id: int) -> Path:
1405+
def download_qualities_file(self, dataset_id: int) -> Path | None:
13981406
"""Download qualities file.
13991407
14001408
Parameters
@@ -1407,7 +1415,15 @@ def download_qualities_file(self, dataset_id: int) -> Path:
14071415
Path
14081416
"""
14091417
path = f"datasets/qualities/{dataset_id}"
1410-
file = self._download_file(path)
1418+
try:
1419+
file = self._download_file(path)
1420+
except OpenMLServerException as e:
1421+
if e.code == 362 and str(e) == "No qualities found - None":
1422+
# quality file stays as None
1423+
logger.warning(f"No qualities found for dataset {dataset_id}")
1424+
return None
1425+
raise e
1426+
14111427
self.parse_qualities_file(file)
14121428
return file
14131429

0 commit comments

Comments
 (0)