code: def test_monotone_constraints():
      ds = import_dataset()
      aml = H2OAutoML(
          project_name="py_monotone_constraints",
          monotone_constraints=dict(
              AGE=1, VOL=-1
          ),  # constraints just for the sake of testing
          max_models=6,
          seed=1,
      )
      aml.train(y=ds.target, training_frame=ds.train)
      model_names = get_partitioned_model_names(aml.leaderboard).all
      models_supporting_monotone_constraints = [
          n for n in model_names if re.match(r"GBM|XGBoost", n)
      ]
      assert len(models_supporting_monotone_constraints) < len(
          model_names
      ), "models not supporting the constraint should not have been skipped"
      for m in models_supporting_monotone_constraints:
          model = h2o.get_model(m)
          value = next(
              v["actual"]
              for n, v in model.params.items()
              if n == "monotone_constraints"
          )
          assert isinstance(value, list)
          assert len(value) == 2
          age = next((v for v in value if v["key"] == "AGE"), None)
          assert age is not None
          assert age["value"] == 1.0
          vol = next((v for v in value if v["key"] == "VOL"), None)
          assert vol is not None
          assert vol["value"] == -1.0
  
file_path: h2o-3/h2o-py/tests/testdir_algos/automl/pyunit_automl_monotone_constraints.py
imports: import sys, os
  import re
  import h2o
  import h2o.exceptions
  from h2o.automl import H2OAutoML
  from tests import pyunit_utils
  from _automl_utils import import_dataset, get_partitioned_model_names
label_desc: Use image node_id 1 for calling a global function with example usage: test_monotone_constraints() without return types