Skip to content

Commit

Permalink
Add DVC_ROOT env var into queued experiment runs (iterative#9879)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon authored Aug 28, 2023
1 parent ef260ea commit 5b69a16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dvc/repo/experiments/queue/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from funcy import retry

from dvc.dependency import ParamsDependency
from dvc.env import DVC_EXP_BASELINE_REV, DVC_EXP_NAME
from dvc.env import DVC_EXP_BASELINE_REV, DVC_EXP_NAME, DVC_ROOT
from dvc.lock import LockError
from dvc.repo.experiments.exceptions import ExperimentExistsError
from dvc.repo.experiments.executor.base import BaseExecutor
Expand Down Expand Up @@ -348,6 +348,7 @@ def _stash_exp( # noqa: C901
if not name:
name = get_random_exp_name(self.scm, baseline_rev)
run_env[DVC_EXP_NAME] = name
run_env[DVC_ROOT] = self.repo.root_dir

# save studio config to read later by dvc and dvclive
studio_config = get_studio_config(
Expand Down
4 changes: 4 additions & 0 deletions tests/func/experiments/test_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from dvc.env import (
DVC_EXP_BASELINE_REV,
DVC_EXP_NAME,
DVC_ROOT,
DVC_STUDIO_OFFLINE,
DVC_STUDIO_REPO_URL,
DVC_STUDIO_TOKEN,
Expand Down Expand Up @@ -620,6 +621,7 @@ def test_run_env(tmp_dir, dvc, scm, mocker):
from dvc.env import (
DVC_EXP_BASELINE_REV,
DVC_EXP_NAME,
DVC_ROOT,
DVC_STUDIO_OFFLINE,
DVC_STUDIO_REPO_URL,
DVC_STUDIO_TOKEN,
Expand All @@ -628,6 +630,7 @@ def test_run_env(tmp_dir, dvc, scm, mocker):
for v in (
DVC_EXP_BASELINE_REV,
DVC_EXP_NAME,
DVC_ROOT,
DVC_STUDIO_OFFLINE,
DVC_STUDIO_REPO_URL,
DVC_STUDIO_TOKEN,
Expand Down Expand Up @@ -655,6 +658,7 @@ def test_run_env(tmp_dir, dvc, scm, mocker):
dvc.experiments.run()
assert (tmp_dir / DVC_EXP_BASELINE_REV).read_text().strip() == baseline
assert (tmp_dir / DVC_EXP_NAME).read_text().strip()
assert (tmp_dir / DVC_ROOT).read_text().strip() == dvc.root_dir
assert (tmp_dir / DVC_STUDIO_TOKEN).read_text().strip() == "TOKEN"
assert (tmp_dir / DVC_STUDIO_REPO_URL).read_text().strip() == "REPO_URL"
assert (tmp_dir / DVC_STUDIO_URL).read_text().strip() == "BASE_URL"
Expand Down

0 comments on commit 5b69a16

Please sign in to comment.