mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
exp rename: verify exp name follows ref format
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
e5dd2bb2cc
commit
c2f8115c9a
@@ -5,7 +5,7 @@ from dvc.repo.experiments.exceptions import (
|
||||
ExperimentExistsError,
|
||||
UnresolvedExpNamesError,
|
||||
)
|
||||
from dvc.repo.experiments.utils import resolve_name
|
||||
from dvc.repo.experiments.utils import check_ref_format, resolve_name
|
||||
from dvc.scm import Git
|
||||
|
||||
from .refs import ExpRefInfo
|
||||
@@ -43,6 +43,7 @@ def rename(
|
||||
if repo.scm.get_ref(str(new_ref)) and not force:
|
||||
raise ExperimentExistsError(new_name)
|
||||
|
||||
check_ref_format(repo.scm, new_ref)
|
||||
_rename_exp(scm=repo.scm, ref_info=result, new_name=new_name)
|
||||
renamed.append(name)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from dvc.exceptions import InvalidArgumentError
|
||||
from dvc.repo.experiments.exceptions import (
|
||||
ExperimentExistsError,
|
||||
UnresolvedExpNamesError,
|
||||
@@ -31,3 +32,13 @@ def test_existing_name(dvc, exp_stage):
|
||||
dvc.experiments.rename("second-name", "first-name")
|
||||
|
||||
dvc.experiments.rename("second-name", "first-name", force=True)
|
||||
|
||||
|
||||
def test_invalid_name(dvc, exp_stage):
|
||||
dvc.experiments.run(exp_stage.addressing, name="test-name", params=["foo=1"])
|
||||
|
||||
with pytest.raises(InvalidArgumentError):
|
||||
dvc.experiments.rename("invalid*name", "test-name")
|
||||
|
||||
with pytest.raises(InvalidArgumentError):
|
||||
dvc.experiments.rename("invalid/name", "test-name")
|
||||
|
||||
Reference in New Issue
Block a user