Page MenuHomeSoftware Heritage

Use dict instead of temporary SWHID when parsing {Core,Qualified}SWHID.
ClosedPublic

Authored by vlorentz on Feb 19 2021, 2:17 PM.

Details

Summary

It is cleaner, avoids warnings, and will be needed when introducing
ExtendedSWHID in a future commit.

Depends on D5116.

Diff Detail

Repository
rDMOD Data model
Branch
parse-swhid
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 19389
Build 30069: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 30068: arc lint + arc unit

Event Timeline

Build has FAILED

Patch application report for D5117 (id=18303)

Could not rebase; Attempt merge onto 758eb885d3...

Updating 758eb88..3668e2e
Fast-forward
 swh/model/identifiers.py            | 349 +++++++++++++++++++++++++++++++++--
 swh/model/tests/test_identifiers.py | 359 ++++++++++++++++++++++++++++++++++--
 tox.ini                             |   1 +
 3 files changed, 673 insertions(+), 36 deletions(-)
Changes applied before test
commit 3668e2e928d0452af9116c5b56da73afd5720737
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Fri Feb 19 13:58:03 2021 +0100

    Use dict instead of temporary SWHID when parsing {Core,Qualified}SWHID.
    
    It is cleaner, avoids warnings, and will be needed when introducing
    ExtendedSWHID in a future commit.

commit 8e917597dbb22054ada06387a0501452d8862d34
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Fri Feb 19 10:56:29 2021 +0100

    QualifiedSWHID: Replace the 'qualifiers' dict with statically defined attributes
    
    And store their parsed values (CoreSWHID, tuple of ints, etc.) instead of string.

commit eba8d84de660e2b3d7df304fa32da7404fb9f6bb
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Feb 18 13:09:21 2021 +0100

    Add new class CoreSWHID as an alternative to SWHID/QualifiedSWHID
    
    Following the discussion on T3034, we decided to replace SWHID with
    two or three classes:
    
    * QualifiedSWHID to replace the existing SWHID (standard types + qualifiers)
    * CoreSWHID, for "core SWHID" only (standard types + no qualifiers)
    * ExtendedSWHID for internal use in Software Heritage (extra types + no qualifiers)
    
    This commit adds the second one

commit 690b7f824f55bc65fbec21b29714926476038abb
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Feb 16 13:33:13 2021 +0100

    Add new class QualifiedSWHID to replace SWHID, and deprecate the latter.
    
    Following the discussion on T3034, we decided to replace SWHID with
    two or three classes:
    
    * QualifiedSWHID to replace the existing SWHID (standard types + qualifiers)
    * CoreSWHID, for "core SWHID" only (standard types + no qualifiers)
    * ExtendedSWHID for internal use in Software Heritage (extra types + no qualifiers)
    
    Since migrating from SWHID will break existing code, this commit uses
    the opportunity to modernize it a little, ie.:
    
    * `keyword`-only constructor, to get rid of the hacky default values for
      `object_type` and `object_id`
    * enum instead of strings for the object type
    * `bytes` instead of an hex string for the object id
    * rename `metadata` to `qualifiers`

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

Harbormaster returned this revision to the author for changes because remote builds failed.Feb 19 2021, 2:18 PM
Harbormaster failed remote builds in B19389: Diff 18303!

remove 'type: ignore' on QualifiedSWHID(parts, qualifiers), mypy no longer needs/accepts it

Build is green

Patch application report for D5117 (id=18304)

Could not rebase; Attempt merge onto 758eb885d3...

Updating 758eb88..9923765
Fast-forward
 swh/model/identifiers.py            | 349 +++++++++++++++++++++++++++++++++--
 swh/model/tests/test_identifiers.py | 359 ++++++++++++++++++++++++++++++++++--
 tox.ini                             |   1 +
 3 files changed, 673 insertions(+), 36 deletions(-)
Changes applied before test
commit 992376597d6f44dfe78c4eef40bf651fe355f0fd
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Fri Feb 19 13:58:03 2021 +0100

    Use dict instead of temporary SWHID when parsing {Core,Qualified}SWHID.
    
    It is cleaner, avoids warnings, and will be needed when introducing
    ExtendedSWHID in a future commit.

commit 8e917597dbb22054ada06387a0501452d8862d34
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Fri Feb 19 10:56:29 2021 +0100

    QualifiedSWHID: Replace the 'qualifiers' dict with statically defined attributes
    
    And store their parsed values (CoreSWHID, tuple of ints, etc.) instead of string.

commit eba8d84de660e2b3d7df304fa32da7404fb9f6bb
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Feb 18 13:09:21 2021 +0100

    Add new class CoreSWHID as an alternative to SWHID/QualifiedSWHID
    
    Following the discussion on T3034, we decided to replace SWHID with
    two or three classes:
    
    * QualifiedSWHID to replace the existing SWHID (standard types + qualifiers)
    * CoreSWHID, for "core SWHID" only (standard types + no qualifiers)
    * ExtendedSWHID for internal use in Software Heritage (extra types + no qualifiers)
    
    This commit adds the second one

commit 690b7f824f55bc65fbec21b29714926476038abb
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Feb 16 13:33:13 2021 +0100

    Add new class QualifiedSWHID to replace SWHID, and deprecate the latter.
    
    Following the discussion on T3034, we decided to replace SWHID with
    two or three classes:
    
    * QualifiedSWHID to replace the existing SWHID (standard types + qualifiers)
    * CoreSWHID, for "core SWHID" only (standard types + no qualifiers)
    * ExtendedSWHID for internal use in Software Heritage (extra types + no qualifiers)
    
    Since migrating from SWHID will break existing code, this commit uses
    the opportunity to modernize it a little, ie.:
    
    * `keyword`-only constructor, to get rid of the hacky default values for
      `object_type` and `object_id`
    * enum instead of strings for the object type
    * `bytes` instead of an hex string for the object id
    * rename `metadata` to `qualifiers`

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

olasd added a subscriber: olasd.

Thanks!

swh/model/identifiers.py
800

Not sure if that gets refactored later?

864–867

I guess this converter is getting tested via the new from_string? Maybe it'd make sense to have a simple unit test for it.

This revision is now accepted and ready to land.Feb 23 2021, 10:59 AM
swh/model/identifiers.py
800

it doesn't, why?

864–867

yes and so do the other ones. I'll add an other diff for that

swh/model/identifiers.py
864–867