Skip to content

Commit

Permalink
log_artifact: Use name validation from GTO. (#715)
Browse files Browse the repository at this point in the history
* 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`.
  • Loading branch information
daavoo committed Sep 26, 2023
1 parent ef91442 commit 87d79a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ classifiers = [
]
dynamic = ["version"]
dependencies = [
"dvc>=3.22.0",
"dvc>=3.22.1",
"dvc-render>=0.6.0,<1.0",
"dvc-studio-client>=0.15.0,<1",
"funcy",
"gto",
"ruamel.yaml",
"scmrepo",
]
Expand Down
8 changes: 5 additions & 3 deletions src/dvclive/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ def log_artifact(
raise InvalidDataTypeError(path, type(path))

if self._dvc_repo is not None:
from dvc.repo.artifacts import name_is_compatible
from gto.constants import assert_name_is_valid
from gto.exceptions import ValidationError

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

if any((type, name, desc, labels, meta)):
name = name or Path(path).stem
if name_is_compatible(name):
try:
assert_name_is_valid(name)
self._artifacts[name] = {
k: v
for k, v in locals().items()
if k in ("path", "type", "desc", "labels", "meta")
and v is not None
}
else:
except ValidationError:
logger.warning(
"Can't use '%s' as artifact name (ID)."
" It will not be included in the `artifacts` section.",
Expand Down

0 comments on commit 87d79a1

Please sign in to comment.