From d0344ce975fe97732b859605c873ec4c68924b86 Mon Sep 17 00:00:00 2001 From: "Mr. Outis" Date: Wed, 18 Dec 2019 17:00:39 -0600 Subject: [PATCH] summon: grimoire/spells -> artifacts --- dvc/api.py | 20 ++++++++++---------- tests/func/test_api.py | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dvc/api.py b/dvc/api.py index 390ea029d..957fdf9a0 100644 --- a/dvc/api.py +++ b/dvc/api.py @@ -75,22 +75,22 @@ def _make_repo(repo_url, rev=None): def summon(name, repo=None, rev=None): - # 1. Read grimoire.yaml + # 1. Read artifacts.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: - grimoire_path = os.path.join(_repo.root_dir, "grimoire.yaml") + artifacts_path = os.path.join(_repo.root_dir, "artifacts.yaml") - with open(grimoire_path, "r") as fobj: - spells = ruamel.yaml.safe_load(fobj.read()).get("spells") - spell = next(x for x in spells if x.get("name") == name) + 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) outs = [ _repo.find_outs_by_path(os.path.join(_repo.root_dir, dep))[0] - for dep in spell.get("deps") + for dep in artifact.get("deps") ] with _repo.state: @@ -102,12 +102,12 @@ def summon(name, repo=None, rev=None): os.chdir(_repo.root_dir) - spell_path = os.path.join(_repo.root_dir, spell.get("file")) - spec = importlib.util.spec_from_file_location(name, spell_path) + artifact_path = os.path.join(_repo.root_dir, artifact.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, spell.get("method")) - result = method(**spell.get("params")) + method = getattr(module, artifact.get("method")) + result = method(**artifact.get("params")) os.chdir(previous_dir) diff --git a/tests/func/test_api.py b/tests/func/test_api.py index f640dfd21..e424db02c 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): - grimoire_yaml = ruamel.yaml.dump( + artifacts_yaml = ruamel.yaml.dump( { - "spells": [ + "artifacts": [ { "name": "sum", "description": "Add to ", @@ -152,12 +152,12 @@ def test_summon(tmp_dir, erepo_dir, dvc, monkeypatch): erepo_dir.dvc_gen("number", "100") - erepo_dir.scm_gen("grimoire.yaml", grimoire_yaml) + erepo_dir.scm_gen("artifacts.yaml", artifacts_yaml) erepo_dir.scm_gen( "calculator.py", "def add_to_num(x): return x + int(open('number').read())", ) - erepo_dir.scm.add(["number.dvc", "calculator.py", "grimoire.yaml"]) + erepo_dir.scm.add(["number.dvc", "calculator.py", "artifacts.yaml"]) erepo_dir.scm.commit("Add files") repo_url = "file://{}".format(erepo_dir)