diff --git a/VERSION.txt b/VERSION.txt index 9beb74d49..288adf538 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.13.2 +0.13.3 diff --git a/pulser-core/pulser/json/coders.py b/pulser-core/pulser/json/coders.py index 46b8ba0e6..3d1a2dc04 100644 --- a/pulser-core/pulser/json/coders.py +++ b/pulser-core/pulser/json/coders.py @@ -101,6 +101,18 @@ def object_hook(self, obj: dict[str, Any]) -> Any: if not build: return cls + if "Device" in obj_name: + # Handle the removal of _channels for backwards compatibility + _channels = obj["__kwargs__"].pop("_channels", None) + channel_objs = obj["__kwargs__"].get("channel_objects", None) + channel_ids = obj["__kwargs__"].get("channel_ids", None) + if _channels and not (channel_ids or channel_objs): + _channels_dict = dict(_channels) + obj["__kwargs__"]["channel_ids"] = tuple(_channels_dict.keys()) + obj["__kwargs__"]["channel_objects"] = tuple( + _channels_dict.values() + ) + if "Sequence" in obj_name: seq = cls(*obj["__args__"], **obj["__kwargs__"]) for name, args, kwargs in obj["calls"]: diff --git a/pulser-core/requirements.txt b/pulser-core/requirements.txt index e1b171398..019c2b781 100644 --- a/pulser-core/requirements.txt +++ b/pulser-core/requirements.txt @@ -1,4 +1,4 @@ -jsonschema +jsonschema < 4.18 matplotlib # Numpy 1.20 introduces type hints, 1.24.0 breaks matplotlib < 3.6.1 numpy >= 1.20, != 1.24.0 diff --git a/pulser-pasqal/requirements.txt b/pulser-pasqal/requirements.txt index a86e8f5a3..c94f4466d 100644 --- a/pulser-pasqal/requirements.txt +++ b/pulser-pasqal/requirements.txt @@ -1 +1,2 @@ pasqal-cloud ~= 0.2.3 +pydantic < 2.0 \ No newline at end of file diff --git a/tests/test_json.py b/tests/test_json.py index 3b8efdde1..9764c84e2 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -210,3 +210,26 @@ def test_sequence_module(): # Check that it also works s = json.dumps(obj_dict) Sequence.deserialize(s) + + +def test_deprecation(): + seq = Sequence(Register.square(1), MockDevice) + + seq_dict = json.loads(seq.serialize()) + dev_dict = seq_dict["__kwargs__"]["device"] + + assert "_channels" not in dev_dict["__kwargs__"] + dev_dict["__kwargs__"]["_channels"] = [] + + s = json.dumps(seq_dict) + new_seq = Sequence.deserialize(s) + assert new_seq.device == MockDevice + + ids = dev_dict["__kwargs__"].pop("channel_ids") + ch_objs = dev_dict["__kwargs__"].pop("channel_objects") + dev_dict["__kwargs__"]["_channels"] = tuple(zip(ids, ch_objs)) + + assert seq_dict["__kwargs__"]["device"] == dev_dict + s = json.dumps(seq_dict) + new_seq = Sequence.deserialize(s) + assert new_seq.device == MockDevice