Page MenuHomeSoftware Heritage

Use attr instead of NamedTuple to generate SWHID.
ClosedPublic

Authored by vlorentz on Jul 7 2020, 5:34 PM.

Details

Summary

As NamedTuple inherits from tuple, msgpack serializes it like a tuple,
which makes it indistinguishable from a tuple when deserializing,
which is an issue for the RPC API.

Diff Detail

Repository
rDMOD Data model
Branch
attr-swhid
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 13445
Build 20564: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 20563: arc lint + arc unit

Event Timeline

Build is green

Patch application report for D3450 (id=12225)

Rebasing onto bea256e390...

Current branch diff-target is up to date.
Changes applied before test
commit 52ef52ea46acbbf6622a172ff5fc8b9fa7d9cbd2
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Jul 7 17:34:41 2020 +0200

    Use attr instead of NamedTuple to generate SWHID.
    
    As NamedTuple inherits from tuple, msgpack serializes it like a tuple,
    which makes it indistinguishable from a tuple when deserializing,
    which is an issue for the RPC API.

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

douardda added a subscriber: douardda.

Thx, looks good. Just a small question about the modification of the swhid() API.

swh/model/identifiers.py
754

how is this (accept dict) related to the namedtuple->attr refactoring?

This revision is now accepted and ready to land.Jul 8 2020, 9:32 AM
swh/model/identifiers.py
754

07:53 <vlorentz> douardda: the reason is that we were already passing dicts
07:54 <+douardda> so the type annotation was wrong?
07:54 <vlorentz> yes
07:54 <+douardda> ok, I would have preferred this fix live in a dedicated revision,but meh