Page MenuHomeSoftware Heritage

model: Add a raw_manifest attribute
ClosedPublic

Authored by vlorentz on Dec 8 2021, 5:22 PM.

Details

Summary

This will be used to store the original manifest of 'weird' git objects,
when we cannot reasonably represent them otherwise.

First step for T3753.

Diff Detail

Repository
rDMOD Data model
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build has FAILED

Patch application report for D6801 (id=24650)

Could not rebase; Attempt merge onto c32290481c...

Updating c322904..5d078ec
Fast-forward
 swh/model/model.py            | 110 ++++++++++++++++++++++++++++++++----------
 swh/model/tests/test_model.py | 102 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 186 insertions(+), 26 deletions(-)
Changes applied before test
commit 5d078ecf17538e264ea2616a5863edceee39fc56
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:28:25 2021 +0100

    model: Add a raw_manifest attribute
    
    This will be used to store the original manifest of 'weird' git objects,
    when we cannot reasonably represent them otherwise.

commit 1c4d0bb0fae359ce506db5e678386a0c8bb6ded8
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:20:38 2021 +0100

    model: Deduplicate calls to hashlib.
    
    It's just simpler this way

commit 59ed64b08cd42c5af988b402f5948b077a5cb296
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:24:38 2021 +0100

    model: Add a check() method to model objects
    
    It calls attr.validate() (which calls the validators), and recomputes
    the hash of HashableObject instances.
    
    A future commit will also make it check the raw_manifest attribute
    when relevant

commit 5eb65393af220b3e52f83f34bd27af9d0047cbf2
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:20:38 2021 +0100

    model: Deduplicate calls to hashlib.
    
    It's just simpler this way

commit 2d0105b8413064db60aaa0802a45b0fad8b12d25
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:17:40 2021 +0100

    model: Add support for None to the type checker
    
    For the sake of completeness (a future commit may depend on it).

Link to build: https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/427/
See console output for more information: https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/427/console

Harbormaster returned this revision to the author for changes because remote builds failed.Dec 8 2021, 5:23 PM
Harbormaster failed remote builds in B25508: Diff 24650!

Build is green

Patch application report for D6801 (id=24651)

Could not rebase; Attempt merge onto c32290481c...

Updating c322904..b9e0617
Fast-forward
 swh/model/model.py            | 106 +++++++++++++++++++++++++++++++-----------
 swh/model/tests/test_model.py | 102 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 182 insertions(+), 26 deletions(-)
Changes applied before test
commit b9e0617e74d790c224f0bba31e541fe7b6b673de
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:28:25 2021 +0100

    model: Add a raw_manifest attribute
    
    This will be used to store the original manifest of 'weird' git objects,
    when we cannot reasonably represent them otherwise.

commit 59ed64b08cd42c5af988b402f5948b077a5cb296
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:24:38 2021 +0100

    model: Add a check() method to model objects
    
    It calls attr.validate() (which calls the validators), and recomputes
    the hash of HashableObject instances.
    
    A future commit will also make it check the raw_manifest attribute
    when relevant

commit 5eb65393af220b3e52f83f34bd27af9d0047cbf2
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:20:38 2021 +0100

    model: Deduplicate calls to hashlib.
    
    It's just simpler this way

commit 2d0105b8413064db60aaa0802a45b0fad8b12d25
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:17:40 2021 +0100

    model: Add support for None to the type checker
    
    For the sake of completeness (a future commit may depend on it).

See https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/428/ for more details.

ardumont added inline comments.
swh/model/model.py
272

Is that to prevent programmer from doing something they don't need to do in loaders?

swh/model/model.py
272

yes

olasd added a subscriber: olasd.

You've made _compute_hash_from_attributes a "private" method, but wouldn't the git loader need to call it explicitly to know whether to populate the raw_manifest field?

Apart from that question, this looks fine, thanks!

This revision is now accepted and ready to land.Dec 14 2021, 11:59 AM

No, it just needs to call compute_hash(). Before setting a raw_manifest, both are equivalent

This revision was landed with ongoing or failed builds.Dec 22 2021, 1:22 PM
This revision was automatically updated to reflect the committed changes.

Build is green

Patch application report for D6801 (id=24897)

Rebasing onto 9e1e14a829...

Current branch diff-target is up to date.
Changes applied before test
commit f6144a15fa507ffd4e7acca207bcf5272ed16fbd
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:28:25 2021 +0100

    model: Add a raw_manifest attribute
    
    This will be used to store the original manifest of 'weird' git objects,
    when we cannot reasonably represent them otherwise.

See https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/436/ for more details.