Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exp run: track files for skipped/run-cached stages #9889

Merged
merged 1 commit into from
Sep 4, 2023

Conversation

pmrowla
Copy link
Contributor

@pmrowla pmrowla commented Aug 30, 2023

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™

Fixes #9781

@pmrowla pmrowla self-assigned this Aug 30, 2023
@pmrowla pmrowla marked this pull request as draft August 30, 2023 06:35
@pmrowla pmrowla changed the title stage: count cached stages as being reproduced exp run: track files for skipped/run-cached stages Aug 30, 2023
Comment on lines +543 to +547
ret = _reproduce_stage(stage, **kwargs)
if not kwargs.get("dry") and (paths := _get_stage_files(stage)):
logger.debug("Staging stage-related files: %s", paths)
stage.repo.scm_context.add(paths)
return ret
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stage.reproduce() returns None for skipped (unchanged run-cached) stages, and when the entire pipeline is skipped dvc.reproduce() ends up returning an empty list. In exp run we still need to force git-tracking the dvc.yaml and dvc.lock for those skipped stages.

@pmrowla pmrowla marked this pull request as ready for review August 30, 2023 06:57
@pmrowla pmrowla added A: experiments Related to dvc exp bugfix fixes bug labels Aug 30, 2023
@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Patch coverage is 100.00% of modified lines.

Files Changed Coverage
dvc/repo/experiments/executor/base.py 100.00%

πŸ“’ Thoughts on this report? Let us know!.

@skshetry
Copy link
Member

@pmrowla, what do you think of changing the return type of dvc.reproduce()?

@pmrowla
Copy link
Contributor Author

pmrowla commented Aug 30, 2023

@pmrowla, what do you think of changing the return type of dvc.reproduce()?

I thought about having it return the tuple of ([reproduced], [skipped]) stages but wasn't sure if that would be useful anywhere else outside of this use case

@skshetry
Copy link
Member

@pmrowla, what do you think of changing the return type of dvc.reproduce()?

I thought about having it return the tuple of ([reproduced], [skipped]) stages but wasn't sure if that would be useful anywhere else outside of this use case

I think it should be something like following now, after --keep-going and --ignore-errors implementation.

@dataclass
class Result:
    reproduced: List["Stage"] = field(default_factory=list)
    unchanged: List["Stage"] = field(default_factory=list)
    failed: List["Stage"] = field(default_factory=list)
    skipped: List["Stage"] = field(default_factory=list)

I think we are long due for changing return type of repro. We have been hacking just to not change the return type.

But I guess adjusting tests will be painful, so I'm happy with this too for now. But we'll have to change the return type at some point.

@skshetry
Copy link
Member

I am also okay with introducing a post_run_hook as that's what this seems to be about, and will avoid wrapping _reproduce_stage.

@skshetry
Copy link
Member

Btw, what should be the behaviour here if dvc exp run fails? Should it still stage files from stages that were run? Previous implementation did not do that, this one does.

@daavoo
Copy link
Contributor

daavoo commented Aug 30, 2023

I agree changing the return type would be cleaner but no strong opinion or need to block the P.R.

@pmrowla
Copy link
Contributor Author

pmrowla commented Aug 30, 2023

Btw, what should be the behaviour here if dvc exp run fails? Should it still stage files from stages that were run? Previous implementation did not do that, this one does.

If it fails, we don't make a commit and everything gets git reset to the state prior to the experiment anyways, so it doesn't make a difference whether or not we stage anything right now

@pmrowla
Copy link
Contributor Author

pmrowla commented Sep 4, 2023

I think we're all in agreement that the return type for reproduce() will need to be reworked going forward, but I think that's beyond the scope of this bug fix, especially since it will require updating a lot of tests

Going to go ahead and merge this as-is for now

@pmrowla pmrowla merged commit bf119e7 into iterative:main Sep 4, 2023
18 of 20 checks passed
@pmrowla pmrowla deleted the stage-cached-dump branch September 4, 2023 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: experiments Related to dvc exp bugfix fixes bug
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

dvc exp run: Repeated execution of dvc exp run leads to second experiment being corrupted
3 participants