Page MenuHomeSoftware Heritage

Encode datetime as Timestamp in msgpack
ClosedPublic

Authored by douardda on Dec 8 2020, 5:13 PM.

Details

Summary

decoding custom format is still supported for backward compat.
Note that revision modify the exception type raised when attempting to
encode a naive datetime object for both formats (json amd msgpack): it
now raises a TypeError instead of a ValueError.

The ENCODERS/DECODERS constants have also been split to make clear which
codecs are specific to the json format.

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D4690 (id=16642)

Rebasing onto 6492e6173e...

Current branch diff-target is up to date.
Changes applied before test
commit 39abbfd34a057c262b3aebc653235e69c23c6864
Author: David Douard <david.douard@sdfa3.org>
Date:   Tue Dec 8 16:49:59 2020 +0100

    Encode datetime as Timestamp in msgpack
    
    decoding custom format is still supported for backward compat.
    Note that revision modify the exception type raised when attempting to
    encode a naive datetime object for both formats (json amd msgpack): it
    now raises a TypeError instead of a ValueError.
    
    The ENCODERS/DECODERS constants have also been split to make clear which
    codecs are specific to the json format.

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

Thanks for this change!

Could you split:

  • the json.dumps -> json_dumps changes
  • the JSON_ENCODERS/DECODERS split

into commits separate from the msgpack change?

split the commit in 3 parts

Build is green

Patch application report for D4690 (id=16715)

Rebasing onto 6492e6173e...

Current branch diff-target is up to date.
Changes applied before test
commit 777ea186fa8d31a972ccc15abb7c42297e0a399f
Author: David Douard <david.douard@sdfa3.org>
Date:   Fri Dec 11 09:33:29 2020 +0100

    Encode datetime as Timestamp in msgpack
    
    decoding custom format is still supported for backward compat.
    
    Note that this revision modifies the exception type raised when attempting to
    encode a naive datetime object for both formats (json amd msgpack): it now
    raises a TypeError instead of a ValueError.

commit e722afbf82e32e2b51594d760b91c87ed22883dd
Author: David Douard <david.douard@sdfa3.org>
Date:   Fri Dec 11 09:31:52 2020 +0100

    Split serializers ENCODERS/DECODERS to extract JSON specific ones
    
    to make it clear which codecs are specific to the json format.

commit 10b997ac1c86b1997b58d1445a8fd7ec55870919
Author: David Douard <david.douard@sdfa3.org>
Date:   Fri Dec 11 09:27:12 2020 +0100

    Use json_dumps/loads in test_serializers.py
    
    instead of json.dumps(..., cls=SWHJSONEncoder) and so.
    
    This simplify a bit the code and make sure the json_dumps/loads
    functions are actually tested.

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

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