Skip to content

Commit 96df5e3

Browse files
committed
Remove circular import using lazy import
1 parent 9bcbcb3 commit 96df5e3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

openml/datasets/functions.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import openml._api_calls
2323
import openml.utils
24-
from openml._api import api_context
2524
from openml.config import OPENML_SKIP_PARQUET_ENV_VAR
2625
from openml.exceptions import (
2726
OpenMLHashException,
@@ -65,6 +64,8 @@ def list_qualities() -> list[str]:
6564
-------
6665
list
6766
"""
67+
from openml._api import api_context
68+
6869
return api_context.backend.datasets.list_qualities()
6970

7071

@@ -118,6 +119,8 @@ def list_datasets(
118119
If qualities are calculated for the dataset, some of
119120
these are also included as columns.
120121
"""
122+
from openml._api import api_context
123+
121124
listing_call = partial(
122125
api_context.backend.datasets.list,
123126
data_id=data_id,
@@ -708,6 +711,8 @@ def status_update(data_id: int, status: Literal["active", "deactivated"]) -> Non
708711
status : str,
709712
'active' or 'deactivated'
710713
"""
714+
from openml._api import api_context
715+
711716
legal_status = {"active", "deactivated"}
712717
if status not in legal_status:
713718
raise ValueError(f"Illegal status value. Legal values: {legal_status}")
@@ -786,6 +791,8 @@ def edit_dataset(
786791
-------
787792
Dataset id
788793
"""
794+
from openml._api import api_context
795+
789796
return api_context.backend.datasets.edit(
790797
data_id,
791798
description,
@@ -831,6 +838,8 @@ def fork_dataset(data_id: int) -> int:
831838
Dataset id of the forked dataset
832839
833840
"""
841+
from openml._api import api_context
842+
834843
return api_context.backend.datasets.fork(data_id=data_id)
835844

836845

@@ -855,6 +864,8 @@ def data_feature_add_ontology(data_id: int, index: int, ontology: str) -> bool:
855864
-------
856865
True or throws an OpenML server exception
857866
"""
867+
from openml._api import api_context
868+
858869
return api_context.backend.datasets.feature_add_ontology(data_id, index, ontology)
859870

860871

@@ -878,6 +889,8 @@ def data_feature_remove_ontology(data_id: int, index: int, ontology: str) -> boo
878889
-------
879890
True or throws an OpenML server exception
880891
"""
892+
from openml._api import api_context
893+
881894
return api_context.backend.datasets.feature_remove_ontology(data_id, index, ontology)
882895

883896

@@ -1321,4 +1334,6 @@ def delete_dataset(dataset_id: int) -> bool:
13211334
bool
13221335
True if the deletion was successful. False otherwise.
13231336
"""
1337+
from openml._api import api_context
1338+
13241339
return api_context.backend.datasets.delete(dataset_id)

0 commit comments

Comments
 (0)