Skip to content

Commit

Permalink
Revert "Restyle #3393 introduce hyper parameters and config (#3516)"
Browse files Browse the repository at this point in the history
This reverts commit 65d22c7.
  • Loading branch information
efiop authored Mar 19, 2020
1 parent 65d22c7 commit 8fa3cc9
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 167 deletions.
8 changes: 0 additions & 8 deletions dvc/command/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def run(self):
metrics=self.args.metrics,
metrics_no_cache=self.args.metrics_no_cache,
deps=self.args.deps,
params=self.args.params,
fname=self.args.file,
cwd=self.args.cwd,
wdir=self.args.wdir,
Expand Down Expand Up @@ -112,13 +111,6 @@ def add_parser(subparsers, parent_parser):
help="Declare output file or directory "
"(do not put into DVC cache).",
)
run_parser.add_argument(
"-p",
"--params",
action="append",
default=[],
help="Declare parameter to use as additional dependency.",
)
run_parser.add_argument(
"-m",
"--metrics",
Expand Down
27 changes: 10 additions & 17 deletions dvc/dependency/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from dvc.dependency.local import DependencyLOCAL
from dvc.dependency.s3 import DependencyS3
from dvc.dependency.ssh import DependencySSH
from dvc.dependency.param import DependencyPARAMS
from dvc.output.base import OutputBase
from dvc.remote import Remote
from dvc.scheme import Schemes
Expand Down Expand Up @@ -43,43 +42,37 @@
SCHEMA = output.SCHEMA.copy()
del SCHEMA[OutputBase.PARAM_CACHE]
del SCHEMA[OutputBase.PARAM_METRIC]
SCHEMA.update(DependencyREPO.REPO_SCHEMA)
SCHEMA.update(DependencyPARAMS.PARAM_SCHEMA)
SCHEMA[DependencyREPO.PARAM_REPO] = DependencyREPO.REPO_SCHEMA


def _get_by_path(stage, path, info):
parsed = urlparse(path)
def _get(stage, p, info):
parsed = urlparse(p)

if parsed.scheme == "remote":
remote = Remote(stage.repo, name=parsed.netloc)
return DEP_MAP[remote.scheme](stage, path, info, remote=remote)
return DEP_MAP[remote.scheme](stage, p, info, remote=remote)

if info and info.get(DependencyREPO.PARAM_REPO):
repo = info.pop(DependencyREPO.PARAM_REPO)
return DependencyREPO(repo, stage, path, info)
return DependencyREPO(repo, stage, p, info)

for d in DEPS:
if d.supported(path):
return d(stage, path, info)
return DependencyLOCAL(stage, path, info)
if d.supported(p):
return d(stage, p, info)
return DependencyLOCAL(stage, p, info)


def loadd_from(stage, d_list):
ret = []
for d in d_list:
p = d.pop(OutputBase.PARAM_PATH)
ret.append(_get_by_path(stage, p, d))
ret.append(_get(stage, p, d))
return ret


def loads_from(stage, s_list, erepo=None):
ret = []
for s in s_list:
info = {DependencyREPO.PARAM_REPO: erepo} if erepo else {}
dep_obj = _get_by_path(stage, s, info)
ret.append(dep_obj)
ret.append(_get(stage, s, info))
return ret


def loads_params(stage, s_list): # TODO: Make support for `eropo=` as well ?
return DependencyPARAMS.from_list(stage, s_list)
107 changes: 0 additions & 107 deletions dvc/dependency/param.py

This file was deleted.

8 changes: 3 additions & 5 deletions dvc/dependency/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ class DependencyREPO(DependencyLOCAL):
PARAM_REV_LOCK = "rev_lock"

REPO_SCHEMA = {
PARAM_REPO: {
Required(PARAM_URL): str,
PARAM_REV: str,
PARAM_REV_LOCK: str,
}
Required(PARAM_URL): str,
PARAM_REV: str,
PARAM_REV_LOCK: str,
}

def __init__(self, def_repo, stage, *args, **kwargs):
Expand Down
4 changes: 1 addition & 3 deletions dvc/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,9 @@ def create(repo, accompany_outs=False, **kwargs):
)

Stage._fill_stage_outputs(stage, **kwargs)
deps = dependency.loads_from(
stage.deps = dependency.loads_from(
stage, kwargs.get("deps", []), erepo=kwargs.get("erepo", None)
)
params = dependency.loads_params(stage, kwargs.get("params", []))
stage.deps = deps + params

stage._check_circular_dependency()
stage._check_duplicated_arguments()
Expand Down
6 changes: 0 additions & 6 deletions tests/basic_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ class TestDirFixture(object):
# in tests, we replace foo with bar, so we need to make sure that when we
# modify a file in our tests, its content length changes.
BAR_CONTENTS = BAR + "r"
PARAMSDEFAULT = "params.json"
PARAMSDEFAULT_CONTENTS = '{"p_one": "1", "p_two": "1"}'
PARAMS = "par.json"
PARAMS_CONTENTS = '{"p_three": "3"}'
CODE = "code.py"
CODE_CONTENTS = (
"import sys\nimport shutil\n"
Expand Down Expand Up @@ -91,8 +87,6 @@ def setUp(self):
self._pushd(self._root_dir)
self.create(self.FOO, self.FOO_CONTENTS)
self.create(self.BAR, self.BAR_CONTENTS)
self.create(self.PARAMSDEFAULT, self.PARAMSDEFAULT_CONTENTS)
self.create(self.PARAMS, self.PARAMS_CONTENTS)
self.create(self.CODE, self.CODE_CONTENTS)
os.mkdir(self.DATA_DIR)
os.mkdir(self.DATA_SUB_DIR)
Expand Down
4 changes: 1 addition & 3 deletions tests/func/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class TestRun(TestDvc):
def test(self):
cmd = "python {} {} {}".format(self.CODE, self.FOO, "out")
deps = [self.FOO, self.CODE]
params = ["p_one", "p_two", "par.json:p_three"]
outs = [os.path.join(self.dvc.root_dir, "out")]
outs_no_cache = []
fname = "out.dvc"
Expand All @@ -46,7 +45,6 @@ def test(self):
cmd=cmd,
deps=deps,
outs=outs,
params=params,
outs_no_cache=outs_no_cache,
fname=fname,
cwd=cwd,
Expand All @@ -55,7 +53,7 @@ def test(self):
self.assertTrue(filecmp.cmp(self.FOO, "out", shallow=False))
self.assertTrue(os.path.isfile(stage.path))
self.assertEqual(stage.cmd, cmd)
self.assertEqual(len(stage.deps), len(deps) + 2)
self.assertEqual(len(stage.deps), len(deps))
self.assertEqual(len(stage.outs), len(outs + outs_no_cache))
self.assertEqual(stage.outs[0].fspath, outs[0])
self.assertEqual(stage.outs[0].checksum, file_md5(self.FOO)[0])
Expand Down
18 changes: 0 additions & 18 deletions tests/unit/dependency/test_params.py

This file was deleted.

0 comments on commit 8fa3cc9

Please sign in to comment.