Skip to content

json serialize SharedRuntimeInfo.device #5746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"shared_runtime_info": {
"cirq_type": "cirq.google.SharedRuntimeInfo",
"run_id": "my run",
"device": null,
"run_start_time": {
"cirq_type": "datetime.datetime",
"timestamp": 1651091275.571572
Expand Down Expand Up @@ -146,4 +147,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cirq_type": "cirq.google.SharedRuntimeInfo",
"run_id": "my run",
"device": null,
"run_start_time": {
"cirq_type": "datetime.datetime",
"timestamp": 1651091275.571572
Expand All @@ -9,4 +10,4 @@
"cirq_type": "datetime.datetime",
"timestamp": 1651092475.571585
}
}
}
5 changes: 1 addition & 4 deletions cirq-google/cirq_google/workflow/quantum_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ def _json_namespace_(cls) -> str:
return 'cirq.google'

def _json_dict_(self) -> Dict[str, Any]:
d = dataclass_json_dict(self)
# TODO (gh-4699): serialize `device` as well once SerializableDevice is serializable.
del d['device']
return d
return dataclass_json_dict(self)

def __repr__(self) -> str:
return _compat.dataclass_repr(self, namespace='cirq_google')
Expand Down
2 changes: 0 additions & 2 deletions cirq-google/cirq_google/workflow/quantum_runtime_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ def test_execute(tmpdir, rt_config):
run_id=run_id, base_data_dir=tmpdir
).load(base_data_dir=tmpdir)

# TODO(gh-4699): Don't null-out device once it's serializable.
assert isinstance(returned_exegroup_result.shared_runtime_info.device, cirq.Device)
returned_exegroup_result.shared_runtime_info.device = None

assert returned_exegroup_result == exegroup_result
assert manual_exegroup_result == exegroup_result
Expand Down