class_docstr: Utility to make new experiments using the same storage object.
  
  Parameters
  ----------
  storage: dict or BaseStorageProtocol, optional
      Storage object or storage configuration.
  debug: bool, optional.
      If True, force using EphemeralDB for the storage. Default: False
class_docstr_tok: ["Utility","to","make","new","experiments","using","the","same","storage","object",".","Parameters","--","--","--","--","--","storage",":","dict","or","BaseStorageProtocol",",","optional","Storage","object","or","storage","configuration",".","debug",":","bool",",","optional",".","If","True",",","force","using","EphemeralDB","for","the","storage",".","Default",":","False"]
docstr: Build an experiment object
  
  If new, ``space`` argument must be provided, else all arguments are fetched from the
  database based on (name, version). If any argument given does not match the corresponding
  ones in the database for given (name, version), than the version is incremented and the
  experiment will be a child of the previous version.
  
  Parameters
  ----------
  name: str
      Name of the experiment to build
  version: int, optional
      Version to select. If None, last version will be selected.
      If version given is larger than largest version available, the largest version
      will be selected.
  space: dict, optional
      Optimization space of the algorithm.
      Should have the form ``dict(name='<prior>(args)')``.
  algorithm: str or dict, optional
      Algorithm used for optimization.
  strategy: str or dict, optional
      Deprecated and will be remove in v0.4. It should now be set in algorithm configuration
      directly if it supports it.
  max_trials: int, optional
      Maximum number of trials before the experiment is considered done.
  max_broken: int, optional
      Number of broken trials for the experiment to be considered broken.
  branching: dict, optional
      Arguments to control the branching.
  
      branch_from: str, optional
          Name of the experiment to branch from.
      manual_resolution: bool, optional
          Starts the prompt to resolve manually the conflicts. Defaults to False.
      non_monitored_arguments: list of str, optional
          Will ignore these arguments while looking for differences. Defaults to [].
      ignore_code_changes: bool, optional
          Will ignore code changes while looking for differences. Defaults to False.
      algorithm_change: bool, optional
          Whether to automatically solve the algorithm conflict (change of algo config).
          Defaults to True.
      orion_version_change: bool, optional
          Whether to automatically solve the orion version conflict.
          Defaults to True.
      code_change_type: str, optional
          How to resolve code change automatically. Must be one of 'noeffect', 'unsure' or
          'break'.  Defaults to 'break'.
      cli_change_type: str, optional
          How to resolve cli change automatically.
          Must be one of 'noeffect', 'unsure' or 'break'.
          Defaults to 'break'.
      config_change_type: str, optional
          How to resolve config change automatically. Must be one of 'noeffect', 'unsure' or
          'break'.  Defaults to 'break'.
