| 289 | raise ParametrizedDumpError(f"cannot {action} a parametrized {stage}") |
| 290 | |
| 291 | def _dump_pipeline_file(self, stages): |
| 292 | stages = stages if isinstance(stages, list) else [stages] |
| 293 | if not stages: |
| 294 | return |
| 295 | |
| 296 | for stage in stages: |
| 297 | self._check_if_parametrized(stage) |
| 298 | |
| 299 | with modify_yaml(self.path, fs=self.repo.fs) as data: |
| 300 | if not data: |
| 301 | logger.info("Creating '%s'", self.relpath) |
| 302 | |
| 303 | data["stages"] = data.get("stages", {}) |
| 304 | for stage in stages: |
| 305 | stage_data = serialize.to_pipeline_file(stage) |
| 306 | existing_entry = stage.name in data["stages"] |
| 307 | action = "Modifying" if existing_entry else "Adding" |
| 308 | logger.info("%s stage '%s' in '%s'", action, stage.name, self.relpath) |
| 309 | if existing_entry: |
| 310 | orig_stage_data = data["stages"][stage.name] |
| 311 | apply_diff(stage_data[stage.name], orig_stage_data) |
| 312 | else: |
| 313 | data["stages"].update(stage_data) |
| 314 | |
| 315 | self.repo.scm_context.track_file(self.relpath) |
| 316 | |
| 317 | @property |
| 318 | def stage(self): |