Skip to content

Commit 415ee9f

Browse files
authored
Merge branch 'develop' into pyproject
2 parents 0608e7a + 5b56127 commit 415ee9f

6 files changed

Lines changed: 25 additions & 22 deletions

File tree

openml/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'connection_n_retries': 2,
2525
}
2626

27-
config_file = os.path.expanduser(os.path.join('~', '.openml' 'config'))
27+
config_file = os.path.expanduser(os.path.join('~', '.openml', 'config'))
2828

2929
# Default values are actually added here in the _setup() function which is
3030
# called at the end of this module

openml/datasets/dataset.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import openml._api_calls
1717
from .data_feature import OpenMLDataFeature
1818
from ..exceptions import PyOpenMLError
19+
from ..utils import _tag_entity
1920

2021

2122
logger = logging.getLogger(__name__)
@@ -284,8 +285,7 @@ def push_tag(self, tag):
284285
tag : str
285286
Tag to attach to the dataset.
286287
"""
287-
data = {'data_id': self.dataset_id, 'tag': tag}
288-
openml._api_calls._perform_api_call("/data/tag", 'post', data=data)
288+
_tag_entity('data', self.dataset_id, tag)
289289

290290
def remove_tag(self, tag):
291291
"""Removes a tag from this dataset on the server.
@@ -295,8 +295,7 @@ def remove_tag(self, tag):
295295
tag : str
296296
Tag to attach to the dataset.
297297
"""
298-
data = {'data_id': self.dataset_id, 'tag': tag}
299-
openml._api_calls._perform_api_call("/data/untag", 'post', data=data)
298+
_tag_entity('data', self.dataset_id, tag, untag=True)
300299

301300
def __eq__(self, other):
302301

openml/flows/flow.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
import xmltodict
66

7-
import openml._api_calls
8-
import openml.exceptions
97
from ..extensions import get_extension_by_flow
10-
from ..utils import extract_xml_tags
8+
from ..utils import extract_xml_tags, _tag_entity
119

1210

1311
class OpenMLFlow(object):
@@ -455,8 +453,7 @@ def push_tag(self, tag):
455453
tag : str
456454
Tag to attach to the flow.
457455
"""
458-
data = {'flow_id': self.flow_id, 'tag': tag}
459-
openml._api_calls._perform_api_call("/flow/tag", 'post', data=data)
456+
_tag_entity('flow', self.flow_id, tag)
460457

461458
def remove_tag(self, tag):
462459
"""Removes a tag from this flow on the server.
@@ -466,8 +463,7 @@ def remove_tag(self, tag):
466463
tag : str
467464
Tag to attach to the flow.
468465
"""
469-
data = {'flow_id': self.flow_id, 'tag': tag}
470-
openml._api_calls._perform_api_call("/flow/untag", 'post', data=data)
466+
_tag_entity('flow', self.flow_id, tag, untag=True)
471467

472468

473469
def _copy_server_fields(source_flow, target_flow):

openml/runs/run.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections import OrderedDict
22
import pickle
33
import time
4-
from typing import Any, IO, Optional, TextIO, TYPE_CHECKING # noqa: F401
4+
from typing import Any, IO, TextIO
55
import os
66

77
import arff
@@ -19,6 +19,7 @@
1919
OpenMLClusteringTask,
2020
OpenMLRegressionTask
2121
)
22+
from ..utils import _tag_entity
2223

2324

2425
class OpenMLRun(object):
@@ -472,8 +473,7 @@ def push_tag(self, tag: str) -> None:
472473
tag : str
473474
Tag to attach to the run.
474475
"""
475-
data = {'run_id': self.run_id, 'tag': tag}
476-
openml._api_calls._perform_api_call("/run/tag", 'post', data=data)
476+
_tag_entity('run', self.run_id, tag)
477477

478478
def remove_tag(self, tag: str) -> None:
479479
"""Removes a tag from this run on the server.
@@ -483,8 +483,7 @@ def remove_tag(self, tag: str) -> None:
483483
tag : str
484484
Tag to attach to the run.
485485
"""
486-
data = {'run_id': self.run_id, 'tag': tag}
487-
openml._api_calls._perform_api_call("/run/untag", 'post', data=data)
486+
_tag_entity('run', self.run_id, tag, untag=True)
488487

489488

490489
###############################################################################

openml/tasks/task.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .. import datasets
55
from .split import OpenMLSplit
66
import openml._api_calls
7-
from ..utils import _create_cache_directory_for_id
7+
from ..utils import _create_cache_directory_for_id, _tag_entity
88

99

1010
class OpenMLTask(object):
@@ -76,8 +76,7 @@ def push_tag(self, tag):
7676
tag : str
7777
Tag to attach to the task.
7878
"""
79-
data = {'task_id': self.task_id, 'tag': tag}
80-
openml._api_calls._perform_api_call("/task/tag", 'post', data=data)
79+
_tag_entity('task', self.task_id, tag)
8180

8281
def remove_tag(self, tag):
8382
"""Removes a tag from this task on the server.
@@ -87,8 +86,7 @@ def remove_tag(self, tag):
8786
tag : str
8887
Tag to attach to the task.
8988
"""
90-
data = {'task_id': self.task_id, 'tag': tag}
91-
openml._api_calls._perform_api_call("/task/untag", 'post', data=data)
89+
_tag_entity('task', self.task_id, tag, untag=True)
9290

9391

9492
class OpenMLSupervisedTask(OpenMLTask):

tests/test_openml/test_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import os
2+
3+
import openml.config
4+
import openml.testing
5+
6+
7+
class TestConfig(openml.testing.TestBase):
8+
9+
def test_config_loading(self):
10+
self.assertTrue(os.path.exists(openml.config.config_file))
11+
self.assertTrue(os.path.isdir(os.path.expanduser('~/.openml')))

0 commit comments

Comments
 (0)