Commit ff34c92a authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Handle honeywell backend status



Currently, we terminate if the backend is not online.
This can be inconvenient for batch mode (vector<Composite>) since the backend can go into 'in maintenance' status.

Hence, changed the logic to only terminate if the status is 'offline' (according to the calendar).
Otherwise, try polling.
Signed-off-by: Nguyen, Thien Minh's avatarThien Nguyen <nguyentm@ornl.gov>
parent 681830d1
......@@ -167,13 +167,24 @@ void HoneywellAccelerator::execute(
"Please specify a honeywell backend in your getAccelerator() call.");
}
auto qasm = getNativeCode(circuit);
auto backend_status = get(url, "machine/"+backend, generateRequestHeader());
auto status_J = nlohmann::json::parse(backend_status);
if (status_J["state"] != "online") {
xacc::error("Cannot run on " + backend + ", it is not online.");
while (true) {
auto backend_status =
get(url, "machine/" + backend, generateRequestHeader());
auto status_J = nlohmann::json::parse(backend_status);
// xacc::info("\nHoneywell status:\n" + backend_status);
// If offline, terminate
if (status_J["state"] == "offline") {
xacc::error("Cannot run on " + backend + ", it is offline.");
}
// If online, continue to run
if (status_J["state"] == "online") {
break;
}
// If status = 'in maintenance', wait for a bit and try again
xacc::info("Honeywell is '" + std::string(status_J["state"]) +
"', waiting for a bit...");
std::this_thread::sleep_for(std::chrono::seconds(60));
}
xacc::info("\nHoneywell sending qasm:\n" + qasm);
nlohmann::json j;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment