Skip to content

Commit

Permalink
fix request to get queue size from IBMQ in docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
salmma committed Jun 2, 2022
1 parent b32d13e commit d27a8a6
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,18 +381,28 @@ public Optional<Qpu> getQpuByName(String name, String provider, String token) {

public Integer getQueueSizeOfQpu(String qpuName) {
URI ibmqQueueSizeUrl = URI.create(String.format("https://api.quantum-computing.ibm.com/api/Backends/%s/queue/status?", qpuName));
LOG.debug("Requesting IBMQ for queue size");
RestTemplate restTemplate = new RestTemplate();

// fake user agent, as IBMQ blocks Java/1.8
HttpHeaders headers = new HttpHeaders();
headers.set("user-agent", "python-requests/2.27.1");

HttpEntity<String> entity = new HttpEntity<>(headers);

try {
IbmqQpuQueue ibmqQpuQueue = restTemplate.getForObject(ibmqQueueSizeUrl, IbmqQpuQueue.class);
ResponseEntity<IbmqQpuQueue> response =
restTemplate.exchange(ibmqQueueSizeUrl, HttpMethod.GET, entity, IbmqQpuQueue.class);

IbmqQpuQueue ibmqQpuQueue = response.getBody();

if (ibmqQpuQueue != null) {
return ibmqQpuQueue.getLengthQueue();
} else {
return 0;
return 100;
}
} catch (RestClientException e) {
return 0;
return 100;
}
}
}

0 comments on commit d27a8a6

Please sign in to comment.