class_docstr: Legacy protocol, store all experiments and trials inside the Database()
  
  Parameters
  ----------
  config: Dict
      configuration definition passed from experiment_builder
      to storage factory to legacy constructor.
      See `~orion.io.database.Database` for more details
  setup: bool
      Setup the database (create indexes)
class_docstr_tok: ["Legacy","protocol",",","store","all","experiments","and","trials","inside","the","Database","(",")","Parameters","--","--","--","--","--","config",":","Dict","configuration","definition","passed","from","experiment_builder","to","storage","factory","to","legacy","constructor",".","See","`","~orion.io.database.Database","`","for","more","details","setup",":","bool","Setup","the","database","(","create","indexes",")"]
docstr: See :func:`orion.storage.base.BaseStorageProtocol.write_algorithm_lock`
docstr_tok: ["See",":","func",":","`","orion.storage.base.BaseStorageProtocol.write_algorithm_lock","`"]
code: def write_algorithm_lock(
      self,
      experiment_id,
      algorithm_config,
      locked=0,
      state=None,
      heartbeat=None,
  ):
      """See :func:`orion.storage.base.BaseStorageProtocol.write_algorithm_lock`"""
      return self._db.write(
          "algo",
          {
              "experiment": experiment_id,
              "configuration": algorithm_config,
              "locked": locked,
              "state": None if state is None else pickle.dumps(state),
              "heartbeat": datetime.datetime.utcnow()
              if heartbeat is None
              else heartbeat,
          },
      )
  
imports: import contextlib
  import datetime
  import logging
  import pickle
  import time
  import orion.core
  import orion.core.utils.backward
  from orion.core.io.database import Database, OutdatedDatabaseError, database_factory
  from orion.core.worker.trial import Trial, validate_status
  from orion.storage.base import BaseStorageProtocol, FailedUpdate, LockAcquisitionTimeout, LockedAlgorithmState, get_trial_uid_and_exp, get_uid
label_desc: Use image node_id 28 for calling the Legacy obj's underlying member method code with example usage: obj.write_algorithm_lock(experiment_id, algorithm_config, locked, state, heartbeat) and returns: self