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

Unit TestsFailed

TimeTest
101,843 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.algos.test_snapshot::test_snapshot_large
swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f85d7ddfb38> @given(branch_name=branch_names(), branch_target=branch_targets(only_objects=True))
529 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_cassandra.TestCassandraStorage::test_revision_add_name_clash
self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f87780db4a8> swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f87780db9b0>
533 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_cassandra.TestCassandraStorage::test_revision_add_twice
self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f87384b3668> swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f87383c7860>
453 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_cassandra.TestCassandraStorage::test_revision_get_no_parents
self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f87501ebf28> swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f871479cf98>
485 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_cassandra.TestCassandraStorage::test_revision_get_order
self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f87505c7668> swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f87505e3358>
View Full Test Results (10 Failed · 770 Passed · 17 Skipped)

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
17–20

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
17–20

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.