Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DVC_ROOT env var into queued experiment runs #9879

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused by this already existing.
Either I am missing something or this is dead code:

dvc/dvc/stage/__init__.py

Lines 288 to 295 in ef260ea

def env(self) -> Env:
from dvc.env import DVC_ROOT
env: Env = {}
if self.repo:
env.update({DVC_ROOT: self.repo.root_dir})
return env

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like dead code from checkpoints: #5257

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try and remove it in a separate PR.

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