docstr: Specifying a dummy global stopping strategy which stops
  the optimization after 3 trials are completed.
docstr_tok: ["Specifying","a","dummy","global","stopping","strategy","which","stops","the","optimization","after","3","trials","are","completed","."]
code: def test_global_stopping_integration(self) -> None:
      """
      Specifying a dummy global stopping strategy which stops
      the optimization after 3 trials are completed.
      """
      global_stopping_strategy = DummyGlobalStoppingStrategy(
          min_trials=2, trial_to_stop=3
      )
      ax_client = self.get_ax_client_for_branin(
          global_stopping_strategy=global_stopping_strategy
      )
  
      # Running the first 3 iterations.
      for _ in range(3):
          parameters, trial_index = ax_client.get_next_trial()
          ax_client.complete_trial(
              trial_index=trial_index,
              # pyre-fixme[6]: For 2nd param expected `Union[Dict[str, Union[Tuple[...
              raw_data=self.evaluate(parameters),
          )
  
      # Trying to run the 4th iteration, which should raise
      exception = OptimizationShouldStop(
          message="Stop the optimization."
      )
      with self.assertRaises(OptimizationShouldStop) as cm:
          parameters, trial_index = ax_client.get_next_trial()
      # Assert Exception's message is unchanged.
      self.assertEqual(cm.exception.message, exception.message)
  
      # Trying to run the 4th iteration by overruling the stopping strategy.
      parameters, trial_index = ax_client.get_next_trial(force=True)
      self.assertIsNotNone(parameters)
  
      # Test the property & setter.
      self.assertIs(
          ax_client.global_stopping_strategy, global_stopping_strategy
      )
      new_gss = DummyGlobalStoppingStrategy(
          min_trials=5, trial_to_stop=5
      )
      ax_client.global_stopping_strategy = new_gss
      self.assertIs(ax_client.global_stopping_strategy, new_gss)
      self.assertIs(ax_client._global_stopping_strategy, new_gss)
  
file_path: Ax/ax/service/tests/test_global_stopping.py
imports: from typing import Dict, Tuple
  import numpy
  from ax.core.types import TParameterization
  from ax.exceptions.core import OptimizationShouldStop
  from ax.global_stopping.strategies.base import BaseGlobalStoppingStrategy
  from ax.service.ax_client import AxClient
  from ax.utils.common.testutils import TestCase
  from ax.utils.measurement.synthetic_functions import branin
  from ax.utils.testing.core_stubs import DummyGlobalStoppingStrategy
label_desc: Use image node_id 3 for calling the TestGlobalStoppingIntegration obj's underlying member method code with example usage: obj.test_global_stopping_integration() without return types