Commit 63199e1f authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

adding checks for needed files, setup user_id as input from text file


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent eda85b26
......@@ -190,7 +190,7 @@ void QCSAccelerator::execute(
// Run execute_qpu_request, get job-id
qcs::QPURequest qpuReq(prog, get_uuid());
qcs::QPURequestParams qpuParams(qpuReq);
qcs::QPURequestParams qpuParams(qpuReq, user_id);
qcs::RPCRequestQPURequest r2(get_uuid(), qpuParams);
auto unpackedData2 = request(r2, qpu_socket);
std::stringstream ss2;
......
......@@ -102,6 +102,7 @@ protected:
std::string client_secret = "";
std::string server_public = "";
std::string auth_token = "";
std::string user_id = "";
template <typename T>
msgpack::unpacked request(T &requestType, zmq::socket_t &socket) {
......@@ -120,6 +121,18 @@ protected:
}
void getSocketURLs() {
if (!xacc::directoryExists(std::getenv("HOME") + std::string("/.qcs"))) {
xacc::error("[QCS] $HOME/.qcs directory does not exists.");
}
if (!xacc::fileExists(std::getenv("HOME") + std::string("/.qcs_config"))) {
xacc::error("[QCS] $HOME/.qcs_config file does not exist.");
}
if (!xacc::fileExists(std::getenv("HOME") +
std::string("/.qcs/user_auth_token"))) {
xacc::error("[QCS] $HOME/.qcs/user_auth_token file does not exist.");
}
std::ifstream stream(std::getenv("HOME") +
std::string("/.qcs/user_auth_token"));
std::string contents((std::istreambuf_iterator<char>(stream)),
......@@ -150,7 +163,7 @@ protected:
{"Authorization",
"Bearer " + auth_json["access_token"].get<std::string>()}};
auth_token = auth_json["access_token"].get<std::string>();
// std::cout << json_data.length() << "\n";
// std::cout << json_data << "\n";
auto resp = this->post("https://dispatch.services.qcs.rigetti.com",
......@@ -175,6 +188,19 @@ protected:
if (qpu_compiler_endpoint.empty() || qpu_endpoint.empty()) {
xacc::error("QCS Error: Cannot find qpu_compiler or qpu endpoint.");
}
std::ifstream stream2(std::getenv("HOME") + std::string("/.qcs_config"));
std::string contents2((std::istreambuf_iterator<char>(stream2)),
std::istreambuf_iterator<char>());
auto lines = xacc::split(contents2, '\n');
for (auto &l : lines) {
if (l.find("user_id") != std::string::npos) {
auto id = xacc::split(l, '=')[1];
xacc::trim(id);
user_id = id;
break;
}
}
}
public:
......
......@@ -108,10 +108,10 @@ class QPURequest {
class QPURequestParams {
protected:
QPURequest& request;
std::string user = "ccde1544-c4bc-40f0-9914-010be987dc0d";
std::string user = "";
int priority = 1;
public:
QPURequestParams(QPURequest &a) : request(a) {}
QPURequestParams(QPURequest &a, std::string& uid) : request(a), user(uid) {}
MSGPACK_DEFINE_MAP(MSGPACK_NVP("request", request), user, priority);
};
......
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