Skip to content

Commit

Permalink
update: default no longer returning RETIRED devices from get_devices
Browse files Browse the repository at this point in the history
  • Loading branch information
krneta committed Nov 13, 2023
1 parent 7f28109 commit 0a11d27
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/braket/aws/aws_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,9 @@ def get_devices(
types (Optional[list[AwsDeviceType]]): device type list, default is `None`
QPUs will be searched for all regions and simulators will only be
searched for the region of the current session.
statuses (Optional[list[str]]): device status list, default is `None`
statuses (Optional[list[str]]): device status list, default is `None`. When `None`
is used, RETIRED devices will not be returned. To include RETIRED devices in
the results, add `RETIRED` to the list passed to this parameter.
provider_names (Optional[list[str]]): provider name list, default is `None`
order_by (str): field to order result by, default is `name`.
Accepted values are ['arn', 'name', 'type', 'provider_name', 'status']
Expand Down
6 changes: 5 additions & 1 deletion src/braket/aws/aws_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,9 @@ def search_devices(
arns (Optional[list[str]]): device ARN list, default is `None`.
names (Optional[list[str]]): device name list, default is `None`.
types (Optional[list[str]]): device type list, default is `None`.
statuses (Optional[list[str]]): device status list, default is `None`.
statuses (Optional[list[str]]): device status list, default is `None`. When `None`
is used, RETIRED devices will not be returned. To include RETIRED devices in
the results, add `RETIRED` to the list passed to this parameter.
provider_names (Optional[list[str]]): provider name list, default is `None`.
Returns:
Expand All @@ -645,6 +647,8 @@ def search_devices(
continue
if statuses and result["deviceStatus"] not in statuses:
continue
if statuses is None and result["deviceStatus"] == "RETIRED":
continue
if provider_names and result["providerName"] not in provider_names:
continue
results.append(result)
Expand Down
2 changes: 1 addition & 1 deletion test/integ_tests/test_device_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from braket.aws import AwsDevice
from braket.devices import Devices

RIGETTI_ARN = "arn:aws:braket:::device/qpu/rigetti/Aspen-10"
RIGETTI_ARN = "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3"
IONQ_ARN = "arn:aws:braket:us-east-1::device/qpu/ionq/Harmony"
SIMULATOR_ARN = "arn:aws:braket:::device/quantum-simulator/amazon/sv1"
OQC_ARN = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
Expand Down
19 changes: 19 additions & 0 deletions test/unit_tests/braket/aws/test_aws_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,18 @@ def test_cancel_job_surfaces_errors(exception_type, aws_session):
},
],
),
(
{"statuses": ["RETIRED"]},
[
{
"deviceArn": "arn4",
"deviceName": "name4",
"deviceType": "QPU",
"deviceStatus": "RETIRED",
"providerName": "pname3",
},
],
),
(
{"provider_names": ["pname2"]},
[
Expand Down Expand Up @@ -745,6 +757,13 @@ def test_search_devices(input, output, aws_session):
"deviceStatus": "ONLINE",
"providerName": "pname2",
},
{
"deviceArn": "arn4",
"deviceName": "name4",
"deviceType": "QPU",
"deviceStatus": "RETIRED",
"providerName": "pname3",
},
]
}
]
Expand Down

0 comments on commit 0a11d27

Please sign in to comment.