def test_load_changed_command(dvc, stage_data, lock_data): dvcfile = Dvcfile(dvc, PIPELINE_FILE) stage = StageLoader.load_stage(dvcfile, "stage-1", stage_data) assert not stage.cmd_changed assert stage.cmd == "command" lock_data["cmd"] = "different-command" stage = StageLoader.load_stage(dvcfile, "stage-1", stage_data, lock_data) assert stage.cmd_changed assert stage.cmd == "command"
def test_load_stage_wdir_and_path_correctly(dvc, stage_data, lock_data): stage_data["wdir"] = "dir" dvcfile = Dvcfile(dvc, PIPELINE_FILE) stage = StageLoader.load_stage(dvcfile, "stage-1", stage_data, lock_data) assert stage.wdir == os.path.abspath("dir") assert stage.path == os.path.abspath(PIPELINE_FILE)
def test_load_stage_with_metrics_and_plots(dvc, stage_data, lock_data, typ): stage_data[typ] = stage_data.pop("outs") dvcfile = Dvcfile(dvc, PIPELINE_FILE) stage = StageLoader.load_stage(dvcfile, "stage-1", stage_data, lock_data) assert stage.outs[0].def_path == "bar" assert stage.outs[0].hash_info == HashInfo("md5", "bar_checksum")
def test_load_stage_with_params(dvc, stage_data, lock_data): lock_data["params"] = {"params.yaml": {"lorem": "ipsum"}} stage_data["params"] = ["lorem"] dvcfile = Dvcfile(dvc, PIPELINE_FILE) stage = StageLoader.load_stage(dvcfile, "stage-1", stage_data, lock_data) params, deps = split_params_deps(stage) assert deps[0].def_path == "foo" and stage.outs[0].def_path == "bar" assert params[0].def_path == "params.yaml" assert params[0].hash_info == HashInfo("params", {"lorem": "ipsum"}) assert deps[0].hash_info == HashInfo("md5", "foo_checksum") assert stage.outs[0].hash_info == HashInfo("md5", "bar_checksum")
def test_load_stage(dvc, stage_data, lock_data): dvcfile = Dvcfile(dvc, PIPELINE_FILE) stage = StageLoader.load_stage(dvcfile, "stage-1", stage_data, lock_data) assert stage.wdir == os.path.abspath(os.curdir) assert stage.name == "stage-1" assert stage.cmd == "command" assert stage.path == os.path.abspath(PIPELINE_FILE) assert stage.deps[0].def_path == "foo" assert stage.deps[0].hash_info == HashInfo("md5", "foo_checksum") assert stage.outs[0].def_path == "bar" assert stage.outs[0].hash_info == HashInfo("md5", "bar_checksum")
def test_load_stage_no_lock(dvc, stage_data): dvcfile = Dvcfile(dvc, PIPELINE_FILE) stage = StageLoader.load_stage(dvcfile, "stage-1", stage_data) assert stage.deps[0].def_path == "foo" and stage.outs[0].def_path == "bar" assert not stage.deps[0].hash_info assert not stage.outs[0].hash_info
def test_load_stage_outs_with_flags(dvc, stage_data, lock_data): stage_data["outs"] = [{"foo": {"cache": False}}] dvcfile = Dvcfile(dvc, PIPELINE_FILE) stage = StageLoader.load_stage(dvcfile, "stage-1", stage_data, lock_data) assert stage.outs[0].use_cache is False
def test_load_stage_cmd_with_list(dvc, stage_data, lock_data): stage_data["cmd"] = ["cmd-0", "cmd-1"] dvcfile = Dvcfile(dvc, PIPELINE_FILE) stage = StageLoader.load_stage(dvcfile, "stage-1", stage_data, lock_data) assert stage.cmd == ["cmd-0", "cmd-1"]