code: def get_or_create_benchmark(
      storage,
      name,
      algorithms=None,
      targets=None,
      executor=None,
  ):
      """
      Create or get a benchmark object.
  
      Parameters
      ----------
      storage: BaseStorageProtocol
          Instance of the storage to use
      name: str
          Name of the benchmark
      algorithms: list, optional
          Algorithms used for benchmark, each algorithm can be a string or dict.
      targets: list, optional
          Targets for the benchmark, each target will be a dict with two keys.
  
          assess: list
              Assessment objects
          task: list
              Task objects
      executor: `orion.executor.base.BaseExecutor`, optional
          Executor to run the benchmark experiments
  
      Returns
      -------
      An instance of `orion.benchmark.Benchmark`
      """
  
      # fetch benchmark from db
      db_config = _fetch_benchmark(storage, name)
  
      benchmark_id = None
      input_configure = None
  
      if db_config:
          if algorithms or targets:
              input_benchmark = Benchmark(
                  storage, name, algorithms, targets
              )
              input_configure = input_benchmark.configuration
  
          benchmark_id, algorithms, targets = _resolve_db_config(
              db_config
          )
  
      if not algorithms or not targets:
          raise NoConfigurationError(
              "Benchmark {} does not exist in DB, "
              "algorithms and targets space was not defined.".format(
                  name
              )
          )
  
      benchmark = _create_benchmark(
          storage,
          name,
          algorithms,
          targets,
          executor=executor,
      )
  
      if (
          input_configure
          and input_benchmark.configuration != benchmark.configuration
      ):
          logger.warning(
              f"Benchmark with same name is found but has different configuration, "
              f"which will be used for this creation.\n{benchmark.configuration}"
          )
  
      if benchmark_id is None:
          logger.debug(
              "Benchmark not found in DB. Now attempting registration in DB."
          )
          try:
              _register_benchmark(storage, benchmark)
              logger.debug("Benchmark successfully registered in DB.")
          except DuplicateKeyError:
              logger.info(
                  "Benchmark registration failed. This is likely due to a race condition. "
                  "Now rolling back and re-attempting building it."
              )
              benchmark.close()
              benchmark = get_or_create_benchmark(
                  storage,
                  name,
                  algorithms,
                  targets,
                  executor,
              )
  
      return benchmark
  
file_path: orion/src/orion/benchmark/benchmark_client.py
imports: import datetime
  import logging
  from orion.benchmark import Benchmark, Study
  from orion.benchmark.assessment.base import bench_assessment_factory
  from orion.benchmark.task.base import bench_task_factory
  from orion.core.io.database import DuplicateKeyError
  from orion.core.utils.exceptions import NoConfigurationError
label_desc: Use image node_id 1 for calling a global function with example usage: get_or_create_benchmark(storage, name, algorithms, targets, executor) and returns: benchmark