braket.aws.direct_reservations module

class braket.aws.direct_reservations.DirectReservation(device: Device | str | None, reservation_arn: str | None)[source]

Bases: AbstractContextManager

Context manager that modifies AwsQuantumTasks created within the context to use a reservation ARN for all tasks targeting the specified device. Note: this context manager only allows for one reservation at a time.

Reservations are AWS account and device specific. Only the AWS account that created the reservation can use your reservation ARN. Additionally, the reservation ARN is only valid on the reserved device at the chosen start and end times.

Parameters:
  • device (Device | str | None) – The Braket device for which you have a reservation ARN, or optionally the device ARN.

  • reservation_arn (str | None) – The Braket Direct reservation ARN to be applied to all quantum tasks run within the context.

Examples

As a context manager >>> with DirectReservation(device_arn, reservation_arn=”<my_reservation_arn>”): … task1 = device.run(circuit, shots) … task2 = device.run(circuit, shots)

or start the reservation >>> DirectReservation(device_arn, reservation_arn=”<my_reservation_arn>”).start() … task1 = device.run(circuit, shots) … task2 = device.run(circuit, shots)

References:

[1] https://docs.aws.amazon.com/braket/latest/developerguide/braket-reservations.html

start() None[source]

Start the reservation context.

stop() None[source]

Stop the reservation context.