From 1b3c771df524077606bd8e006d0a9a022c1800d8 Mon Sep 17 00:00:00 2001 From: "Mr. Outis" Date: Wed, 18 Dec 2019 22:42:42 -0600 Subject: [PATCH] summon: artifacs.yaml -> dvcsummon.yaml; artifact -> object --- dvc/api.py | 20 +++++++++----------- tests/func/test_api.py | 6 +++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/dvc/api.py b/dvc/api.py index 492373f95..bd9488409 100644 --- a/dvc/api.py +++ b/dvc/api.py @@ -75,22 +75,20 @@ def _make_repo(repo_url, rev=None): def summon(name, params=None, repo=None, rev=None): - # 1. Read artifacts.yaml + # 1. Read dvcsummon.yaml # 2. Pull dependencies # 3. Get the call and parameters # 4. Invoke the call with the given parameters # 5. Return the result with _make_repo(repo, rev=rev) as _repo: - artifacts_path = os.path.join(_repo.root_dir, "artifacts.yaml") + dvcsummon_path = os.path.join(_repo.root_dir, "dvcsummon.yaml") - with open(artifacts_path, "r") as fobj: - artifacts = ruamel.yaml.safe_load(fobj.read()).get("artifacts") - artifact = next(x for x in artifacts if x.get("name") == name) + with open(dvcsummon_path, "r") as fobj: + objects = ruamel.yaml.safe_load(fobj.read()).get("objects") + obj = next(x for x in objects if x.get("name") == name) - outs = [ - _repo.find_out_by_relpath(dep) for dep in artifact.get("deps", ()) - ] + outs = [_repo.find_out_by_relpath(dep) for dep in obj.get("deps", ())] with _repo.state: for out in outs: @@ -101,12 +99,12 @@ def summon(name, params=None, repo=None, rev=None): os.chdir(_repo.root_dir) - artifact_path = os.path.join(_repo.root_dir, artifact.get("file")) + artifact_path = os.path.join(_repo.root_dir, obj.get("file")) spec = importlib.util.spec_from_file_location(name, artifact_path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) - method = getattr(module, artifact.get("method")) - _params = artifact.get("params") + method = getattr(module, obj.get("method")) + _params = obj.get("params") if params: _params.update(params) diff --git a/tests/func/test_api.py b/tests/func/test_api.py index 2dc7a1ad1..98a7040ee 100644 --- a/tests/func/test_api.py +++ b/tests/func/test_api.py @@ -131,9 +131,9 @@ def test_open_not_cached(dvc): def test_summon(tmp_dir, erepo_dir, dvc, monkeypatch): - artifacts_yaml = ruamel.yaml.dump( + dvcsummon_yaml = ruamel.yaml.dump( { - "artifacts": [ + "objects": [ { "name": "sum", "description": "Add to ", @@ -151,7 +151,7 @@ def test_summon(tmp_dir, erepo_dir, dvc, monkeypatch): m.chdir(fspath(erepo_dir)) erepo_dir.dvc_gen("number", "100", commit="Add number.dvc") - erepo_dir.scm_gen("artifacts.yaml", artifacts_yaml) + erepo_dir.scm_gen("dvcsummon.yaml", dvcsummon_yaml) erepo_dir.scm_gen( "calculator.py", "def add_to_num(x): return x + int(open('number').read())",