mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
fix(exceptions): add parent ctr init in InvalidArgumentError
This commit is contained in:
committed by
David de la Iglesia Castro
parent
41df96fcdb
commit
a9d0ac2ba9
@@ -17,6 +17,10 @@ class DvcException(Exception):
|
|||||||
class InvalidArgumentError(ValueError, DvcException):
|
class InvalidArgumentError(ValueError, DvcException):
|
||||||
"""Thrown if arguments are invalid."""
|
"""Thrown if arguments are invalid."""
|
||||||
|
|
||||||
|
def __init__(self, msg, *args):
|
||||||
|
self.msg = msg
|
||||||
|
super().__init__(msg, *args)
|
||||||
|
|
||||||
|
|
||||||
class OutputDuplicationError(DvcException):
|
class OutputDuplicationError(DvcException):
|
||||||
"""Thrown if a file/directory is specified as an output in more than one
|
"""Thrown if a file/directory is specified as an output in more than one
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -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):
|
def test_artifacts_add_subdir(tmp_dir, dvc):
|
||||||
subdir = tmp_dir / "subdir"
|
subdir = tmp_dir / "subdir"
|
||||||
subdir.mkdir()
|
subdir.mkdir()
|
||||||
|
|||||||
Reference in New Issue
Block a user