diff --git a/dvc/repo/experiments/executor/base.py b/dvc/repo/experiments/executor/base.py index e184f068d..5d364a0c6 100644 --- a/dvc/repo/experiments/executor/base.py +++ b/dvc/repo/experiments/executor/base.py @@ -7,6 +7,7 @@ from contextlib import contextmanager from dataclasses import asdict, dataclass from enum import IntEnum from functools import partial +from itertools import chain from typing import ( TYPE_CHECKING, Any, @@ -261,10 +262,14 @@ class BaseExecutor(ABC): ) @classmethod - def _get_top_level_paths(cls, repo: "Repo") -> Iterable["str"]: - yield from _collect_top_level_metrics(repo) - yield from _collect_top_level_params(repo) - yield from repo.index._plot_sources # pylint: disable=protected-access + def _get_top_level_paths(cls, repo: "Repo") -> List["str"]: + return list( + chain( + _collect_top_level_metrics(repo), + _collect_top_level_params(repo), + repo.index._plot_sources, # pylint: disable=protected-access + ) + ) @classmethod def save( @@ -544,20 +549,16 @@ class BaseExecutor(ABC): repro_force or checkpoint_reset, ) - def after_repro(): - paths = list(cls._get_top_level_paths(dvc)) - if paths: - logger.debug("Staging top-level files: %s", paths) - dvc.scm_context.add(paths) - stages = dvc_reproduce( dvc, *args, on_unchanged=filter_pipeline, checkpoint_func=checkpoint_func, - after_repro_callback=after_repro, **kwargs, ) + if paths := cls._get_top_level_paths(dvc): + logger.debug("Staging top-level files: %s", paths) + dvc.scm_context.add(paths) exp_hash = cls.hash_exp(stages) if not repro_dry: diff --git a/dvc/repo/reproduce.py b/dvc/repo/reproduce.py index 3ce4fadf4..0c3321010 100644 --- a/dvc/repo/reproduce.py +++ b/dvc/repo/reproduce.py @@ -76,13 +76,12 @@ def _track_stage(stage: "Stage") -> None: @locked @scm_context -def reproduce( # noqa: C901, PLR0912 +def reproduce( # noqa: C901 self: "Repo", targets=None, recursive=False, pipeline=False, all_pipelines=False, - after_repro_callback=None, **kwargs, ): from .graph import get_pipeline, get_pipelines @@ -126,10 +125,7 @@ def reproduce( # noqa: C901, PLR0912 ) ) - result = _reproduce_stages(self.index.graph, list(stages), **kwargs) - if callable(after_repro_callback): - after_repro_callback() - return result + return _reproduce_stages(self.index.graph, list(stages), **kwargs) def _reproduce_stages( # noqa: C901