From 4cc46b5f3e6f8091d6ef33f0b689c9407f2c415b Mon Sep 17 00:00:00 2001 From: sahithyaravi Date: Tue, 9 Apr 2019 12:31:45 +0200 Subject: [PATCH 1/5] add tag_entity as backend --- openml/datasets/dataset.py | 7 +++---- openml/flows/flow.py | 7 +++---- openml/runs/run.py | 7 +++---- openml/tasks/task.py | 8 +++----- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/openml/datasets/dataset.py b/openml/datasets/dataset.py index 8201cdc29..119a345a6 100644 --- a/openml/datasets/dataset.py +++ b/openml/datasets/dataset.py @@ -15,6 +15,7 @@ import openml._api_calls from .data_feature import OpenMLDataFeature from ..exceptions import PyOpenMLError +from ..utils import _tag_entity logger = logging.getLogger(__name__) @@ -283,8 +284,7 @@ def push_tag(self, tag): tag : str Tag to attach to the dataset. """ - data = {'data_id': self.dataset_id, 'tag': tag} - openml._api_calls._perform_api_call("/data/tag", 'post', data=data) + _tag_entity('data', self.dataset_id, tag) def remove_tag(self, tag): """Removes a tag from this dataset on the server. @@ -294,8 +294,7 @@ def remove_tag(self, tag): tag : str Tag to attach to the dataset. """ - data = {'data_id': self.dataset_id, 'tag': tag} - openml._api_calls._perform_api_call("/data/untag", 'post', data=data) + _tag_entity('data', self.dataset_id, tag, untag=True) def __eq__(self, other): diff --git a/openml/flows/flow.py b/openml/flows/flow.py index 348f276be..854a799ea 100644 --- a/openml/flows/flow.py +++ b/openml/flows/flow.py @@ -8,6 +8,7 @@ import openml.exceptions from ..extensions import get_extension_by_flow from ..utils import extract_xml_tags +from ..utils import _tag_entity class OpenMLFlow(object): @@ -455,8 +456,7 @@ def push_tag(self, tag): tag : str Tag to attach to the flow. """ - data = {'flow_id': self.flow_id, 'tag': tag} - openml._api_calls._perform_api_call("/flow/tag", 'post', data=data) + _tag_entity('flow', self.flow_id, tag) def remove_tag(self, tag): """Removes a tag from this flow on the server. @@ -466,8 +466,7 @@ def remove_tag(self, tag): tag : str Tag to attach to the flow. """ - data = {'flow_id': self.flow_id, 'tag': tag} - openml._api_calls._perform_api_call("/flow/untag", 'post', data=data) + _tag_entity('flow', self.flow_id, tag, untag=True) def _copy_server_fields(source_flow, target_flow): diff --git a/openml/runs/run.py b/openml/runs/run.py index 821f8ed48..311290828 100644 --- a/openml/runs/run.py +++ b/openml/runs/run.py @@ -13,6 +13,7 @@ from ..exceptions import PyOpenMLError from ..flows import get_flow from ..tasks import get_task, TaskTypeEnum +from ..utils import _tag_entity class OpenMLRun(object): @@ -468,8 +469,7 @@ def push_tag(self, tag): tag : str Tag to attach to the run. """ - data = {'run_id': self.run_id, 'tag': tag} - openml._api_calls._perform_api_call("/run/tag", 'post', data=data) + _tag_entity('run', self.run_id, tag) def remove_tag(self, tag): """Removes a tag from this run on the server. @@ -479,8 +479,7 @@ def remove_tag(self, tag): tag : str Tag to attach to the run. """ - data = {'run_id': self.run_id, 'tag': tag} - openml._api_calls._perform_api_call("/run/untag", 'post', data=data) + _tag_entity('run', self.run_id, tag, untag=True) ############################################################################### diff --git a/openml/tasks/task.py b/openml/tasks/task.py index c3ae36b10..7479bf36c 100644 --- a/openml/tasks/task.py +++ b/openml/tasks/task.py @@ -4,7 +4,7 @@ from .. import datasets from .split import OpenMLSplit import openml._api_calls -from ..utils import _create_cache_directory_for_id +from ..utils import _create_cache_directory_for_id, _tag_entity class OpenMLTask(object): @@ -76,8 +76,7 @@ def push_tag(self, tag): tag : str Tag to attach to the task. """ - data = {'task_id': self.task_id, 'tag': tag} - openml._api_calls._perform_api_call("/task/tag", 'post', data=data) + _tag_entity('task', self.task_id, tag) def remove_tag(self, tag): """Removes a tag from this task on the server. @@ -87,8 +86,7 @@ def remove_tag(self, tag): tag : str Tag to attach to the task. """ - data = {'task_id': self.task_id, 'tag': tag} - openml._api_calls._perform_api_call("/task/untag", 'post', data=data) + _tag_entity('task', self.task_id, tag, untag=True) class OpenMLSupervisedTask(OpenMLTask): From 7a2a17b46fa9ab7b814852f05bd11072984ae4d9 Mon Sep 17 00:00:00 2001 From: sahithyaravi Date: Tue, 9 Apr 2019 16:56:27 +0200 Subject: [PATCH 2/5] removed unused import --- openml/flows/flow.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openml/flows/flow.py b/openml/flows/flow.py index 854a799ea..561ca9ecc 100644 --- a/openml/flows/flow.py +++ b/openml/flows/flow.py @@ -5,7 +5,6 @@ import xmltodict import openml._api_calls -import openml.exceptions from ..extensions import get_extension_by_flow from ..utils import extract_xml_tags from ..utils import _tag_entity From ed20e9f23459ff64bc41af00d373b1dc62b170da Mon Sep 17 00:00:00 2001 From: sahithyaravi Date: Wed, 10 Apr 2019 13:22:10 +0200 Subject: [PATCH 3/5] fix pyflakes errors --- openml/flows/flow.py | 2 -- openml/runs/run.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/openml/flows/flow.py b/openml/flows/flow.py index 561ca9ecc..b3e054e29 100644 --- a/openml/flows/flow.py +++ b/openml/flows/flow.py @@ -1,10 +1,8 @@ from collections import OrderedDict import os -from typing import Dict, List, Union # noqa: F401 import xmltodict -import openml._api_calls from ..extensions import get_extension_by_flow from ..utils import extract_xml_tags from ..utils import _tag_entity diff --git a/openml/runs/run.py b/openml/runs/run.py index 311290828..1450ca8cb 100644 --- a/openml/runs/run.py +++ b/openml/runs/run.py @@ -1,7 +1,7 @@ from collections import OrderedDict import pickle import time -from typing import Any, IO, Optional, TextIO, TYPE_CHECKING # noqa: F401 +from typing import Any, IO, TextIO import os import arff From 257a5ba2f18f3dedc4d526799ed2fb03e3a22c11 Mon Sep 17 00:00:00 2001 From: sahithyaravi Date: Wed, 10 Apr 2019 13:54:56 +0200 Subject: [PATCH 4/5] remove trailing space --- openml/runs/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openml/runs/run.py b/openml/runs/run.py index 1450ca8cb..f718384dd 100644 --- a/openml/runs/run.py +++ b/openml/runs/run.py @@ -1,7 +1,7 @@ from collections import OrderedDict import pickle import time -from typing import Any, IO, TextIO +from typing import Any, IO, TextIO import os import arff From e13f540bfa7430e448ce1c6d709874dc050a03d5 Mon Sep 17 00:00:00 2001 From: sahithyaravi Date: Wed, 10 Apr 2019 17:17:28 +0200 Subject: [PATCH 5/5] fix mypy error --- openml/flows/flow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openml/flows/flow.py b/openml/flows/flow.py index b3e054e29..1ab8d12d0 100644 --- a/openml/flows/flow.py +++ b/openml/flows/flow.py @@ -1,11 +1,11 @@ from collections import OrderedDict import os +from typing import Dict, List, Union # noqa: F401 import xmltodict from ..extensions import get_extension_by_flow -from ..utils import extract_xml_tags -from ..utils import _tag_entity +from ..utils import extract_xml_tags, _tag_entity class OpenMLFlow(object):