code: def build(
      self,
      name: str,
      version: int | None = None,
      branching: dict | None = None,
      **config,
  ) -> Experiment:
      """Build an experiment object
  
      If new, ``space`` argument must be provided, else all arguments are fetched from the
      database based on (name, version). If any argument given does not match the corresponding
      ones in the database for given (name, version), than the version is incremented and the
      experiment will be a child of the previous version.
  
      Parameters
      ----------
      name: str
          Name of the experiment to build
      version: int, optional
          Version to select. If None, last version will be selected.
          If version given is larger than largest version available, the largest version
          will be selected.
      space: dict, optional
          Optimization space of the algorithm.
          Should have the form ``dict(name='<prior>(args)')``.
      algorithm: str or dict, optional
          Algorithm used for optimization.
      strategy: str or dict, optional
          Deprecated and will be remove in v0.4. It should now be set in algorithm configuration
          directly if it supports it.
      max_trials: int, optional
          Maximum number of trials before the experiment is considered done.
      max_broken: int, optional
          Number of broken trials for the experiment to be considered broken.
      branching: dict, optional
          Arguments to control the branching.
  
          branch_from: str, optional
              Name of the experiment to branch from.
          manual_resolution: bool, optional
              Starts the prompt to resolve manually the conflicts. Defaults to False.
          non_monitored_arguments: list of str, optional
              Will ignore these arguments while looking for differences. Defaults to [].
          ignore_code_changes: bool, optional
              Will ignore code changes while looking for differences. Defaults to False.
          algorithm_change: bool, optional
              Whether to automatically solve the algorithm conflict (change of algo config).
              Defaults to True.
          orion_version_change: bool, optional
              Whether to automatically solve the orion version conflict.
              Defaults to True.
          code_change_type: str, optional
              How to resolve code change automatically. Must be one of 'noeffect', 'unsure' or
              'break'.  Defaults to 'break'.
          cli_change_type: str, optional
              How to resolve cli change automatically.
              Must be one of 'noeffect', 'unsure' or 'break'.
              Defaults to 'break'.
          config_change_type: str, optional
              How to resolve config change automatically. Must be one of 'noeffect', 'unsure' or
              'break'.  Defaults to 'break'.
  
      """
      log.debug(f"Building experiment {name} with {version}")
      log.debug(
          "    Passed experiment config:\n%s", pprint.pformat(config)
      )
      log.debug("    Branching config:\n%s", pprint.pformat(branching))
  
      name, config, branching = clean_config(name, config, branching)
  
      config = self.consolidate_config(name, version, config)
  
      if "space" not in config:
          raise NoConfigurationError(
              f"Experiment {name} does not exist in DB and space was not defined."
          )
  
      if len(config["space"]) == 0:
          raise NoConfigurationError(
              "No prior found. Please include at least one."
          )
  
      experiment = self.create_experiment(
          mode="x", **copy.deepcopy(config)
      )
      if experiment.id is None:
          log.debug(
              "Experiment not found in DB. Now attempting registration in DB."
          )
          try:
              self._register_experiment(experiment)
              log.debug("Experiment successfully registered in DB.")
          except DuplicateKeyError:
              log.debug(
                  "Experiment registration failed. This is likely due to a race condition. "
                  "Now rolling back and re-attempting building it."
              )
              experiment = self.build(branching=branching, **config)
  
          return experiment
  
      log.debug(
          f"Experiment {config['name']}-v{config['version']} already existed."
      )
  
      conflicts = self._get_conflicts(experiment, branching)
      must_branch = len(conflicts.get()) > 1 or branching.get(
          "branch_to"
      )
  
      if must_branch and branching.get(
          "enable", orion.core.config.evc.enable
      ):
          return self._attempt_branching(
              conflicts, experiment, version, branching
          )
      elif must_branch:
          log.warning(
              "Running experiment in a different state:\n%s",
              self._get_branching_status_string(conflicts, branching),
          )
  
      log.debug("No branching required.")
  
      self._update_experiment(experiment)
      return experiment
  
imports: from __future__ import annotations
  import copy
  import datetime
  import getpass
  import logging
  import pprint
  import sys
  import typing
  from typing import Any, TypeVar
  import orion.core
  from orion.algo.base import BaseAlgorithm, algo_factory
  from orion.algo.space import Space
  from orion.core.evc.adapters import BaseAdapter
  from orion.core.evc.conflicts import ExperimentNameConflict, detect_conflicts
  from orion.core.io import resolve_config
  from orion.core.io.config import ConfigurationError
  from orion.core.io.database import DuplicateKeyError
  from orion.core.io.experiment_branch_builder import ExperimentBranchBuilder
  from orion.core.io.interactive_commands.branching_prompt import BranchingPrompt
  from orion.core.io.space_builder import SpaceBuilder
  from orion.core.utils import backward
  from orion.core.utils.exceptions import BranchingEvent, NoConfigurationError, NoNameError, RaceCondition
  from orion.core.worker.experiment import Experiment, Mode
  from orion.core.worker.experiment_config import ExperimentConfig
  from orion.core.worker.primary_algo import create_algo
  from orion.core.worker.warm_start import KnowledgeBase
  from orion.storage.base import setup_storage
label_desc: Use image node_id 2 for calling the ExperimentBuilder obj's underlying member method code with example usage: obj.build(name, version, branching) and returns: experiment, experiment, self