class_docstr: Helper class providing methods for saving changes made to an experiment
  if `db_settings` property is set to a non-None value on the instance.
class_docstr_tok: ["Helper","class","providing","methods","for","saving","changes","made","to","an","experiment","if","`","db_settings","`","property","is","set","to","a","non-None","value","on","the","instance","."]
docstr: If DB settings are set on this `WithDBSettingsBase` instance, checks
  whether given experiment and generation strategy are already saved and
  saves them, if not.
  
  Returns:
      Tuple of two booleans: whether experiment was saved in the course of
          this function's execution and whether generation strategy was
          saved.
docstr_tok: ["If","DB","settings","are","set","on","this","`","WithDBSettingsBase","`","instance",",","checks","whether","given","experiment","and","generation","strategy","are","already","saved","and","saves","them",",","if","not",".","Returns",":","Tuple","of","two","booleans",":","whether","experiment","was","saved","in","the","course","of","this","function","'s","execution","and","whether","generation","strategy","was","saved","."]
code: def _maybe_save_experiment_and_generation_strategy(
      self,
      experiment: Experiment,
      generation_strategy: GenerationStrategyInterface,
  ) -> Tuple[bool, bool]:
      """If DB settings are set on this `WithDBSettingsBase` instance, checks
      whether given experiment and generation strategy are already saved and
      saves them, if not.
  
      Returns:
          Tuple of two booleans: whether experiment was saved in the course of
              this function's execution and whether generation strategy was
              saved.
      """
      saved_exp, saved_gs = False, False
      if self.db_settings_set:
          if experiment._name is None:
              raise ValueError(
                  "Experiment must specify a name to use storage functionality."
              )
          exp_name = not_none(experiment.name)
          (
              exp_id,
              gs_id,
          ) = self._get_experiment_and_generation_strategy_db_id(
              experiment_name=exp_name
          )
          if exp_id:  # Experiment in DB.
              logger.info(
                  f"Experiment {exp_name} is in DB, updating it."
              )
              self._save_experiment_to_db_if_possible(
                  experiment=experiment
              )
              saved_exp = True
          else:  # Experiment not yet in DB.
              logger.info(
                  f"Experiment {exp_name} is not yet in DB, storing it."
              )
              self._save_experiment_to_db_if_possible(
                  experiment=experiment
              )
              saved_exp = True
          if gs_id and generation_strategy._db_id != gs_id:
              raise UnsupportedError(
                  "Experiment was associated with generation strategy in DB, "
                  f"but a new generation strategy {generation_strategy.name} "
                  "was provided. To use the generation strategy currently in DB,"
                  " instantiate scheduler via: `Scheduler.from_stored_experiment`."
              )
          if not gs_id or generation_strategy._db_id is None:
              # There is no GS associated with experiment or the generation
              # strategy passed in is different from the one associated with
              # experiment currently.
              logger.info(
                  f"Generation strategy {generation_strategy.name} is not yet in DB, "
                  "storing it."
              )
              # If generation strategy does not yet have an experiment attached,
              # attach the current experiment to it, as otherwise it will not be
              # possible to retrieve by experiment name.
              if generation_strategy._experiment is None:
                  generation_strategy.experiment = experiment
              self._save_generation_strategy_to_db_if_possible(
                  generation_strategy=generation_strategy
              )
              saved_gs = True
      return saved_exp, saved_gs
  
imports: import re
  import time
  from logging import INFO, Logger
  from typing import Any, Dict, List, Optional, Tuple, Type
  from ax.core.base_trial import BaseTrial
  from ax.core.experiment import Experiment
  from ax.core.generation_strategy_interface import GenerationStrategyInterface
  from ax.core.generator_run import GeneratorRun
  from ax.exceptions.core import IncompatibleDependencyVersion, ObjectNotFoundError, UnsupportedError
  from ax.modelbridge.generation_strategy import GenerationStrategy
  from ax.utils.common.executils import retry_on_exception
  from ax.utils.common.logger import _round_floats_for_logging, get_logger
  from ax.utils.common.typeutils import not_none
label_desc: Use image node_id 6 for calling the WithDBSettingsBase obj's underlying member method code with example usage: obj._maybe_save_experiment_and_generation_strategy(experiment, generation_strategy) and returns: saved_exp,  saved_gs