Skip to content

Commit f68a7f7

Browse files
committed
hints: add helper in DSSTrainedModelDetails
1 parent 1433ba6 commit f68a7f7

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

dataikuapi/dss/ml.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,62 @@ def get_origin_analysis_trained_model(self):
543543
project_key=self.saved_model.project_key)
544544
return origin_ml_task.get_trained_model_details(fmi)
545545

546+
def get_hints(self):
547+
"""
548+
Retrieve hints computed for this trained model
549+
550+
:returns: list of hints
551+
:rtype: list of type `dataikuapi.dss.ml.DSSMLHint`
552+
"""
553+
hints = self.details.get("trainHints", {})
554+
return [DSSMLHint(d) for d in hints.get("hints", [])]
555+
556+
557+
class DSSMLHint(object):
558+
"""
559+
Object that represents a computed Hint on a trained models
560+
561+
Do not create this object directly, use :meth:`DSSTrainedModelDetails.get_hints()` instead
562+
"""
563+
564+
def __init__(self, data):
565+
self._internal_dict = data
566+
567+
def get_raw(self):
568+
"""
569+
Gets the raw dictionary of the hint
570+
571+
:rtype: dict
572+
"""
573+
return self._internal_dict
574+
575+
def get_type(self):
576+
"""
577+
Return the base Hint type
578+
:rtype: str
579+
"""
580+
return self._internal_dict["type"]
581+
582+
def get_type_pretty(self):
583+
"""
584+
Return the Hint type as displayed in the UI
585+
:rtype: str
586+
"""
587+
return self._internal_dict["displayableType"]
588+
589+
def get_message(self):
590+
"""
591+
Return the message as displayed in the UI
592+
:rtype: str
593+
"""
594+
return self._internal_dict["message"]
595+
596+
def __repr__(self):
597+
return "{cls}(type={type}, message={msg})".format(cls=self.__class__.__name__,
598+
type=self._internal_dict["type"],
599+
msg=self._internal_dict["message"])
600+
601+
546602
class DSSTreeNode(object):
547603
def __init__(self, tree, i):
548604
self.tree = tree

0 commit comments

Comments
 (0)