Skip to content

Commit b68f25f

Browse files
committed
Fix EngineProgram.get_circuit(_async) empty code detection
1 parent 2ef9f37 commit b68f25f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cirq-google/cirq_google/engine/engine_program.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ async def get_circuit_async(self) -> cirq.Circuit:
361361
Returns:
362362
The program's cirq Circuit.
363363
"""
364-
if self._program is None or self._program.code is None:
364+
# The code field is an any_pb2.Any and is always set. But if the program has not
365+
# been fetched this field may be empty, which we can see by checking the type_url.
366+
if self._program is None or not self._program.code or not self._program.code.type_url:
365367
self._program = await self.context.client.get_program_async(
366368
self.project_id, self.program_id, True
367369
)

0 commit comments

Comments
 (0)