Page MenuHomeSoftware Heritage

[RFC] Add 'evolve' method to BaseModel objects
Changes PlannedPublic

Authored by vlorentz on Jul 21 2022, 12:45 PM.

Details

Reviewers
None
Group Reviewers
Reviewers
Summary

This allows implicitly updating the id when altering data,
which is very useful in tests of other packages

Depends on D8150.

Test Plan

This is missing a bunch of tests; I will write them if you are fine with this idea.

Diff Detail

Event Timeline

Build has FAILED

Patch application report for D8151 (id=29432)

Could not rebase; Attempt merge onto b872718ab4...

Updating b872718..a4cd229
Fast-forward
 swh/model/model.py            | 32 ++++++++++++++++++++++++--------
 swh/model/tests/test_model.py | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 8 deletions(-)
Changes applied before test
commit a4cd229b7461058596dba74f63430e96cd2bb12f
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Jul 21 12:44:50 2022 +0200

    [RFC] Add 'evolve' method to BaseModel objects
    
    This allows implicitly updating the id when altering data,
    which is very useful in tests of other packages

commit a2158edd4073887a36c9778dcc1b71c667e66866
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Jul 21 12:42:42 2022 +0200

    Rename HashableObject to BaseHashableModel and make it a subclass of BaseModel
    
    instead of a mix-in class.
    
    A future commit will add a method implemented by both with different
    signatures that mypy cannot unify yet.

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

Harbormaster returned this revision to the author for changes because remote builds failed.Jul 21 2022, 12:47 PM
Harbormaster failed remote builds in B30510: Diff 29432!

Build is green

Patch application report for D8151 (id=29436)

Could not rebase; Attempt merge onto b872718ab4...

Updating b872718..44e419e
Fast-forward
 swh/model/model.py            | 32 ++++++++++++++++++++++++--------
 swh/model/tests/test_model.py | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 8 deletions(-)
Changes applied before test
commit 44e419e6710e886b60188611ad0c94e9a7b30d89
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Jul 21 12:44:50 2022 +0200

    [RFC] Add 'evolve' method to BaseModel objects
    
    This allows implicitly updating the id when altering data,
    which is very useful in tests of other packages

commit b867d22a904c41ac40c2e7629ecf7bfdcfa25c4b
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Jul 21 12:42:42 2022 +0200

    Rename HashableObject to BaseHashableModel and make it a subclass of BaseModel
    
    instead of a mix-in class.
    
    A future commit will add a method implemented by both with different
    signatures that mypy cannot unify yet.

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

Yeah, I think that makes sense. Time for these tests to be written? :)