def dump(self, stage, **kwargs): stage_data = serialize.to_lockfile(stage) with modify_yaml(self.path, tree=self.repo.tree) as data: if not data: logger.info("Generating lock file '%s'", self.relpath) modified = data.get(stage.name, {}) != stage_data.get( stage.name, {}) if modified: logger.info("Updating lock file '%s'", self.relpath) data.update(stage_data) if modified: self.repo.scm.track_file(self.relpath)
def test_to_lockfile(dvc): stage = create_stage(PipelineStage, dvc, deps=["input"], **kwargs) stage.deps[0].info = {"md5": "md-five"} entry = to_lockfile(stage) assert len(entry) == 1 _Schema(LOCKFILE_SCHEMA)(entry) assert entry == { "something": OrderedDict([ ("cmd", "command"), ("deps", [{ "path": "input", "md5": "md-five" }]), ]) }
def dump(self, stage, **kwargs): stage_data = serialize.to_lockfile(stage) if not self.exists(): modified = True logger.info("Generating lock file '%s'", self.relpath) data = stage_data open(self.path, "w+").close() else: with self.repo.tree.open(self.path, "r") as fd: data = parse_yaml_for_update(fd.read(), self.path) modified = data.get(stage.name, {}) != stage_data.get( stage.name, {}) if modified: logger.info("Updating lock file '%s'", self.relpath) data.update(stage_data) dump_yaml(self.path, data) if modified: self.repo.scm.track_file(self.relpath)
def exp_hash(stages): exp_data = {} for stage in stages: exp_data.update(to_lockfile(stage)) return dict_sha256(exp_data)
def hash_exp(stages): exp_data = {} for stage in stages: if isinstance(stage, PipelineStage): exp_data.update(to_lockfile(stage)) return dict_sha256(exp_data)