Schedule serialization not working

  • Quantify-scheduler version: 0.22.1
  • Quantify-core version (or n/a): 0.7.9
  • Python version: 3.9
  • Python install method (anaconda/virtualenv/other?): conda
  • Operating System: MacOS 15.1.1

Description

The schedule serialization has been a part of quantify for a while, but it is rarely used in my impression. We have a good use case for it, so I wanted to test if it works out of the box. As this example shows, it doesn't. So the goal of this issue is not to make this one schedule serialization work, but to fix the method so that it works in general.

Specifically, here I tried to serialize a schedule using the Schedule.to_json() method.

What I Did

250116_serialize_schedule_quantify.py

What Was Expected

Runs without failure.

What Actually Happened

Traceback (most recent call last):
  File "/Users/konstantin/code/products/scqt/250116_serialize_schedule_quantify.py", line 56, in <module>
    json_schedule = schedule.to_json()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/scqt-3.9/lib/python3.9/site-packages/quantify_scheduler/schedules/schedule.py", line 199, in to_json
    return json.dumps(self, cls=json_utils.SchedulerJSONEncoder)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/scqt-3.9/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/scqt-3.9/lib/python3.9/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/scqt-3.9/lib/python3.9/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
ValueError: Circular reference detected

You can also find us on Slack. For reference, the issues workflow is described in the contribution guidelines.