| 170 | |
| 171 | |
| 172 | class SingleStageFile(FileMixin): |
| 173 | from dvc.schema import COMPILED_SINGLE_STAGE_SCHEMA as SCHEMA |
| 174 | from dvc.stage.loader import SingleStageLoader as LOADER # noqa: N814 |
| 175 | |
| 176 | datasets: ClassVar[list[dict[str, Any]]] = [] |
| 177 | datasets_lock: ClassVar[list[dict[str, Any]]] = [] |
| 178 | metrics: ClassVar[list[str]] = [] |
| 179 | plots: ClassVar[Any] = {} |
| 180 | params: ClassVar[list[str]] = [] |
| 181 | artifacts: ClassVar[dict[str, Optional[dict[str, Any]]]] = {} |
| 182 | |
| 183 | @property |
| 184 | def stage(self) -> "Stage": |
| 185 | data, raw = self._load() |
| 186 | return self.LOADER.load_stage(self, data, raw) |
| 187 | |
| 188 | @property |
| 189 | def stages(self) -> LOADER: |
| 190 | data, raw = self._load() |
| 191 | return self.LOADER(self, data, raw) |
| 192 | |
| 193 | def dump(self, stage, **kwargs) -> None: |
| 194 | """Dumps given stage appropriately in the dvcfile.""" |
| 195 | from dvc.stage import PipelineStage |
| 196 | |
| 197 | assert not isinstance(stage, PipelineStage) |
| 198 | if self.verify: |
| 199 | check_dvcfile_path(self.repo, self.path) |
| 200 | logger.debug("Saving information to '%s'.", relpath(self.path)) |
| 201 | dump_yaml(self.path, serialize.to_single_stage_file(stage, **kwargs)) |
| 202 | self.repo.scm_context.track_file(self.relpath) |
| 203 | |
| 204 | def dump_stages(self, stages, **kwargs) -> None: |
| 205 | if not stages: |
| 206 | return None |
| 207 | |
| 208 | assert len(stages) == 1, "SingleStageFile can only dump one stage." |
| 209 | return self.dump(stages[0], **kwargs) |
| 210 | |
| 211 | def remove_stage(self, stage): # noqa: ARG002 |
| 212 | self.remove() |
| 213 | |
| 214 | def merge(self, ancestor, other, allowed=None): |
| 215 | assert isinstance(ancestor, SingleStageFile) |
| 216 | assert isinstance(other, SingleStageFile) |
| 217 | |
| 218 | stage = self.stage |
| 219 | stage.merge(ancestor.stage, other.stage, allowed=allowed) |
| 220 | self.dump(stage) |
| 221 | |
| 222 | |
| 223 | class ProjectFile(FileMixin): |
no outgoing calls