class_docstr: Naive Git-stash based experiment queue.
  
  Maps queued experiments to (Git) stash reflog entries.
class_docstr_tok: ["Naive","Git-stash","based","experiment","queue",".","Maps","queued","experiments","to","(","Git",")","stash","reflog","entries","."]
docstr: Stash changes from the workspace as an experiment.
  
  Args:
      params: Dict mapping paths to `Hydra Override`_ patterns,
          provided via `exp run --set-param`.
      baseline_rev: Optional baseline rev for this experiment, defaults
          to the current SCM rev.
      branch: Optional experiment branch name. If specified, the
          experiment will be added to `branch` instead of creating
          a new branch.
      name: Optional experiment name. If specified this will be used as
          the human-readable name in the experiment branch ref. Has no
          effect of branch is specified.
  
  .. _Hydra Override:
      https://hydra.cc/docs/next/advanced/override_grammar/basic/
docstr_tok: ["Stash","changes","from","the","workspace","as","an","experiment",".","Args",":","params",":","Dict","mapping","paths","to","`","Hydra","Override","`","_","patterns",",","provided","via","`","exp","run","--","set-param","`",".","baseline_rev",":","Optional","baseline","rev","for","this","experiment",",","defaults","to","the","current","SCM","rev",".","branch",":","Optional","experiment","branch","name",".","If","specified",",","the","experiment","will","be","added","to","`","branch","`","instead","of","creating","a","new","branch",".","name",":","Optional","experiment","name",".","If","specified","this","will","be","used","as","the","human-readable","name","in","the","experiment","branch","ref",".","Has","no","effect","of","branch","is","specified",".","..","_Hydra","Override",":","https",":","\/\/hydra.cc\/docs\/next\/advanced\/override_grammar\/basic\/"]
code: def _stash_exp(
      self,
      *args,
      params: Optional[Dict[str, List[str]]] = None,
      baseline_rev: Optional[str] = None,
      branch: Optional[str] = None,
      name: Optional[str] = None,
      **kwargs,
  ) -> QueueEntry:
      """Stash changes from the workspace as an experiment.
  
      Args:
          params: Dict mapping paths to `Hydra Override`_ patterns,
              provided via `exp run --set-param`.
          baseline_rev: Optional baseline rev for this experiment, defaults
              to the current SCM rev.
          branch: Optional experiment branch name. If specified, the
              experiment will be added to `branch` instead of creating
              a new branch.
          name: Optional experiment name. If specified this will be used as
              the human-readable name in the experiment branch ref. Has no
              effect of branch is specified.
  
      .. _Hydra Override:
          https://hydra.cc/docs/next/advanced/override_grammar/basic/
      """
      with self.scm.stash_workspace(reinstate_index=True) as workspace:
          with self.scm.detach_head(client="dvc") as orig_head:
              stash_head = orig_head
              if baseline_rev is None:
                  baseline_rev = orig_head
  
              try:
                  if workspace:
                      self.stash.apply(workspace)
  
                  # update experiment params from command line
                  if params:
                      self._update_params(params)
  
                  # DVC commit data deps to preserve state across workspace
                  # & tempdir runs
                  self._stash_commit_deps(*args, **kwargs)
  
                  # save additional repro command line arguments
                  run_env = {
                      DVC_EXP_BASELINE_REV: baseline_rev,
                  }
                  if not name:
                      name = get_random_exp_name(self.scm, baseline_rev)
                  run_env[DVC_EXP_NAME] = name
                  # Override DVC_ROOT env var to point to the parent DVC repo
                  # root (and not an executor tempdir root)
                  run_env[DVC_ROOT] = self.repo.root_dir
  
                  # save studio config to read later by dvc and dvclive
                  studio_config = get_studio_config(
                      dvc_studio_config=self.repo.config.get("studio")
                  )
                  run_env = {**config_to_env(studio_config), **run_env}
                  self._pack_args(*args, run_env=run_env, **kwargs)
                  # save experiment as a stash commit
                  msg = self._stash_msg(
                      stash_head,
                      baseline_rev=baseline_rev,
                      branch=branch,
                      name=name,
                  )
                  stash_rev = self.stash.push(message=msg)
                  assert stash_rev
                  logger.debug(
                      (
                          "Stashed experiment '%s' with baseline '%s' "
                          "for future execution."
                      ),
                      stash_rev[:7],
                      baseline_rev[:7],
                  )
              finally:
                  # Revert any of our changes before prior unstashing
                  self.scm.reset(hard=True)
  
      return QueueEntry(
          self.repo.root_dir,
          self.scm.root_dir,
          self.ref,
          stash_rev,
          baseline_rev,
          branch,
          name,
          stash_head,
      )
  
imports: import os
  from abc import ABC, abstractmethod
  from dataclasses import asdict, dataclass
  from typing import TYPE_CHECKING, Any, Collection, Dict, Generator, Iterable, List, Mapping, NamedTuple, Optional, Type, Union
  from dvc_studio_client.post_live_metrics import get_studio_config
  from funcy import retry
  from dvc.dependency import ParamsDependency
  from dvc.env import DVC_EXP_BASELINE_REV, DVC_EXP_NAME, DVC_ROOT
  from dvc.lock import LockError
  from dvc.log import logger
  from dvc.repo.experiments.exceptions import ExperimentExistsError
  from dvc.repo.experiments.executor.base import BaseExecutor
  from dvc.repo.experiments.executor.local import WorkspaceExecutor
  from dvc.repo.experiments.refs import ExpRefInfo
  from dvc.repo.experiments.stash import ExpStash, ExpStashEntry
  from dvc.repo.experiments.utils import EXEC_PID_DIR, EXEC_TMP_DIR, get_exp_rwlock, get_random_exp_name
  from dvc.utils.objects import cached_property
  from dvc.utils.studio import config_to_env
  from .utils import get_remote_executor_refs
label_desc: Use image node_id 22 for calling the BaseStashQueue obj's underlying member method code with example usage: obj._stash_exp() and returns: QueueEntry