docstr: Tests MinTrials and MaxTrials default to experiment
  level trials when trials_from_node is None.
docstr_tok: ["Tests","MinTrials","and","MaxTrials","default","to","experiment","level","trials","when","trials_from_node","is","None","."]
code: def test_trials_from_node_none(self) -> None:
      """Tests MinTrials and MaxTrials default to experiment
      level trials when trials_from_node is None.
      """
      experiment = get_experiment()
      gs = GenerationStrategy(
          name="SOBOL::default",
          steps=[
              GenerationStep(
                  model=Models.SOBOL,
                  num_trials=4,
                  min_trials_observed=2,
                  enforce_num_trials=True,
              ),
          ],
      )
      max_criterion_with_status = MaxTrials(
          threshold=2,
          block_gen_if_met=True,
          only_in_statuses=[TrialStatus.COMPLETED],
      )
      max_criterion = MaxTrials(threshold=2, block_gen_if_met=True)
      warning_msg = (
          "`trials_from_node` is None, will check threshold on"
          + " experiment level."
      )
  
      # no trials so criterion should be false, then add trials to pass criterion
      with self.assertLogs(
          TransitionCriterion.__module__, logging.WARNING
      ) as logger:
          self.assertFalse(
              max_criterion.is_met(experiment, trials_from_node=None)
          )
          self.assertTrue(
              any(warning_msg in output for output in logger.output),
              logger.output,
          )
      for _i in range(3):
          experiment.new_trial(gs.gen(experiment=experiment))
      self.assertTrue(
          max_criterion.is_met(experiment, trials_from_node=None)
      )
  
      # Before marking trial status it should be false, until trials are completed
      self.assertFalse(
          max_criterion_with_status.is_met(
              experiment, trials_from_node=None
          )
      )
      for idx, trial in experiment.trials.items():
          trial._status = TrialStatus.COMPLETED
          if idx == 1:
              break
      self.assertTrue(
          max_criterion_with_status.is_met(
              experiment, trials_from_node=None
          )
      )
  
      # Check MinTrials
      min_criterion = MinTrials(
          threshold=3,
          only_in_statuses=[
              TrialStatus.COMPLETED,
              TrialStatus.EARLY_STOPPED,
          ],
      )
      with self.assertLogs(
          TransitionCriterion.__module__, logging.WARNING
      ) as logger:
          self.assertFalse(
              min_criterion.is_met(experiment, trials_from_node=None)
          )
          self.assertTrue(
              any(warning_msg in output for output in logger.output),
              logger.output,
          )
      for _idx, trial in experiment.trials.items():
          trial._status = TrialStatus.COMPLETED
      self.assertTrue(
          min_criterion.is_met(experiment, trials_from_node=None)
      )
  
file_path: Ax/ax/modelbridge/tests/test_transition_criterion.py
imports: import logging
  from logging import Logger
  from unittest.mock import patch
  import pandas
  from ax.core.base_trial import TrialStatus
  from ax.core.data import Data
  from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy
  from ax.modelbridge.registry import Models
  from ax.modelbridge.transition_criterion import MaxGenerationParallelism, MaxTrials, MinimumPreferenceOccurances, MinimumTrialsInStatus, MinTrials, TransitionCriterion
  from ax.utils.common.logger import get_logger
  from ax.utils.common.testutils import TestCase
  from ax.utils.testing.core_stubs import get_branin_experiment, get_experiment
label_desc: Use image node_id 5 for calling the TestTransitionCriterion obj's underlying member method code with example usage: obj.test_trials_from_node_none() without return types