-
Notifications
You must be signed in to change notification settings - Fork 122
/
QueryRemoteJob2.cpp
103 lines (85 loc) · 4.16 KB
/
QueryRemoteJob2.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
#include "MantidAPI/RemoteJobManagerFactory.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/FacilityInfo.h"
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/NullValidator.h"
#include "MantidKernel/MandatoryValidator.h"
#include "MantidRemoteAlgorithms/QueryRemoteJob2.h"
namespace Mantid {
namespace RemoteAlgorithms {
// Register the algorithm into the Algorithm Factory
DECLARE_ALGORITHM(QueryRemoteJob2)
using namespace Mantid::Kernel;
using namespace Mantid::API;
// A reference to the logger is provided by the base class, it is called g_log.
void QueryRemoteJob2::init() {
// Unlike most algorithms, this one doesn't deal with workspaces....
auto requireValue = boost::make_shared<MandatoryValidator<std::string>>();
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 compute resource to query", Direction::Input);
// The ID of the job we want to query
declareProperty("JobID", "", requireValue, "The ID of the job to query",
Direction::Input);
// Name given to the job
declareProperty("JobName", "", nullValidator, "The name of the job",
Direction::Output);
// Name of the executable/python or other kind of script that was (or will be)
// run
declareProperty(
"ScriptName", "", nullValidator,
"The name of the script or executable that was (or will be) run",
Direction::Output);
// A human readable description of the job's status
declareProperty("JobStatusString", "", nullValidator,
"The current status of the job (example: Queued, Running, "
"Complete, etc..)",
Direction::Output);
// Transaction ID this job is associated with
declareProperty("TransID", "", nullValidator,
"The transaction ID this job was submitted under",
Direction::Output);
// Dates and times for job submit, job start and job complete (may be empty
// depending on the server-side implementation)
declareProperty("SubmitDate", "", nullValidator,
"The date & time the job was submitted (availability is "
"optional and implementation dependent)",
Direction::Output);
declareProperty("StartDate", "", nullValidator,
"The date & time the job actually started executing "
"(availability is optional and implementation dependent)",
Direction::Output);
declareProperty("CompletionDate", "", nullValidator,
"The date & time the job finished (availability is optional "
"and implementation dependent)",
Direction::Output);
declareProperty("CommandLine", "", nullValidator,
"The command line run by this job on the remote compute "
"resource machine(s), which in some cases may provide "
"additional low level information on the environment used "
"(modules loaded, exact versions (paths) of scripts being "
"run, etc.)",
Direction::Output);
}
void QueryRemoteJob2::exec() {
Mantid::API::IRemoteJobManager_sptr jm =
Mantid::API::RemoteJobManagerFactory::Instance().create(
getPropertyValue("ComputeResource"));
Mantid::API::IRemoteJobManager::RemoteJobInfo info =
jm->queryRemoteJob(getPropertyValue("JobID"));
setProperty("JobName", info.name);
setProperty("ScriptName", info.runnableName);
setProperty("JobStatusString", info.status);
setProperty("TransID", info.transactionID);
setProperty("SubmitDate", info.submitDate.toISO8601String());
setProperty("StartDate", info.startDate.toISO8601String());
setProperty("CompletionDate", info.completionTime.toISO8601String());
setProperty("CommandLine", info.cmdLine);
}
} // end namespace RemoteAlgorithms
} // end namespace Mantid