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

Index: support custom meta comparison function in diff #237

Merged
merged 2 commits into from
Nov 28, 2022

Conversation

pmrowla
Copy link
Contributor

@pmrowla pmrowla commented Nov 28, 2022

  • Adds index.diff(meta_cmp_key=...) parameter
    • Can be used to specify a key function which will be used to compare old.meta and new.meta (rather than comparing the entire meta instance)
    • Works the same way as python sorted(key=...), i.e. meta_cmp_key=lambda m: m.etag can be used to only compare old.etag == new.etag in diff
    • When either or both old/new entry.meta is none, meta_cmp_key will be ignored
  • additional kwargs for index.checkout() will be passed into diff() (only used when old index is also passed into checkout)

In DVC we want to avoid pushing a new version when the old and new checksums match, even if the version_ids do not match. i.e. someone else may have pushed a new version_id, but if their etag matches ours we do not need to push another duplicate copy, the "latest" version is still what we want it to be.

prerequisite for iterative/dvc#8409

@pmrowla pmrowla self-assigned this Nov 28, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2022

Codecov Report

Base: 55.29% // Head: 55.21% // Decreases project coverage by -0.07% ⚠️

Coverage data is based on head (0395c6b) compared to base (0ee8097).
Patch coverage: 36.36% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
- Coverage   55.29%   55.21%   -0.08%     
==========================================
  Files          49       49              
  Lines        2930     2936       +6     
  Branches      501      504       +3     
==========================================
+ Hits         1620     1621       +1     
- Misses       1234     1237       +3     
- Partials       76       78       +2     
Impacted Files Coverage Δ
src/dvc_data/index/diff.py 78.16% <16.66%> (-2.80%) ⬇️
src/dvc_data/index/checkout.py 61.81% <60.00%> (-1.65%) ⬇️

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 at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pmrowla pmrowla merged commit 7bddfcd into iterative:main Nov 28, 2022
@pmrowla pmrowla deleted the index-diff-key branch November 28, 2022 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants