@@ -44,6 +44,7 @@ def __init__(
44
44
self ,
45
45
service : 'cirq_ionq.Service' ,
46
46
target : Optional [str ],
47
+ timeout_seconds : Optional [int ] = None ,
47
48
seed : cirq .RANDOM_STATE_OR_SEED_LIKE = None ,
48
49
):
49
50
"""Construct the sampler.
@@ -57,10 +58,12 @@ def __init__(
57
58
seed: If the target is `simulation` the seed for generating results. If None, this
58
59
will be `np.random`, if an int, will be `np.random.RandomState(int)`, otherwise
59
60
must be a modulate similar to `np.random`.
61
+ timeout_seconds: Length of time to wait for results. Default is specified in the job.
60
62
"""
61
63
self ._service = service
62
64
self ._target = target
63
65
self ._seed = seed
66
+ self ._timeout_seconds = timeout_seconds
64
67
65
68
def run_sweep (
66
69
self ,
@@ -86,7 +89,10 @@ def run_sweep(
86
89
)
87
90
for resolver in resolvers
88
91
]
89
- job_results = [job .results () for job in jobs ]
92
+ kwargs = {}
93
+ if self ._timeout_seconds is not None :
94
+ kwargs = {"timeout_seconds" : self ._timeout_seconds }
95
+ job_results = [job .results (** kwargs ) for job in jobs ]
90
96
cirq_results = []
91
97
for result , params in zip (job_results , resolvers ):
92
98
if isinstance (result , results .QPUResult ):
0 commit comments