From 49f1462fb2e9d3a8110f33a94a86a3736ce58eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Pe=CC=81net?= Date: Tue, 3 Aug 2021 18:30:33 +0200 Subject: [PATCH 1/8] MEC public API --- dataikuapi/dss/modelcomparator.py | 163 +++++++++++++++++++++++++ dataikuapi/dss/modelevaluationstore.py | 3 + dataikuapi/dss/project.py | 55 ++++++++- 3 files changed, 217 insertions(+), 4 deletions(-) create mode 100644 dataikuapi/dss/modelcomparator.py diff --git a/dataikuapi/dss/modelcomparator.py b/dataikuapi/dss/modelcomparator.py new file mode 100644 index 00000000..191b587b --- /dev/null +++ b/dataikuapi/dss/modelcomparator.py @@ -0,0 +1,163 @@ +import json + +from dataikuapi.dss.discussion import DSSObjectDiscussions + + +class DSSModelComparator(object): + """ + A handle to interact with a model comparator on the DSS instance. + + Do not create this directly, use :meth:`dataikuapi.dss.DSSProject.get_model_comparator` + """ + def __init__(self, client, project_key, mec_id): + self.client = client + self.project = client.get_project(project_key) + self.project_key = project_key + self.mec_id = mec_id + + @property + def id(self): + return self.mec_id + + def get_settings(self): + """ + Returns the settings of this model comparator. + + :rtype: DSSModelComparatorSettings + """ + data = self.client._perform_json( + "GET", "/projects/%s/modelcomparators/%s" % (self.project_key, self.mec_id)) + return DSSModelComparatorSettings(self, data) + + def get_object_discussions(self): + """ + Get a handle to manage discussions on the model comparator + + :returns: the handle to manage discussions + :rtype: :class:`dataikuapi.discussion.DSSObjectDiscussions` + """ + return DSSObjectDiscussions(self.client, self.project_key, "MODEL_EVALUATION_COMPARATOR", self.mec_id) + + ######################################################## + # Deletion + ######################################################## + + def delete(self): + """ + Delete the model evaluation store + + """ + return self.client._perform_empty("DELETE", "/projects/%s/modelcomparators/%s" % (self.project_key, self.mec_id)) + + +class DSSModelComparatorSettings: + """ + A handle on the settings of a model comparator + + A model comparator has: + - a display name ; + - a prediction type ; + - a list of full ids of items to compare + + The prediction type can be: + - BINARY_CLASSIFICATION, + - REGRESSION, + - MULTICLASS + + The full ids are: + - the model id of a Lab Model, such as A-PROJECTKEY-LABID-MODELID-s1-pp1-m1 (visible on the summary tab of the model) ; + - the model id of a saved model version, such as S-PROJECTKEY-SMID-1234567891234 (visible on the summary tab of the model) ; + - the model evaluation id of a model evaluation, such as ME-PROJECTKEY-STOREID-MEID (visible on the summary tab of the model evaluation). + + + Do not create this class directly, instead use :meth:`dataikuapi.dss.DSSModelComparator.get_settings` + """ + + def __init__(self, model_comparator, settings): + self.model_comparator = model_comparator + self.settings = settings + + def get_raw(self): + """ + Gets raw settings of a model comparator + + :return: the raw settings of comparator, as a dict. Modifications made to the returned object + are reflected when saving + :rtype: dict + """ + return self.settings + + def add_compared_item(self, full_id): + """ + Add an item to the list of compared items + + :param full_id: full id of the item (lab model, saved model version, model evaluation) to add + """ + if "comparedModels" not in self.settings: + self.settings["comparedModels"] = [] + self.settings["comparedModels"].append({ + "refId": full_id + }) + + def remove_compared_item(self, full_id): + """ + Remove an item from the list of compared items + + :param full_id: full id of the item (lab model, saved model version, model evaluation) to remove + """ + if not self.settings["comparedModels"]: + return + self.settings["comparedModels"] = filter(lambda x: x["refId"] != full_id, self.settings["comparedModels"]) + + def get_compared_items(self): + """ + Gets the full ids of items compared in this comparator instance + + :return: the list of the full ids of compared items + :rtype: list[str] + """ + if not self.settings["comparedModels"]: + return [] + return map(lambda x: x["refId"], self.settings["comparedModels"]) + + def get_prediction_type(self): + """ + Gets the prediction type of this comparator instance + + :return: str + """ + return self.settings["predictionType"] + + def set_prediction_type(self, prediction_type): + """ + Sets the prediction type of this comparator instance. Must be consistent + with the prediction types of compared items. + + :param prediction_type: + """ + self.settings["predictionType"] = prediction_type + + def get_display_name(self): + """ + Human readable name of this comparator instance + + :return: str + """ + return self.settings["displayName"] + + def set_display_name(self, display_name): + """ + Set the human readable name of this comparator instance + + :param display_name: + """ + self.settings["displayName"] = display_name + + def save(self): + """ + Save settings modifications + """ + self.model_comparator.client._perform_empty( + "PUT", "/projects/%s/modelcomparators/%s" % (self.model_comparator.project_key, self.model_comparator.mec_id), + body=self.settings) + diff --git a/dataikuapi/dss/modelevaluationstore.py b/dataikuapi/dss/modelevaluationstore.py index f1f71910..31d2f6c5 100644 --- a/dataikuapi/dss/modelevaluationstore.py +++ b/dataikuapi/dss/modelevaluationstore.py @@ -270,6 +270,9 @@ def get_settings(self): "GET", "/projects/%s/modelevaluationstores/%s/runs/%s/settings" % (self.project_key, self.mes_id, self.run_id)) return DSSModelEvaluationSettings(self, data) + def get_full_id(self): + return "ME-{}-{}-{}".format(self.project_key, self.mes_id, self.run_id) + def delete(self): """ Remove this model evaluation diff --git a/dataikuapi/dss/project.py b/dataikuapi/dss/project.py index 3c74d31b..7e901aa3 100644 --- a/dataikuapi/dss/project.py +++ b/dataikuapi/dss/project.py @@ -1,5 +1,6 @@ import time, warnings, sys, os.path as osp from .dataset import DSSDataset, DSSDatasetListItem, DSSManagedDatasetCreationHelper +from .modelcomparator import DSSModelComparator from .streaming_endpoint import DSSStreamingEndpoint, DSSStreamingEndpointListItem, DSSManagedStreamingEndpointCreationHelper from .recipe import DSSRecipeListItem, DSSRecipe from . import recipe @@ -730,17 +731,15 @@ def get_model_evaluation_store(self, mes_id): """ return DSSModelEvaluationStore(self.client, self.project_key, mes_id) - def create_model_evaluation_store(self, name, mes_id=None): + def create_model_evaluation_store(self, name): """ Create a new model evaluation store in the project, and return a handle to interact with it. :param string name: the name for the new model evaluation store - :param string mes_id optional: the id for the new model evaluation store - + :returns: A :class:`dataikuapi.dss.modelevaluationstore.DSSModelEvaluationStore` model evaluation store handle """ obj = { - "id" : mes_id, "projectKey" : self.project_key, "name" : name } @@ -749,6 +748,54 @@ def create_model_evaluation_store(self, name, mes_id=None): mes_id = res['id'] return DSSModelEvaluationStore(self.client, self.project_key, mes_id) + ######################################################## + # Model comparators + ######################################################## + + def list_model_comparators(self, as_type=None): + """ + List the model comparators in this project. + + :returns: The list of the model comparators + :rtype: list + """ + items = self.client._perform_json("GET", "/projects/%s/modelcomparators/" % self.project_key) + if as_type == "objects" or as_type == "object": + return [DSSModelComparator(self.client, self.project_key, item["id"]) for item in items] + else: + return items + + def get_model_comparator(self, mec_id): + """ + Get a handle to interact with a specific model comparator + + :param string mec_id: the id of the desired model comparator + + :returns: A :class:`dataikuapi.dss.modelcomparator.DSSModelComparator` model comparator handle + :rtype: :class:`dataikuapi.dss.modelcomparator.DSSModelComparator` + """ + return DSSModelComparator(self.client, self.project_key, mec_id) + + def create_model_comparator(self, name, prediction_type): + """ + Create a new model comparator in the project, and return a handle to interact with it. + + :param string name: the name for the new model comparator + :param string prediction_type: one of BINARY_CLASSIFICATION, REGRESSION and MULTICLASS + + :returns: A :class:`dataikuapi.dss.modelcomparator.DSSModelComparator` model comparator handle + :rtype: :class:`dataikuapi.dss.modelcomparator.DSSModelComparator` + """ + obj = { + "projectKey": self.project_key, + "displayName": name, + "predictionType": prediction_type + } + res = self.client._perform_json("POST", "/projects/%s/modelcomparators/" % self.project_key, + body = obj) + mec_id = res['id'] + return DSSModelComparator(self.client, self.project_key, mec_id) + ######################################################## # Jobs ######################################################## From 46b0a4f150987dc7db4cd9a8f1fcc473329d50d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Pe=CC=81net?= Date: Wed, 11 Aug 2021 18:16:44 +0200 Subject: [PATCH 2/8] Applying name change to model comparisons --- dataikuapi/dss/modelcomparator.py | 8 ++++---- dataikuapi/dss/project.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dataikuapi/dss/modelcomparator.py b/dataikuapi/dss/modelcomparator.py index 191b587b..13242351 100644 --- a/dataikuapi/dss/modelcomparator.py +++ b/dataikuapi/dss/modelcomparator.py @@ -26,7 +26,7 @@ def get_settings(self): :rtype: DSSModelComparatorSettings """ data = self.client._perform_json( - "GET", "/projects/%s/modelcomparators/%s" % (self.project_key, self.mec_id)) + "GET", "/projects/%s/modelcomparisons/%s" % (self.project_key, self.mec_id)) return DSSModelComparatorSettings(self, data) def get_object_discussions(self): @@ -36,7 +36,7 @@ def get_object_discussions(self): :returns: the handle to manage discussions :rtype: :class:`dataikuapi.discussion.DSSObjectDiscussions` """ - return DSSObjectDiscussions(self.client, self.project_key, "MODEL_EVALUATION_COMPARATOR", self.mec_id) + return DSSObjectDiscussions(self.client, self.project_key, "MODEL_COMPARISON", self.mec_id) ######################################################## # Deletion @@ -47,7 +47,7 @@ def delete(self): Delete the model evaluation store """ - return self.client._perform_empty("DELETE", "/projects/%s/modelcomparators/%s" % (self.project_key, self.mec_id)) + return self.client._perform_empty("DELETE", "/projects/%s/modelcomparisons/%s" % (self.project_key, self.mec_id)) class DSSModelComparatorSettings: @@ -158,6 +158,6 @@ def save(self): Save settings modifications """ self.model_comparator.client._perform_empty( - "PUT", "/projects/%s/modelcomparators/%s" % (self.model_comparator.project_key, self.model_comparator.mec_id), + "PUT", "/projects/%s/modelcomparisons/%s" % (self.model_comparator.project_key, self.model_comparator.mec_id), body=self.settings) diff --git a/dataikuapi/dss/project.py b/dataikuapi/dss/project.py index 06af993a..5c93bad6 100644 --- a/dataikuapi/dss/project.py +++ b/dataikuapi/dss/project.py @@ -806,7 +806,7 @@ def list_model_comparators(self, as_type=None): :returns: The list of the model comparators :rtype: list """ - items = self.client._perform_json("GET", "/projects/%s/modelcomparators/" % self.project_key) + items = self.client._perform_json("GET", "/projects/%s/modelcomparisons/" % self.project_key) if as_type == "objects" or as_type == "object": return [DSSModelComparator(self.client, self.project_key, item["id"]) for item in items] else: @@ -838,7 +838,7 @@ def create_model_comparator(self, name, prediction_type): "displayName": name, "predictionType": prediction_type } - res = self.client._perform_json("POST", "/projects/%s/modelcomparators/" % self.project_key, + res = self.client._perform_json("POST", "/projects/%s/modelcomparisons/" % self.project_key, body = obj) mec_id = res['id'] return DSSModelComparator(self.client, self.project_key, mec_id) From 6f6b0ada56816e375359f0c6b5436b92302d91f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Pe=CC=81net?= Date: Mon, 13 Sep 2021 11:19:23 +0200 Subject: [PATCH 3/8] Naming, wording. --- ...{modelcomparator.py => modelcomparison.py} | 46 +++++++++---------- dataikuapi/dss/project.py | 39 ++++++++-------- 2 files changed, 41 insertions(+), 44 deletions(-) rename dataikuapi/dss/{modelcomparator.py => modelcomparison.py} (76%) diff --git a/dataikuapi/dss/modelcomparator.py b/dataikuapi/dss/modelcomparison.py similarity index 76% rename from dataikuapi/dss/modelcomparator.py rename to dataikuapi/dss/modelcomparison.py index 13242351..8e85c58e 100644 --- a/dataikuapi/dss/modelcomparator.py +++ b/dataikuapi/dss/modelcomparison.py @@ -3,11 +3,11 @@ from dataikuapi.dss.discussion import DSSObjectDiscussions -class DSSModelComparator(object): +class DSSModelComparison(object): """ - A handle to interact with a model comparator on the DSS instance. + A handle to interact with a model comparison on the DSS instance. - Do not create this directly, use :meth:`dataikuapi.dss.DSSProject.get_model_comparator` + Do not create this directly, use :meth:`dataikuapi.dss.DSSProject.get_model_comparison` """ def __init__(self, client, project_key, mec_id): self.client = client @@ -21,17 +21,17 @@ def id(self): def get_settings(self): """ - Returns the settings of this model comparator. + Returns the settings of this model comparison. - :rtype: DSSModelComparatorSettings + :rtype: DSSModelComparisonSettings """ data = self.client._perform_json( "GET", "/projects/%s/modelcomparisons/%s" % (self.project_key, self.mec_id)) - return DSSModelComparatorSettings(self, data) + return DSSModelComparisonSettings(self, data) def get_object_discussions(self): """ - Get a handle to manage discussions on the model comparator + Get a handle to manage discussions on the model comparison :returns: the handle to manage discussions :rtype: :class:`dataikuapi.discussion.DSSObjectDiscussions` @@ -44,17 +44,17 @@ def get_object_discussions(self): def delete(self): """ - Delete the model evaluation store + Delete the model comparison """ return self.client._perform_empty("DELETE", "/projects/%s/modelcomparisons/%s" % (self.project_key, self.mec_id)) -class DSSModelComparatorSettings: +class DSSModelComparisonSettings: """ - A handle on the settings of a model comparator + A handle on the settings of a model comparison - A model comparator has: + A model comparison has: - a display name ; - a prediction type ; - a list of full ids of items to compare @@ -70,18 +70,18 @@ class DSSModelComparatorSettings: - the model evaluation id of a model evaluation, such as ME-PROJECTKEY-STOREID-MEID (visible on the summary tab of the model evaluation). - Do not create this class directly, instead use :meth:`dataikuapi.dss.DSSModelComparator.get_settings` + Do not create this class directly, instead use :meth:`dataikuapi.dss.DSSModelComparison.get_settings` """ - def __init__(self, model_comparator, settings): - self.model_comparator = model_comparator + def __init__(self, model_comparison, settings): + self.model_comparison = model_comparison self.settings = settings def get_raw(self): """ - Gets raw settings of a model comparator + Gets raw settings of a model comparison - :return: the raw settings of comparator, as a dict. Modifications made to the returned object + :return: the raw settings of comparison, as a dict. Modifications made to the returned object are reflected when saving :rtype: dict """ @@ -111,7 +111,7 @@ def remove_compared_item(self, full_id): def get_compared_items(self): """ - Gets the full ids of items compared in this comparator instance + Gets the full ids of items compared in this comparison :return: the list of the full ids of compared items :rtype: list[str] @@ -122,7 +122,7 @@ def get_compared_items(self): def get_prediction_type(self): """ - Gets the prediction type of this comparator instance + Gets the prediction type of this comparison :return: str """ @@ -130,7 +130,7 @@ def get_prediction_type(self): def set_prediction_type(self, prediction_type): """ - Sets the prediction type of this comparator instance. Must be consistent + Sets the prediction type of this comparison. Must be consistent with the prediction types of compared items. :param prediction_type: @@ -139,7 +139,7 @@ def set_prediction_type(self, prediction_type): def get_display_name(self): """ - Human readable name of this comparator instance + Human readable name of this comparison :return: str """ @@ -147,7 +147,7 @@ def get_display_name(self): def set_display_name(self, display_name): """ - Set the human readable name of this comparator instance + Set the human readable name of this comparison :param display_name: """ @@ -157,7 +157,7 @@ def save(self): """ Save settings modifications """ - self.model_comparator.client._perform_empty( - "PUT", "/projects/%s/modelcomparisons/%s" % (self.model_comparator.project_key, self.model_comparator.mec_id), + self.model_comparison.client._perform_empty( + "PUT", "/projects/%s/modelcomparisons/%s" % (self.model_comparison.project_key, self.model_comparison.mec_id), body=self.settings) diff --git a/dataikuapi/dss/project.py b/dataikuapi/dss/project.py index 7af39f65..4a5f8842 100644 --- a/dataikuapi/dss/project.py +++ b/dataikuapi/dss/project.py @@ -1,6 +1,6 @@ import time, warnings, sys, os.path as osp from .dataset import DSSDataset, DSSDatasetListItem, DSSManagedDatasetCreationHelper -from .modelcomparator import DSSModelComparator +from .modelcomparison import DSSModelComparison from .jupyternotebook import DSSJupyterNotebook, DSSJupyterNotebookListItem from .notebook import DSSNotebook from .streaming_endpoint import DSSStreamingEndpoint, DSSStreamingEndpointListItem, DSSManagedStreamingEndpointCreationHelper @@ -802,42 +802,39 @@ def create_model_evaluation_store(self, name): return DSSModelEvaluationStore(self.client, self.project_key, mes_id) ######################################################## - # Model comparators + # Model comparisons ######################################################## - def list_model_comparators(self, as_type=None): + def list_model_comparisons(self): """ - List the model comparators in this project. + List the model comparisons in this project. - :returns: The list of the model comparators + :returns: The list of the model comparisons :rtype: list """ items = self.client._perform_json("GET", "/projects/%s/modelcomparisons/" % self.project_key) - if as_type == "objects" or as_type == "object": - return [DSSModelComparator(self.client, self.project_key, item["id"]) for item in items] - else: - return items + return [DSSModelComparison(self.client, self.project_key, item["id"]) for item in items] - def get_model_comparator(self, mec_id): + def get_model_comparison(self, mec_id): """ - Get a handle to interact with a specific model comparator + Get a handle to interact with a specific model comparison - :param string mec_id: the id of the desired model comparator + :param string mec_id: the id of the desired model comparison - :returns: A :class:`dataikuapi.dss.modelcomparator.DSSModelComparator` model comparator handle - :rtype: :class:`dataikuapi.dss.modelcomparator.DSSModelComparator` + :returns: A handle on a model comparison + :rtype: :class:`dataikuapi.dss.modelcomparison.DSSModelComparison` """ - return DSSModelComparator(self.client, self.project_key, mec_id) + return DSSModelComparison(self.client, self.project_key, mec_id) - def create_model_comparator(self, name, prediction_type): + def create_model_comparison(self, name, prediction_type): """ - Create a new model comparator in the project, and return a handle to interact with it. + Create a new model comparison in the project, and return a handle to interact with it. - :param string name: the name for the new model comparator + :param string name: the name for the new model comparison :param string prediction_type: one of BINARY_CLASSIFICATION, REGRESSION and MULTICLASS - :returns: A :class:`dataikuapi.dss.modelcomparator.DSSModelComparator` model comparator handle - :rtype: :class:`dataikuapi.dss.modelcomparator.DSSModelComparator` + :returns: A handle on a new model comparison + :rtype: :class:`dataikuapi.dss.modelcomparison.DSSModelComparison` """ obj = { "projectKey": self.project_key, @@ -847,7 +844,7 @@ def create_model_comparator(self, name, prediction_type): res = self.client._perform_json("POST", "/projects/%s/modelcomparisons/" % self.project_key, body = obj) mec_id = res['id'] - return DSSModelComparator(self.client, self.project_key, mec_id) + return DSSModelComparison(self.client, self.project_key, mec_id) ######################################################## # Jobs From e5c0fa509879601fe2829613e0773d538329d620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Pe=CC=81net?= Date: Mon, 13 Sep 2021 11:21:31 +0200 Subject: [PATCH 4/8] Removing id examples and info on location. --- dataikuapi/dss/modelcomparison.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dataikuapi/dss/modelcomparison.py b/dataikuapi/dss/modelcomparison.py index 8e85c58e..749fdfb9 100644 --- a/dataikuapi/dss/modelcomparison.py +++ b/dataikuapi/dss/modelcomparison.py @@ -65,9 +65,9 @@ class DSSModelComparisonSettings: - MULTICLASS The full ids are: - - the model id of a Lab Model, such as A-PROJECTKEY-LABID-MODELID-s1-pp1-m1 (visible on the summary tab of the model) ; - - the model id of a saved model version, such as S-PROJECTKEY-SMID-1234567891234 (visible on the summary tab of the model) ; - - the model evaluation id of a model evaluation, such as ME-PROJECTKEY-STOREID-MEID (visible on the summary tab of the model evaluation). + - the model id of a Lab Model, + - the model id of a saved model version, + - the model evaluation id of a model evaluation. Do not create this class directly, instead use :meth:`dataikuapi.dss.DSSModelComparison.get_settings` From aa5177f366adb9cd68e4f440f08cca9e3fc8ef12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Pe=CC=81net?= Date: Mon, 13 Sep 2021 13:26:02 +0200 Subject: [PATCH 5/8] Turning prediction_type and display_name into properties. --- dataikuapi/dss/modelcomparison.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dataikuapi/dss/modelcomparison.py b/dataikuapi/dss/modelcomparison.py index 749fdfb9..1dc56061 100644 --- a/dataikuapi/dss/modelcomparison.py +++ b/dataikuapi/dss/modelcomparison.py @@ -23,7 +23,7 @@ def get_settings(self): """ Returns the settings of this model comparison. - :rtype: DSSModelComparisonSettings + :rtype: :class:`dataikuapi.dss.modelcomparison.DSSModelComparisonSettings` """ data = self.client._perform_json( "GET", "/projects/%s/modelcomparisons/%s" % (self.project_key, self.mec_id)) @@ -50,7 +50,7 @@ def delete(self): return self.client._perform_empty("DELETE", "/projects/%s/modelcomparisons/%s" % (self.project_key, self.mec_id)) -class DSSModelComparisonSettings: +class DSSModelComparisonSettings(object): """ A handle on the settings of a model comparison @@ -120,7 +120,8 @@ def get_compared_items(self): return [] return map(lambda x: x["refId"], self.settings["comparedModels"]) - def get_prediction_type(self): + @property + def prediction_type(self): """ Gets the prediction type of this comparison @@ -128,7 +129,8 @@ def get_prediction_type(self): """ return self.settings["predictionType"] - def set_prediction_type(self, prediction_type): + @prediction_type.setter + def prediction_type(self, prediction_type): """ Sets the prediction type of this comparison. Must be consistent with the prediction types of compared items. @@ -137,7 +139,8 @@ def set_prediction_type(self, prediction_type): """ self.settings["predictionType"] = prediction_type - def get_display_name(self): + @property + def display_name(self): """ Human readable name of this comparison @@ -145,7 +148,8 @@ def get_display_name(self): """ return self.settings["displayName"] - def set_display_name(self, display_name): + @display_name.setter + def display_name(self, display_name): """ Set the human readable name of this comparison From e084fbe8a85be9627710db98fb94dbe372475c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Pe=CC=81net?= Date: Mon, 13 Sep 2021 13:28:37 +0200 Subject: [PATCH 6/8] Removing no longer needed import. --- dataikuapi/dss/modelcomparison.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/dataikuapi/dss/modelcomparison.py b/dataikuapi/dss/modelcomparison.py index 1dc56061..96cd3d68 100644 --- a/dataikuapi/dss/modelcomparison.py +++ b/dataikuapi/dss/modelcomparison.py @@ -1,5 +1,3 @@ -import json - from dataikuapi.dss.discussion import DSSObjectDiscussions From 97e83b0dc6531976426269581f8c1f6b6c1bbbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Pe=CC=81net?= Date: Mon, 13 Sep 2021 13:33:04 +0200 Subject: [PATCH 7/8] Nitpick wording and punctuation. --- dataikuapi/dss/modelcomparison.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dataikuapi/dss/modelcomparison.py b/dataikuapi/dss/modelcomparison.py index 96cd3d68..48f0cd50 100644 --- a/dataikuapi/dss/modelcomparison.py +++ b/dataikuapi/dss/modelcomparison.py @@ -3,7 +3,7 @@ class DSSModelComparison(object): """ - A handle to interact with a model comparison on the DSS instance. + A handle to interact with a model comparison on the DSS instance Do not create this directly, use :meth:`dataikuapi.dss.DSSProject.get_model_comparison` """ @@ -19,7 +19,7 @@ def id(self): def get_settings(self): """ - Returns the settings of this model comparison. + Returns the settings of this model comparison :rtype: :class:`dataikuapi.dss.modelcomparison.DSSModelComparisonSettings` """ @@ -70,14 +70,13 @@ class DSSModelComparisonSettings(object): Do not create this class directly, instead use :meth:`dataikuapi.dss.DSSModelComparison.get_settings` """ - def __init__(self, model_comparison, settings): self.model_comparison = model_comparison self.settings = settings def get_raw(self): """ - Gets raw settings of a model comparison + Get raw settings of a model comparison :return: the raw settings of comparison, as a dict. Modifications made to the returned object are reflected when saving @@ -109,7 +108,7 @@ def remove_compared_item(self, full_id): def get_compared_items(self): """ - Gets the full ids of items compared in this comparison + Get the full ids of items compared in this comparison :return: the list of the full ids of compared items :rtype: list[str] @@ -121,7 +120,7 @@ def get_compared_items(self): @property def prediction_type(self): """ - Gets the prediction type of this comparison + Get the prediction type of this comparison :return: str """ @@ -130,7 +129,7 @@ def prediction_type(self): @prediction_type.setter def prediction_type(self, prediction_type): """ - Sets the prediction type of this comparison. Must be consistent + Set the prediction type of this comparison. Must be consistent with the prediction types of compared items. :param prediction_type: From e776034ee0a63f23b32ee1b365b4536d28bccc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20P=C3=A9net?= Date: Thu, 16 Sep 2021 15:59:10 +0200 Subject: [PATCH 8/8] Use [ ... for ... in ] rather than map (python 2/3 consistency) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément BRUN <57680293+cbrun-dku@users.noreply.github.com> --- dataikuapi/dss/modelcomparison.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataikuapi/dss/modelcomparison.py b/dataikuapi/dss/modelcomparison.py index 48f0cd50..8562140a 100644 --- a/dataikuapi/dss/modelcomparison.py +++ b/dataikuapi/dss/modelcomparison.py @@ -115,7 +115,7 @@ def get_compared_items(self): """ if not self.settings["comparedModels"]: return [] - return map(lambda x: x["refId"], self.settings["comparedModels"]) + return [x["refId"] for x in self.settings["comparedModels"]] @property def prediction_type(self):