tiled icon indicating copy to clipboard operation
tiled copied to clipboard

feat: add option for additional default in json serializer

Open maffettone opened this issue 10 months ago • 1 comments

This addresses the change in orjson that no longer serializes NamedTuples by default to dictionaries. This is potentially the correct behavior, so the approach taken was to give an option for additional defaults in the serializer (which already does some work for numpy). A related PR in databroker takes advantage of this.

Checklist

  • [x] Add a Changelog entry
  • [x] Add the ticket number which this PR closes to the comment section (None present)

maffettone avatar Feb 20 '25 13:02 maffettone

@ambarb for visibility

maffettone avatar Feb 20 '25 13:02 maffettone

As discussed in the companion PR to databroker @maffettone and I agree the best option is to fix this in the device, to use a serializable type.

danielballan avatar Apr 03 '25 15:04 danielballan

@maffettone does this mean we need to put in something to hklpy (or pyhkl, whichever is the correct one)?

ambarb avatar Apr 03 '25 18:04 ambarb

~Yes, I thought I put an issue there, but on double checking it was a different issue. I'll add something this morning.~ EDIT It looks like hklpy handles its named tuples into arrays when it reads them, so no change is needed there. When you grab it as an attribute (sample.lattice) for putting into RE.md, if you hit an error casting it as a dictionary, we can address that at the profile level.

maffettone avatar Apr 04 '25 11:04 maffettone