class_docstr: ExperimentClient providing all functionalities for the python API
  
  Note that the ExperimentClient is not meant to be instantiated by the user.
  Look at `orion.client.create_experiment` to build an ExperimentClient.
  
  Parameters
  ----------
  experiment: `orion.core.worker.experiment.Experiment`
      Experiment object serving for interaction with storage
class_docstr_tok: ["ExperimentClient","providing","all","functionalities","for","the","python","API","Note","that","the","ExperimentClient","is","not","meant","to","be","instantiated","by","the","user",".","Look","at","`","orion.client.create_experiment","`","to","build","an","ExperimentClient",".","Parameters","--","--","--","--","--","experiment",":","`","orion.core.worker.experiment.Experiment","`","Experiment","object","serving","for","interaction","with","storage"]
docstr: Reserve a trial.
  
  Experiment must be in executable ('x') mode.
  
  Set a trial status to reserve to ensure that concurrent process cannot work on it.
  Trials can only be reserved with status 'new', 'interrupted' or 'suspended'.
  
  Parameters
  ----------
  trial: `orion.core.worker.trial.Trial`
      Trial to reserve.
  
  Raises
  ------
  `RuntimeError`
      If trial is reserved by another process
  `ValueError`
      If the trial does not exist in storage.
  `orion.core.utils.exceptions.UnsupportedOperation`
      If the experiment was not loaded in executable mode.
  
  Notes
  -----
  When reserved, a :class:`TrialPacemaker <orion.core.worker.trial_pacemaker.TrialPacemaker>`
  is started to update an heartbeat in storage. The frequency of the heartbeat is configurable
  at creation of experiment or with ``orion.core.config.worker.heartbeat``.
  If the process terminates unexpectedly, the heartbeat will cease and remote processes
  may reset the status of the trial to 'interrupted' when the heartbeat has not been updated
  since twice the value of ``heartbeat``.
docstr_tok: ["Reserve","a","trial",".","Experiment","must","be","in","executable","(","'","x","'",")","mode",".","Set","a","trial","status","to","reserve","to","ensure","that","concurrent","process","can","not","work","on","it",".","Trials","can","only","be","reserved","with","status","'new","'",",","'interrupted","'","or","'suspended","'",".","Parameters","--","--","--","--","--","trial",":","`","orion.core.worker.trial.Trial","`","Trial","to","reserve",".","Raises","--","--","--","`","RuntimeError","`","If","trial","is","reserved","by","another","process","`","ValueError","`","If","the","trial","does","not","exist","in","storage",".","`","orion.core.utils.exceptions.UnsupportedOperation","`","If","the","experiment","was","not","loaded","in","executable","mode",".","Notes","--","--","-","When","reserved",",","a",":","class",":","`","TrialPacemaker","<","orion.core.worker.trial_pacemaker.TrialPacemaker",">","`","is","started","to","update","an","heartbeat","in","storage",".","The","frequency","of","the","heartbeat","is","configurable","at","creation","of","experiment","or","with","``","orion.core.config.worker.heartbeat","``",".","If","the","process","terminates","unexpectedly",",","the","heartbeat","will","cease","and","remote","processes","may","reset","the","status","of","the","trial","to","'interrupted","'","when","the","heartbeat","has","not","been","updated","since","twice","the","value","of","``","heartbeat","``","."]
code: def reserve(self, trial):
      """Reserve a trial.
  
      Experiment must be in executable ('x') mode.
  
      Set a trial status to reserve to ensure that concurrent process cannot work on it.
      Trials can only be reserved with status 'new', 'interrupted' or 'suspended'.
  
      Parameters
      ----------
      trial: `orion.core.worker.trial.Trial`
          Trial to reserve.
  
      Raises
      ------
      `RuntimeError`
          If trial is reserved by another process
      `ValueError`
          If the trial does not exist in storage.
      `orion.core.utils.exceptions.UnsupportedOperation`
          If the experiment was not loaded in executable mode.
  
      Notes
      -----
      When reserved, a :class:`TrialPacemaker <orion.core.worker.trial_pacemaker.TrialPacemaker>`
      is started to update an heartbeat in storage. The frequency of the heartbeat is configurable
      at creation of experiment or with ``orion.core.config.worker.heartbeat``.
      If the process terminates unexpectedly, the heartbeat will cease and remote processes
      may reset the status of the trial to 'interrupted' when the heartbeat has not been updated
      since twice the value of ``heartbeat``.
  
      """
      self._check_if_executable()
  
      if trial.status == "reserved" and trial.id in self._pacemakers:
          log.warning("Trial %s is already reserved.", trial.id)
          return
      elif (
          trial.status == "reserved"
          and trial.id not in self._pacemakers
      ):
          raise RuntimeError(
              f"Trial {trial.id} is already reserved by another process."
          )
      try:
          self._experiment.set_trial_status(
              trial, "reserved", heartbeat=self.heartbeat
          )
      except FailedUpdate as e:
          if self.get_trial(trial) is None:
              raise ValueError(
                  f"Trial {trial.id} does not exist in database."
              ) from e
          raise RuntimeError(
              f"Could not reserve trial {trial.id}."
          ) from e
  
      self._maintain_reservation(trial)
  
imports: from __future__ import annotations
  import inspect
  import logging
  import numbers
  import typing
  from contextlib import contextmanager
  from typing import Callable
  import orion.core
  from orion.algo.space import Space
  from orion.client.runner import Runner, prepare_trial_working_dir
  from orion.core.io.database import DuplicateKeyError
  from orion.core.utils.exceptions import BrokenExperiment, CompletedExperiment, ReservationRaceCondition, UnsupportedOperation, WaitingForTrials
  from orion.core.utils.format_trials import dict_to_trial
  from orion.core.utils.working_dir import SetupWorkingDir
  from orion.core.worker.experiment import AlgoT
  from orion.core.worker.producer import Producer
  from orion.core.worker.trial import AlreadyReleased, Trial, TrialCM
  from orion.core.worker.trial_pacemaker import TrialPacemaker
  from orion.executor.base import BaseExecutor, executor_factory
  from orion.plotting.base import PlotAccessor
  from orion.storage.base import FailedUpdate
label_desc: Use image node_id 30 for calling the ExperimentClient obj's underlying member method code with example usage: obj.reserve(trial) without return types