Fix AssignedGPUs parsing.

This commit is contained in:
Joachim Meyer 2022-12-16 13:42:04 +01:00
parent 80619b6154
commit 6128b58cbd
2 changed files with 13 additions and 9 deletions

View File

@ -17,10 +17,14 @@ if __name__ == "__main__":
slot_gpu_map = {}
for slot in condor_status:
machine = slot["Machine"]
machine = slot["Machine"].split('.')[0]
gpu_map = {}
if machine in slot_gpu_map:
gpu_map = slot_gpu_map[machine]
else:
slot_gpu_map[machine] = {}
if not "AssignedGPUs" in slot:
continue
gpus = slot["AssignedGPUs"].split(',')
for gpu_id in gpus:
gpu = slot["GPUs_" + gpu_id.strip().replace("-", "_")]

View File

@ -267,12 +267,19 @@ std::string getRemoteHost(std::string_view slot) {
return {++atIt, subIt};
}
std::string removeQuotes(const std::string &value) {
if (value[0] == '"' && value.back() == '"') {
return value.substr(1, value.size() - 2);
}
return value;
}
std::vector<std::string>
CCSyncPlugin::getAccelerators(const CondorJob &job,
const std::string &hostname) {
if (auto hostIt = gpuMap.find(hostname); hostIt != gpuMap.end()) {
if (auto gpuIt = job.find("AssignedGPUs"); gpuIt != job.end()) {
std::istringstream gpuStream{gpuIt->second};
std::istringstream gpuStream{removeQuotes(gpuIt->second)};
std::vector<std::string> gpus;
std::string gpu;
while (std::getline(gpuStream, gpu, ',')) {
@ -313,13 +320,6 @@ bool jobHasRequiredClassAds(const CondorJob &job) {
jobHasClassAd(job, "EnteredCurrentStatus");
}
std::string removeQuotes(const std::string &value) {
if (value[0] == '"' && value.back() == '"') {
return value.substr(1, value.size() - 2);
}
return value;
}
void CCSyncPlugin::sendPostRequest(const std::string &route,
const std::string &body) const noexcept {
dprintf(D_VERBOSE, "POST body: %s\n", body.c_str());