-
Notifications
You must be signed in to change notification settings - Fork 122
/
QueryAllRemoteJobs2.cpp
110 lines (96 loc) · 4.75 KB
/
QueryAllRemoteJobs2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "MantidAPI/RemoteJobManagerFactory.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/FacilityInfo.h"
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/NullValidator.h"
#include "MantidRemoteAlgorithms/QueryAllRemoteJobs2.h"
namespace Mantid {
namespace RemoteAlgorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(QueryAllRemoteJobs2)
using namespace Mantid::Kernel;
// A reference to the logger is provided by the base class, it is called g_log.
void QueryAllRemoteJobs2::init() {
// Unlike most algorithms, this one doesn't deal with workspaces....
auto nullValidator = boost::make_shared<NullValidator>();
// Compute Resources
std::vector<std::string> computes = Mantid::Kernel::ConfigService::Instance()
.getFacility()
.computeResources();
declareProperty("ComputeResource", "",
boost::make_shared<StringListValidator>(computes),
"The name of the remote computer to query", Direction::Input);
// Mantid can't store arbitrary structs in its properties, so we're going to
// declare several array properties for different pieces of data. Values from
// the same array index are for the same job.
declareProperty(make_unique<ArrayProperty<std::string>>(
"JobID", nullValidator, Direction::Output),
"ID string for the job(s)");
declareProperty(make_unique<ArrayProperty<std::string>>(
"JobStatusString", nullValidator, Direction::Output),
"Description of the job's current status (Queued, Running, "
"Complete, etc..)");
declareProperty(make_unique<ArrayProperty<std::string>>(
"JobName", nullValidator, Direction::Output),
"Name of the job (specified when the job was submitted)");
declareProperty(make_unique<ArrayProperty<std::string>>(
"ScriptName", nullValidator, Direction::Output),
"The name of the script (python, etc.) or other type of "
"executable that the job runs");
declareProperty(make_unique<ArrayProperty<std::string>>(
"TransID", nullValidator, Direction::Output),
"The ID of the transaction that owns the job");
// Times for job submit, job start and job complete (may be empty depending
// on the server-side implementation)
declareProperty(make_unique<ArrayProperty<std::string>>(
"SubmitDate", nullValidator, Direction::Output),
"The date & time the job was submitted");
declareProperty(make_unique<ArrayProperty<std::string>>(
"StartDate", nullValidator, Direction::Output),
"The date & time the job actually started executing");
declareProperty(make_unique<ArrayProperty<std::string>>(
"CompletionDate", nullValidator, Direction::Output),
"The date & time the job finished");
declareProperty(make_unique<ArrayProperty<std::string>>(
"CommandLine", nullValidator, Direction::Output),
"The command line run by this job on the remote compute "
"resource machine(s)");
}
void QueryAllRemoteJobs2::exec() {
Mantid::API::IRemoteJobManager_sptr jm =
Mantid::API::RemoteJobManagerFactory::Instance().create(
getPropertyValue("ComputeResource"));
std::vector<Mantid::API::IRemoteJobManager::RemoteJobInfo> infos =
jm->queryAllRemoteJobs();
std::vector<std::string> jobIds;
std::vector<std::string> jobStatusStrs;
std::vector<std::string> jobNames;
std::vector<std::string> runNames;
std::vector<std::string> transIds;
std::vector<std::string> submitDates;
std::vector<std::string> startDates;
std::vector<std::string> completionDates;
std::vector<std::string> cmdLine;
for (auto &info : infos) {
jobIds.push_back(info.id);
jobNames.push_back(info.name);
jobStatusStrs.push_back(info.status);
transIds.push_back(info.transactionID);
runNames.push_back(info.runnableName);
submitDates.push_back(info.submitDate.toISO8601String());
startDates.push_back(info.startDate.toISO8601String());
completionDates.push_back(info.completionTime.toISO8601String());
cmdLine.push_back(info.cmdLine);
}
setProperty("JobID", jobIds);
setProperty("JobStatusString", jobStatusStrs);
setProperty("JobName", jobNames);
setProperty("ScriptName", runNames);
setProperty("TransID", transIds);
setProperty("SubmitDate", submitDates);
setProperty("StartDate", startDates);
setProperty("CompletionDate", completionDates);
setProperty("CommandLine", cmdLine);
}
} // end namespace RemoteAlgorithms
} // end namespace Mantid