Skip to content

Commit 15343ea

Browse files
author
arnaudde
committed
Remove checks for assertion names uniqueness and reanme param to parameters in new code
1 parent 537cd67 commit 15343ea

1 file changed

Lines changed: 11 additions & 22 deletions

File tree

dataikuapi/dss/ml.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,15 @@ def get_split_params(self):
434434
@property
435435
def assertions_params(self):
436436
"""
437-
Retrieves the assertions params for this ml task
437+
Retrieves the assertions parameters for this ml task
438438
439439
:rtype: :class:`dataikuapi.dss.ml.DSSMLAssertionsParams`
440440
"""
441441
return self.get_assertions_params()
442442

443443
def get_assertions_params(self):
444444
"""
445-
Retrieves the assertions params for this ml task
445+
Retrieves the assertions parameters for this ml task
446446
447447
:rtype: :class:`dataikuapi.dss.ml.DSSMLAssertionsParams`
448448
"""
@@ -666,31 +666,19 @@ class DSSMLAssertionsParams(object):
666666
Do not create this object directly, use :meth:`DSSPredictionMLTaskSettings.get_assertions_params()` instead
667667
"""
668668

669-
@staticmethod
670-
def check_assertion_names_are_uniq(assertion_params_list):
671-
_ = {}
672-
for assertion_dict in assertion_params_list:
673-
if 'name' not in assertion_dict:
674-
raise ValueError('No name provided for assertion')
675-
if assertion_dict['name'] in _:
676-
raise ValueError('Assertion names must be unique, but got multiple instances of: {}'.format(
677-
assertion_dict['name']))
678-
_[assertion_dict['name']] = True
679-
680669
def __init__(self, data):
681670
self._internal_dict = data
682-
self.check_assertion_names_are_uniq(data["assertions"])
683671

684672
def get_raw(self):
685673
"""
686-
Gets the raw dictionary of the assertions params
674+
Gets the raw dictionary of the assertions parameters
687675
:rtype: dict
688676
"""
689677
return self._internal_dict
690678

691679
def get_assertion(self, assertion_name):
692680
"""
693-
Gets a :class:`dataikuapi.dss.ml.DSSMLAssertionParams` representing the params of the assertion with the
681+
Gets a :class:`dataikuapi.dss.ml.DSSMLAssertionParams` representing the parameters of the assertion with the
694682
provided name (or None if no assertion has that name)
695683
:param str assertion_name: Name of the assertion
696684
:rtype: :class:`dataikuapi.dss.ml.DSSMLAssertionParams` or None
@@ -702,18 +690,19 @@ def get_assertion(self, assertion_name):
702690

703691
def add_assertion(self, assertion_params):
704692
"""
705-
Adds params of an assertion to the assertions params of the ml task.
693+
Adds parameters of an assertion to the assertions parameters of the ml task.
706694
Raises a ValueError if an assertion with the same name already exists
707695
:param object assertion_params: A :class:`~dataikuapi.dss.utils.DSSMLAssertionParams` representing parameters of the assertion
708696
"""
709697
if not isinstance(assertion_params, DSSMLAssertionParams):
710-
raise ValueError('Wrong type for assertion params: {}'.format(type(assertion_params)))
698+
raise ValueError('Wrong type for assertion parameters: {}'.format(type(assertion_params)))
711699
self.check_assertion_names_are_uniq(self._internal_dict["assertions"] + [assertion_params._internal_dict])
700+
712701
self._internal_dict["assertions"].append(assertion_params._internal_dict)
713702

714703
def delete_assertion(self, assertion_name):
715704
"""
716-
Deletes the assertion params of the assertion with the provided name from the `dataikuapi.dss.ml.DSSMLAssertionsParams`
705+
Deletes the assertion parameters of the assertion with the provided name from the `dataikuapi.dss.ml.DSSMLAssertionsParams`
717706
Raises a ValueError if no assertion with the provided name was found
718707
:param str assertion_name: Name of the assertion
719708
"""
@@ -736,7 +725,7 @@ def __init__(self, data):
736725
@staticmethod
737726
def create_from_parts(name, a_filter, condition):
738727
"""
739-
Creates assertion params from name, filter and condition
728+
Creates assertion parameters from name, filter and condition
740729
741730
:param str name: Name of the assertion
742731
:param object a_filter: A :class:`~dataikuapi.dss.utils.DSSFilter` to select assertion population
@@ -752,7 +741,7 @@ def create_from_parts(name, a_filter, condition):
752741

753742
def get_raw(self):
754743
"""
755-
Gets the raw dictionary of the assertion params
744+
Gets the raw dictionary of the assertion parameters
756745
:rtype: dict
757746
"""
758747
return self._internal_dict
@@ -792,7 +781,7 @@ def condition(self):
792781
@condition.setter
793782
def condition(self, condition):
794783
if not isinstance(condition, DSSMLAssertionCondition):
795-
raise ValueError('Wrong type for assertion condition: {}.format(type(condition)))
784+
raise ValueError('Wrong type for assertion condition: {}.format(type(condition))')
796785
self._internal_dict["assertionCondition"] = condition._internal_dict
797786

798787

0 commit comments

Comments
 (0)