Page MenuHomeSoftware Heritage

Convert ImmutableDict to dict before passing it to json.dumps.
ClosedPublic

Authored by douardda on Jul 9 2020, 10:28 AM.

Details

Summary

To work with the new swh-model version, which uses ImmutableDict in model objects.

Introducing the map_optional function just for that may seem pointless, but I use it a lot in D3456.

Diff Detail

Repository
rDSTO Storage manager
Branch
immutable-dict-json
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 13510
Build 20672: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 20671: arc lint + arc unit

Event Timeline

Build has FAILED

Patch application report for D3476 (id=12291)

Rebasing onto c21d0e3820...

Current branch diff-target is up to date.
Changes applied before test
commit 9df56b5d85fbb8a55877a811970e062ecdc022a4
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Jul 9 10:27:12 2020 +0200

    Convert ImmutableDict to dict before passing it to json.dumps.
    
    To work with the new swh-model version, which uses ImmutableDict in model objects.

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

cast instead of 'type: ignore'

Not sure I buy the map_optional here. When I read a line of code with [x if x else f(x)] I understand it right away. With map_optional, I need to go get the definition of that oneliner function.
Plus you have the type annotation headache...

Build has FAILED

Patch application report for D3476 (id=12293)

Rebasing onto c21d0e3820...

Current branch diff-target is up to date.
Changes applied before test
commit e4f044f06948aa1510ed0cc99d4549211c5f0097
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Jul 9 10:27:12 2020 +0200

    Convert ImmutableDict to dict before passing it to json.dumps.
    
    To work with the new swh-model version, which uses ImmutableDict in model objects.

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

douardda added a reviewer: vlorentz.

simplify the diff by killing map_optional()

olasd added a subscriber: olasd.
olasd added inline comments.
swh/storage/db.py
22–25

I guess this would make sense "upstream" too.

This revision is now accepted and ready to land.Jul 9 2020, 11:35 AM

Build has FAILED

Patch application report for D3476 (id=12294)

Rebasing onto c21d0e3820...

Current branch diff-target is up to date.
Changes applied before test
commit 8bf3794874fab66a3049204d3dd391d2b66cae4b
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Jul 9 10:27:12 2020 +0200

    Convert ImmutableDict to dict before passing it to json.dumps.
    
    To work with the new swh-model version, which uses ImmutableDict in model objects.

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

swh/storage/db.py
22–25

we can't, this helper function is too loosely defined to be able to do so. Here we know we will use it on dict-like structures only.

This revision was landed with ongoing or failed builds.Jul 9 2020, 11:44 AM
This revision was automatically updated to reflect the committed changes.