[X] I am running the latest versions of pyQuil and the Forest SDK
[X] I checked to make sure that this bug has not already been reported
Issue Description
A Program containing Frames cannot be pickled if the frames member has been accessed.
For example, in the example below:
a pyQuil program with calibrations can be pickled
a pyQuil program's frames member cannot be pickled (but other individual members can be pickled, such as waveforms.
a pyQuil program with calibrations cannot be pickled if the frames have been accessed, for example, if the copy_everything_except_instructions() method has been called.
Code Snippet
import pickle
from typing import cast
from pyquil import get_qc
from pyquil.api import QPUCompiler
qc = get_qc("Ankaa-9Q-1")
compiler = cast(QPUCompiler, qc.compiler)
cals = compiler.get_calibration_program()
# Works
with open('/tmp/test', 'wb') as file:
pickle.dump(cals, file)
# Works i.e. some individual members can be pickled
with open('/tmp/test', 'wb') as file:
pickle.dump(cals.waveforms, file)
# Fails i.e. the frames member cannot be pickled
with open('/tmp/test', 'wb') as file:
pickle.dump(cals.frames, file)
# Fails
tmp = cals.copy_everything_except_instructions()
with open('/tmp/test', 'wb') as file:
pickle.dump(cals, file)
Error Output
Traceback (most recent call last):
File "test.py", line 28, in <module>
pickle.dump(cals, file)
TypeError: cannot pickle 'Frame' object
Pre-Report Checklist
Issue Description
A
Program
containingFrame
s cannot be pickled if theframes
member has been accessed.For example, in the example below:
pickle
dframes
member cannot bepickle
d (but other individual members can be pickled, such aswaveforms
.pickle
d if theframes
have been accessed, for example, if thecopy_everything_except_instructions()
method has been called.Code Snippet
Error Output
Environment Context
Operating System: Fedora 39 Python: 3.10 PyQuil: 4.7.0