Skip to content

Commit

Permalink
fix(exceptions): add parent ctr init in InvalidArgumentError
Browse files Browse the repository at this point in the history
  • Loading branch information
shcheklein authored and daavoo committed Jul 21, 2023
1 parent 41df96f commit a9d0ac2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dvc/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def __init__(self, msg, *args):
class InvalidArgumentError(ValueError, DvcException):
"""Thrown if arguments are invalid."""

def __init__(self, msg, *args):
self.msg = msg
super().__init__(msg, *args)


class OutputDuplicationError(DvcException):
"""Thrown if a file/directory is specified as an output in more than one
Expand Down
18 changes: 18 additions & 0 deletions tests/func/artifacts/test_artifacts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os
from copy import deepcopy

import pytest

Expand Down Expand Up @@ -39,6 +41,22 @@ def test_artifacts_read_subdir(tmp_dir, dvc):
}


def test_artifacts_read_bad_name(tmp_dir, dvc, caplog):
bad_name_dvcyaml = deepcopy(dvcyaml)
bad_name_dvcyaml["artifacts"]["bad_name"] = {"type": "model", "path": "bad.pkl"}

(tmp_dir / "dvc.yaml").dump(bad_name_dvcyaml)

artifacts = {
name: Artifact(**values)
for name, values in bad_name_dvcyaml["artifacts"].items()
}

with caplog.at_level(logging.WARNING):
assert tmp_dir.dvc.artifacts.read() == {"dvc.yaml": artifacts}
assert "Can't use 'bad_name' as artifact name (ID)" in caplog.text


def test_artifacts_add_subdir(tmp_dir, dvc):
subdir = tmp_dir / "subdir"
subdir.mkdir()
Expand Down

0 comments on commit a9d0ac2

Please sign in to comment.