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 save: Reintroduce implementation based on executor/queue. #9165

Merged
merged 1 commit into from
Mar 24, 2023

Conversation

daavoo
Copy link
Contributor

@daavoo daavoo commented Mar 13, 2023

Closes #9058

Ensures behavior of _stash_exp in exp run is matched in exp save without duplicating logic.

The simpler implementation ended up being worse for keeping exp run and exp save behavior in sync.

@daavoo daavoo linked an issue Mar 13, 2023 that may be closed by this pull request
@daavoo daavoo requested a review from dberenbaum March 13, 2023 15:38
@daavoo daavoo added the A: experiments Related to dvc exp label Mar 14, 2023
@daavoo daavoo force-pushed the 9058-exp-save-handle-staged-files-like-exp-run branch from 494c7a4 to b397158 Compare March 14, 2023 09:22
@codecov
Copy link

codecov bot commented Mar 14, 2023

Codecov Report

Patch coverage: 90.36% and project coverage change: -0.02 ⚠️

Comparison is base (91d3ff0) 92.86% compared to head (c5b673d) 92.85%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9165      +/-   ##
==========================================
- Coverage   92.86%   92.85%   -0.02%     
==========================================
  Files         458      458              
  Lines       37027    37044      +17     
  Branches     5350     5344       -6     
==========================================
+ Hits        34386    34398      +12     
- Misses       2114     2118       +4     
- Partials      527      528       +1     
Impacted Files Coverage Δ
dvc/repo/experiments/executor/base.py 83.73% <75.00%> (-0.57%) ⬇️
dvc/repo/experiments/executor/local.py 91.47% <100.00%> (+0.06%) ⬆️
dvc/repo/experiments/save.py 100.00% <100.00%> (+4.76%) ⬆️
tests/func/experiments/test_save.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@daavoo daavoo force-pushed the 9058-exp-save-handle-staged-files-like-exp-run branch from b397158 to dabe361 Compare March 14, 2023 09:57
@daavoo
Copy link
Contributor Author

daavoo commented Mar 14, 2023

@dberenbaum I have done some QA and updated the tests but might have missed some discrepancies with exp run , could you give it a sweep?

@dberenbaum
Copy link
Collaborator

Can't remember if it's a new issue or whether this should be a separate follow-up, but an untracked dvc.lock is not being included automatically:

$ dvc exp save
WARNING: The following untracked files were present in the workspace before saving but will not be included in the experiment commit:
        dvc.lock

I also can't remember whether exp run/save are supposed to be preserving the git staging status. Everything staged gets saved, but it gets unstaged after exp run/save:

$ git add .
$ dvc exp run
$ git status
On branch main
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        baz.txt
        dvc.lock

nothing added to commit but untracked files present (use "git add" to track)
$ git add .
$ dvc exp save
$ git status
On branch main
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        baz.txt
        dvc.lock

nothing added to commit but untracked files present (use "git add" to track)

@daavoo daavoo marked this pull request as draft March 16, 2023 18:39
@daavoo daavoo self-assigned this Mar 20, 2023
@daavoo daavoo changed the title exp save: Reintroduce implementation based on executor/queue. [WIP] exp save: Reintroduce implementation based on executor/queue. Mar 21, 2023
@daavoo daavoo removed the request for review from dberenbaum March 21, 2023 11:52
@daavoo daavoo force-pushed the 9058-exp-save-handle-staged-files-like-exp-run branch 3 times, most recently from 21d7f17 to cad6bec Compare March 23, 2023 09:41
@daavoo daavoo added the refactoring Factoring and re-factoring label Mar 23, 2023
@daavoo daavoo changed the title [WIP] exp save: Reintroduce implementation based on executor/queue. exp save: Reintroduce implementation based on executor/queue. Mar 23, 2023
@daavoo daavoo marked this pull request as ready for review March 23, 2023 09:58
@daavoo daavoo force-pushed the 9058-exp-save-handle-staged-files-like-exp-run branch from cad6bec to 1f5f411 Compare March 23, 2023 10:00
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really know why some tests in this file randomly fail (mostly on windows , few times on macos) when running the full test suite but pass when running the file in isolation:

Failure: https://github.com/iterative/dvc/actions/runs/4498532766/jobs/7915264864#step:6:934
Passing on isolation: https://github.com/iterative/dvc/actions/runs/4499133901/jobs/7916623248

I updated the tests to use a "from scratch" setup and only tmp_dir, dvc, scm fixtures.

@daavoo daavoo requested a review from a team March 23, 2023 10:00
Comment on lines 30 to 33
save_result = executor.save(
executor.info, force=force, include_untracked=include_untracked
)
result = queue.collect_executor(repo.experiments, executor, save_result)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
save_result = executor.save(
executor.info, force=force, include_untracked=include_untracked
)
result = queue.collect_executor(repo.experiments, executor, save_result)
try:
save_result = executor.save(
executor.info, force=force, include_untracked=include_untracked
)
result = queue.collect_executor(repo.experiments, executor, save_result)
finally:
executor.cleanup()

Copy link
Contributor

@pmrowla pmrowla Mar 23, 2023

Choose a reason for hiding this comment

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

You need to cleanup the executor here since it has it's own scm instance that isn't getting closed.

Not sure whether or not this is the cause of your flaky tests, but it's possible some git object isn't being written/flushed before your test tries to read it afterwards

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It appeared to be the cause. Thanks!

@daavoo daavoo force-pushed the 9058-exp-save-handle-staged-files-like-exp-run branch 3 times, most recently from aa987ca to 3c36693 Compare March 23, 2023 15:12
@daavoo daavoo requested a review from pmrowla March 23, 2023 16:02
@daavoo daavoo enabled auto-merge (rebase) March 24, 2023 08:37
@daavoo daavoo force-pushed the 9058-exp-save-handle-staged-files-like-exp-run branch from 3c36693 to b7bbde5 Compare March 24, 2023 08:37
Closes #9058 .

Ensures behavior of `_stash_exp` in `exp run` is matched in `exp save` without duplicating logic.

The simpler implementation ended up being worse for maintenance when wanting to make `exp run` and `exp save` behavior in sync.
@daavoo daavoo force-pushed the 9058-exp-save-handle-staged-files-like-exp-run branch from b7bbde5 to c5b673d Compare March 24, 2023 09:12
@daavoo daavoo merged commit 6b6dc01 into main Mar 24, 2023
@daavoo daavoo deleted the 9058-exp-save-handle-staged-files-like-exp-run branch March 24, 2023 09:43
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 refactoring Factoring and re-factoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exp save: Handle staged files like exp run
3 participants