Skip to content

Commit 87d79a1

Browse files
authored
log_artifact: Use name validation from GTO. (#715)
* log_artifact: Use name validation from GTO. The function we were using from `dvc.repo.artifacts` was dropped in iterative/dvc#9770 deps: bump "dvc>3.22.1" * deps: Add `gto`.
1 parent ef91442 commit 87d79a1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ classifiers = [
3131
]
3232
dynamic = ["version"]
3333
dependencies = [
34-
"dvc>=3.22.0",
34+
"dvc>=3.22.1",
3535
"dvc-render>=0.6.0,<1.0",
3636
"dvc-studio-client>=0.15.0,<1",
3737
"funcy",
38+
"gto",
3839
"ruamel.yaml",
3940
"scmrepo",
4041
]

src/dvclive/live.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ def log_artifact(
461461
raise InvalidDataTypeError(path, type(path))
462462

463463
if self._dvc_repo is not None:
464-
from dvc.repo.artifacts import name_is_compatible
464+
from gto.constants import assert_name_is_valid
465+
from gto.exceptions import ValidationError
465466

466467
if copy:
467468
path = clean_and_copy_into(path, self.artifacts_dir)
@@ -471,14 +472,15 @@ def log_artifact(
471472

472473
if any((type, name, desc, labels, meta)):
473474
name = name or Path(path).stem
474-
if name_is_compatible(name):
475+
try:
476+
assert_name_is_valid(name)
475477
self._artifacts[name] = {
476478
k: v
477479
for k, v in locals().items()
478480
if k in ("path", "type", "desc", "labels", "meta")
479481
and v is not None
480482
}
481-
else:
483+
except ValidationError:
482484
logger.warning(
483485
"Can't use '%s' as artifact name (ID)."
484486
" It will not be included in the `artifacts` section.",

0 commit comments

Comments
 (0)