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
2 changes: 1 addition & 1 deletion include/mqss/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MQSSClient {
private:
std::unique_ptr<JobResult> waitForJobResult(const JobRequest& job,
size_t poll_seconds);

bool mIsHpc;
std::unique_ptr<MQSSBaseClient> mClient;

public:
Expand Down
6 changes: 3 additions & 3 deletions include/mqss/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class JobRequest {

public:
virtual ~JobRequest() = default;
virtual nlohmann::json toJson() const = 0;
virtual nlohmann::json toJson(bool isHpc) const = 0;
virtual std::string getPath() const = 0;
std::string getUuid() const { return mUuid; }
void setUuid(const std::string& uuid) { mUuid = uuid; }
Expand Down Expand Up @@ -70,7 +70,7 @@ class CircuitJobRequest : public JobRequest {
void setQueued(bool queued) { mQueued = queued; }
bool isQueued() const { return mQueued; }

nlohmann::json toJson() const;
nlohmann::json toJson(bool isHpc) const;

std::string getPath() const { return "job"; }
};
Expand Down Expand Up @@ -102,7 +102,7 @@ class HamiltonianJobRequest : public JobRequest {
}
std::string getCoefficientsString() const { return mCoefficientsStr; }

nlohmann::json toJson() const;
nlohmann::json toJson(bool isHpc) const;

std::string getPath() const { return "hamiltonian_job"; }
};
Expand Down
5 changes: 3 additions & 2 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
using namespace mqss::client;
// GCOVR_EXCL_START
MQSSClient::MQSSClient(const std::string& token,
const std::string& url_or_queue, bool is_hpc) {
const std::string& url_or_queue, bool is_hpc)
: mIsHpc(is_hpc) {
if (is_hpc) {
mClient = std::make_unique<MQSSHPCClient>(token, url_or_queue);
} else {
Expand Down Expand Up @@ -67,7 +68,7 @@ MQSSClient::getResourceInfo(const std::string& resource) const {
}
std::optional<std::string> MQSSClient::submitJob(JobRequest& job) {
std::string path = job.getPath();
std::string result = mClient->post(path, job.toJson());
std::string result = mClient->post(path, job.toJson(mIsHpc));
if (result.empty() || !nlohmann::json::accept(result))
return std::nullopt;

Expand Down
22 changes: 13 additions & 9 deletions src/job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@

using namespace mqss::client;

nlohmann::json CircuitJobRequest::toJson() const {

return {{"circuit", mCircuit},
{"circuit_format", mCircuitFormat},
{"resource_name", mResourceName},
{"shots", mShots},
{"no_modify", mNoModify},
{"queued", mQueued}};
nlohmann::json CircuitJobRequest::toJson(bool isHpc) const {
nlohmann::json circuit = mCircuit;

if (isHpc) {
circuit = nlohmann::json::array({mCircuit});
}

return {
{"circuit", std::move(circuit)}, {"circuit_format", mCircuitFormat},
{"resource_name", mResourceName}, {"shots", mShots},
{"no_modify", mNoModify}, {"queued", mQueued},
};
}

CircuitJobRequest::CircuitJobRequest(std::string circuit,
Expand All @@ -57,7 +61,7 @@ HamiltonianJobRequest::HamiltonianJobRequest(std::string resourceName,
mInteractionStr(std::move(interactionStr)),
mCoefficientsStr(std::move(coefficientsStr)) {}

nlohmann::json HamiltonianJobRequest::toJson() const {
nlohmann::json HamiltonianJobRequest::toJson(bool isHpc) const {

return {{"resource_name", mResourceName},
{"interaction_str", mInteractionStr},
Expand Down
4 changes: 3 additions & 1 deletion src/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ Resource::Resource(std::string name, unsigned qubitCount, bool online,
Resource::Resource(const nlohmann::json& json) {

std::string name = json.value("name", "");
unsigned qubitCount = json.value("qubits", 0);
unsigned qubitCount = json.contains("qubits") && json["qubits"].is_number()
? json["qubits"].get<unsigned>()
: 0;
bool online = json.value("online", false);

std::vector<std::vector<int>> couplingMap =
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/c++/job_integration_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#define MQSS_HPC_QUEUENAME std::getenv("MQSS_HPC_QUEUENAME")
#define MQSS_API_TOKEN std::getenv("MQSS_API_TOKEN")
#define MQSS_API_URL "https://portal-test.quantum.lrz.de:4000/v1"
#define MQSS_API_URL "https://portal.quantum.lrz.de:4000/v1/"

struct ClientCtorParam {
std::string token;
Expand Down
Loading