mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
@@ -17,6 +17,8 @@ from typing import (
|
|||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from dvc_studio_client.env import STUDIO_REPO_URL
|
||||||
|
from dvc_studio_client.post_live_metrics import get_studio_repo_url
|
||||||
from funcy import retry
|
from funcy import retry
|
||||||
|
|
||||||
from dvc.dependency import ParamsDependency
|
from dvc.dependency import ParamsDependency
|
||||||
@@ -415,6 +417,10 @@ class BaseStashQueue(ABC):
|
|||||||
run_env[DVC_EXP_NAME] = name
|
run_env[DVC_EXP_NAME] = name
|
||||||
if resume_rev:
|
if resume_rev:
|
||||||
run_env[DVCLIVE_RESUME] = "1"
|
run_env[DVCLIVE_RESUME] = "1"
|
||||||
|
studio_repo_url = get_studio_repo_url()
|
||||||
|
if studio_repo_url is not None:
|
||||||
|
run_env[STUDIO_REPO_URL] = studio_repo_url
|
||||||
|
|
||||||
self._pack_args(*args, run_env=run_env, **kwargs)
|
self._pack_args(*args, run_env=run_env, **kwargs)
|
||||||
|
|
||||||
# save experiment as a stash commit
|
# save experiment as a stash commit
|
||||||
|
|||||||
@@ -597,17 +597,21 @@ def test_experiments_workspace_not_log_exception(caplog, dvc, scm):
|
|||||||
assert not caplog.text
|
assert not caplog.text
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.vscode
|
||||||
def test_run_env(tmp_dir, dvc, scm, mocker):
|
def test_run_env(tmp_dir, dvc, scm, mocker):
|
||||||
dump_run_env = dedent(
|
dump_run_env = dedent(
|
||||||
"""\
|
"""\
|
||||||
import os
|
import os
|
||||||
|
from dvc_studio_client.env import STUDIO_REPO_URL
|
||||||
from dvc.env import DVC_EXP_BASELINE_REV, DVC_EXP_NAME
|
from dvc.env import DVC_EXP_BASELINE_REV, DVC_EXP_NAME
|
||||||
with open("DVC_EXP_BASELINE_REV", "w") as f:
|
for v in (DVC_EXP_BASELINE_REV, DVC_EXP_NAME, STUDIO_REPO_URL):
|
||||||
f.write(os.environ.get(DVC_EXP_BASELINE_REV, ""))
|
with open(v, "w") as f:
|
||||||
with open("DVC_EXP_NAME", "w") as f:
|
f.write(os.environ.get(v, ""))
|
||||||
f.write(os.environ.get(DVC_EXP_NAME, ""))
|
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
mocker.patch(
|
||||||
|
"dvc.repo.experiments.queue.base.get_studio_repo_url", return_value="REPO_URL"
|
||||||
|
)
|
||||||
(tmp_dir / "dump_run_env.py").write_text(dump_run_env)
|
(tmp_dir / "dump_run_env.py").write_text(dump_run_env)
|
||||||
baseline = scm.get_rev()
|
baseline = scm.get_rev()
|
||||||
dvc.stage.add(
|
dvc.stage.add(
|
||||||
@@ -617,10 +621,12 @@ def test_run_env(tmp_dir, dvc, scm, mocker):
|
|||||||
dvc.experiments.run()
|
dvc.experiments.run()
|
||||||
assert (tmp_dir / "DVC_EXP_BASELINE_REV").read_text().strip() == baseline
|
assert (tmp_dir / "DVC_EXP_BASELINE_REV").read_text().strip() == baseline
|
||||||
assert (tmp_dir / "DVC_EXP_NAME").read_text().strip() != ""
|
assert (tmp_dir / "DVC_EXP_NAME").read_text().strip() != ""
|
||||||
|
assert (tmp_dir / "STUDIO_REPO_URL").read_text().strip() == "REPO_URL"
|
||||||
|
|
||||||
dvc.experiments.run(name="foo")
|
dvc.experiments.run(name="foo")
|
||||||
assert (tmp_dir / "DVC_EXP_BASELINE_REV").read_text().strip() == baseline
|
assert (tmp_dir / "DVC_EXP_BASELINE_REV").read_text().strip() == baseline
|
||||||
assert (tmp_dir / "DVC_EXP_NAME").read_text().strip() == "foo"
|
assert (tmp_dir / "DVC_EXP_NAME").read_text().strip() == "foo"
|
||||||
|
assert (tmp_dir / "STUDIO_REPO_URL").read_text().strip() == "REPO_URL"
|
||||||
|
|
||||||
|
|
||||||
def test_experiment_unchanged(tmp_dir, scm, dvc, exp_stage):
|
def test_experiment_unchanged(tmp_dir, scm, dvc, exp_stage):
|
||||||
|
|||||||
Reference in New Issue
Block a user