class_docstr: Testing the instantiation utilities functionality that is not tested in
  main `AxClient` testing suite (`TestServiceAPI`).
class_docstr_tok: ["Testing","the","instantiation","utilities","functionality","that","is","not","tested","in","main","`","AxClient","`","testing","suite","(","`","TestServiceAPI","`",")","."]
code: def test_constraint_from_str(self) -> None:
      with self.assertRaisesRegex(
          ValueError, "Bound for the constraint"
      ):
          InstantiationBase.constraint_from_str(
              "x1 + x2 <= not_numerical_bound",
              # pyre-fixme[6]: For 2nd param expected `Dict[str, Parameter]` but
              #  got `Dict[str, None]`.
              {"x1": None, "x2": None},
          )
      with self.assertRaisesRegex(
          ValueError, "Outcome constraint bound"
      ):
          InstantiationBase.outcome_constraint_from_str(
              "m1 <= not_numerical_bound"
          )
      three_val_constaint = InstantiationBase.constraint_from_str(
          "x1 + x2 + x3 <= 3",
          {
              "x1": RangeParameter(
                  name="x1",
                  parameter_type=ParameterType.FLOAT,
                  lower=0.1,
                  upper=2.0,
              ),
              "x2": RangeParameter(
                  name="x2",
                  parameter_type=ParameterType.FLOAT,
                  lower=0.1,
                  upper=2.0,
              ),
              "x3": RangeParameter(
                  name="x3",
                  parameter_type=ParameterType.FLOAT,
                  lower=0.1,
                  upper=2.0,
              ),
          },
      )
  
      self.assertEqual(three_val_constaint.bound, 3.0)
      with self.assertRaisesRegex(
          ValueError, "Parameter constraint should"
      ):
          InstantiationBase.constraint_from_str(
              "x1 + x2 + <= 3",
              # pyre-fixme[6]: For 2nd param expected `Dict[str, Parameter]` but
              #  got `Dict[str, None]`.
              {"x1": None, "x2": None, "x3": None},
          )
      with self.assertRaisesRegex(
          ValueError, "Parameter constraint should"
      ):
          InstantiationBase.constraint_from_str(
              "x1 + x2 + x3 = 3",
              # pyre-fixme[6]: For 2nd param expected `Dict[str, Parameter]` but
              #  got `Dict[str, None]`.
              {"x1": None, "x2": None, "x3": None},
          )
      one_val_constraint = InstantiationBase.constraint_from_str(
          "x1 <= 0",
          # pyre-fixme[6]: For 2nd param expected `Dict[str, Parameter]` but
          #  got `Dict[str, None]`.
          {"x1": None, "x2": None},
      )
      self.assertEqual(one_val_constraint.bound, 0.0)
      self.assertEqual(one_val_constraint.constraint_dict, {"x1": 1.0})
      one_val_constraint = InstantiationBase.constraint_from_str(
          "-0.5*x1 >= -0.1",
          # pyre-fixme[6]: For 2nd param expected `Dict[str, Parameter]` but
          #  got `Dict[str, None]`.
          {"x1": None, "x2": None},
      )
      self.assertEqual(one_val_constraint.bound, 0.1)
      self.assertEqual(one_val_constraint.constraint_dict, {"x1": 0.5})
      three_val_constaint2 = InstantiationBase.constraint_from_str(
          "-x1 + 2.1*x2 - 4*x3 <= 3",
          {
              "x1": RangeParameter(
                  name="x1",
                  parameter_type=ParameterType.FLOAT,
                  lower=0.1,
                  upper=4.0,
              ),
              "x2": RangeParameter(
                  name="x2",
                  parameter_type=ParameterType.FLOAT,
                  lower=0.1,
                  upper=4.0,
              ),
              "x3": RangeParameter(
                  name="x3",
                  parameter_type=ParameterType.FLOAT,
                  lower=0.1,
                  upper=4.0,
              ),
          },
      )
  
      self.assertEqual(three_val_constaint2.bound, 3.0)
      self.assertEqual(
          three_val_constaint2.constraint_dict,
          {"x1": -1.0, "x2": 2.1, "x3": -4.0},
      )
      with self.assertRaisesRegex(
          ValueError, "Multiplier should be float"
      ):
          InstantiationBase.constraint_from_str(
              "x1 - e*x2 + x3 <= 3",
              # pyre-fixme[6]: For 2nd param expected `Dict[str, Parameter]` but
              #  got `Dict[str, None]`.
              {"x1": None, "x2": None, "x3": None},
          )
      with self.assertRaisesRegex(
          ValueError, "A linear constraint should be"
      ):
          InstantiationBase.constraint_from_str(
              "x1 - 2 *x2 + 3 *x3 <= 3",
              # pyre-fixme[6]: For 2nd param expected `Dict[str, Parameter]` but
              #  got `Dict[str, None]`.
              {"x1": None, "x2": None, "x3": None},
          )
      with self.assertRaisesRegex(
          ValueError, "A linear constraint should be"
      ):
          InstantiationBase.constraint_from_str(
              "x1 - 2* x2 + 3* x3 <= 3",
              # pyre-fixme[6]: For 2nd param expected `Dict[str, Parameter]` but
              #  got `Dict[str, None]`.
              {"x1": None, "x2": None, "x3": None},
          )
      with self.assertRaisesRegex(
          ValueError, "A linear constraint should be"
      ):
          InstantiationBase.constraint_from_str(
              "x1 - 2 * x2 + 3*x3 <= 3",
              # pyre-fixme[6]: For 2nd param expected `Dict[str, Parameter]` but
              #  got `Dict[str, None]`.
              {"x1": None, "x2": None, "x3": None},
          )
  
file_path: Ax/ax/service/tests/test_instantiation_utils.py
imports: from typing import Any, Dict
  from ax.core.metric import Metric
  from ax.core.optimization_config import MultiObjectiveOptimizationConfig
  from ax.core.parameter import FixedParameter, ParameterType, RangeParameter
  from ax.core.search_space import HierarchicalSearchSpace
  from ax.exceptions.core import UnsupportedError
  from ax.service.utils.instantiation import InstantiationBase
  from ax.utils.common.testutils import TestCase
  from ax.utils.common.typeutils import checked_cast
label_desc: Use image node_id 2 for calling the TestInstantiationtUtils obj's underlying member method code with example usage: obj.test_constraint_from_str() without return types