Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 17 additions & 1 deletion qiskit_ibm_runtime/ibm_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ def jobs(
are included.
program_id: Filter by Program ID.
instance: The service instance to use. Currently only supported for legacy runtime,
and should be in the hub/group/project.
and should be in the hub/group/project format.

Returns:
A list of runtime jobs.
Expand Down Expand Up @@ -1266,6 +1266,22 @@ def least_busy(
) -> ibm_backend.IBMBackend:
"""Return the least busy available backend.

Args:
min_num_qubits: Minimum number of qubits the backend has to have.
instance: The service instance to use. For cloud runtime, this is the Cloud Resource
Name (CRN). For legacy runtime, this is the hub/group/project in that format.
filters: More complex filters, such as lambda functions.
For example::

AccountProvider.backends(
filters=lambda b: b.configuration().quantum_volume > 16)

kwargs: Simple filters that specify a ``True``/``False`` criteria in the
backend configuration, backends status, or provider credentials.
An example to get the operational backends with 5 qubits::

IBMRuntimeService.least_busy(n_qubits=5, operational=True)

Returns:
The backend with the fewest number of pending jobs.

Expand Down
2 changes: 2 additions & 0 deletions test/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@
instance="crn:v1:bluemix:public:quantum-computing:us-east:a/...::",
)


# NamedTemporaryFiles not supported in Windows
@skipIf(os.name == "nt", "Test not supported in Windows")
class TestAccountManager(IBMTestCase):
"""Tests for AccountManager class."""

@temporary_account_config_file(contents={})
@no_envs(["QISKIT_IBM_API_TOKEN"])
def test_save_get(self):
"""Test save and get."""

Expand Down
5 changes: 4 additions & 1 deletion test/test_integration_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,9 @@ def _wait_for_status(self, job, status):

def _get_real_device(self, service):
try:
return service.least_busy(simulator=False).name()
# TODO: Remove filters when ibmq_berlin is removed
return service.least_busy(
simulator=False, filters=lambda b: b.name() != "ibmq_berlin"
).name()
except QiskitBackendNotFoundError:
raise unittest.SkipTest("No real device") # cloud has no real device
1 change: 0 additions & 1 deletion test/test_proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def test_proxy_urls(self, qe_token, qe_url):
test_urls = [
"http://{}:{}".format(ADDRESS, PORT),
"//{}:{}".format(ADDRESS, PORT),
"http:{}:{}".format(ADDRESS, PORT),
"http://user:123@{}:{}".format(ADDRESS, PORT),
]
for proxy_url in test_urls:
Expand Down