Newer
Older
#ifndef MANTID_KERNEL_IREMOTEJOBMANAGER_H
#define MANTID_KERNEL_IREMOTEJOBMANAGER_H
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/DateAndTime.h"
namespace Mantid {
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
/**
Common interface to different remote job managers (job schedulers, web
services, etc. such as MOAB, Platform LSF, or SLURM).
IremoteJobManager objects are (in principle) created via the
RemoteJobManagerFactory. There are several "remote algorithms" in
Mantid: Authenticate, SubmitRemoteJob, QueryRemoteJobStatus,
etc. These algorithms are meant to use this interface to the different
specific implementations. Or, from the opposite angle, the methods of
this interface provide the functionality required by the remote
algorithms in a generic way (with respect to different job schedulers
or underlying mechanisms to handle remote jobs). So-called remote job
manager classes can implement this interface to provide
specialisations for Platform LSF, SLURM, MOAB, the Mantid web service
API, etc.
A typical sequence of calls when you use this interface would be:
1) Authenticate/log-in (authenticate())
2) Do transactions
Where the sequence of calls within a transaction is:
2.1) Start transaction (startRemoteTransaction())
2.2) Do actions
2.3) Stop transaction (stopRemoteTransaction())
In 2.2, several types of actions are possible:
- Submit a job to run on the (remote) compute resource (submitRemoteJob()).
- Get status info for one or all jobs (queryRemoteJob() and
queryAllRemoteJobs()).
- Cancel a job (abortRemoteJob()).
- Get list of available files for a transaction on the compute resource
(queryRemoteFile())
- Upload / download files ( uploadRemoteFile() and downloadRemoteFile()).
Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class MANTID_API_DLL IRemoteJobManager {
public:
virtual ~IRemoteJobManager(){};
/**
* Status and general information about jobs running on (remote)
* compute resources.
*/
struct RemoteJobInfo {
/// Job ID, usually assigned by a job scheduler as an integer
/// number or similar.
std::string id;
/// name of the job, whether given by the user or automatically
/// assigned by the job scheduler
std::string name;
/// Name of the script or executable. Depending on the specific
/// implementation, job scheduler, etc. this can be an
/// 'application' name, a script name or different ways of
/// specifying what is run
std::string runnableName;
/// Last status retrieved (typically: Pending, Running, Exited,
/// etc.). The values are implementation/job scheduler dependent.
std::string status;
/// ID of the transaction where this job is included
std::string transactionID;
/// Date-time of submission. No particular format can be assumed
/// from the specific remote job managers, and some of them may
/// not provide this info
Mantid::Kernel::DateAndTime submitDate;
/// Date-time the job actually started running. No particular
/// format can be assumed
Mantid::Kernel::DateAndTime startDate;
/// Date-time the job finished. No particular format can be
/// assumed
Mantid::Kernel::DateAndTime completionTime;
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
};
/**
* Authenticate or log-in, previous to submitting jobs, up/downloading, etc.
*
* @param username User name or credentials
*
* @param password Password (or other type of authentication token)
* string.
*
* @throws std::invalid_argument If any of the inputs is not set
* properly.
* @throws std::runtime_error If authentication fails
*/
virtual void authenticate(const std::string &username,
const std::string &password) = 0;
/**
* Submit a job (and implicitly request to start it) within a
* transaction.
*
* @param transactionID ID obtained from a startRemoteTransaction()
*
* @param runnable Name of the script or executable for the
* job. This can be a name or path to a file (implementation
* dependent).
*
* @param param Parameters for the job. This is implementation
* dependent and may be a list of command line options, the name of
* a script or configuration file, the contents of a script to run
* or configuration template, etc. For example, for the Mantid web
* service API, this is the content of a python script.
*
* @param taskName (optional) human readable name for this job.
*
* @param numNodes number of nodes to use (optional and dependent on
* implementation and compute resource)
*
* @param coresPerNode number of cores to use in each node (optional
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
* and dependent on implemenation and compute resource)
*
* @return jobID string for the job started (if successful).
*
* @throws std::invalid_argument If any of the inputs is not set
* properly.
* @throws std::runtime_error if job submission fails.
*/
virtual std::string
submitRemoteJob(const std::string &transactionID, const std::string &runnable,
const std::string ¶m, const std::string &taskName = "",
const int numNodes = 1, const int coresPerNode = 1) = 0;
/**
* Get/download a file from the (remote) compute resource.
*
* @param transactionID ID obtained from a startRemoteTransaction()
*
* @param remoteFileName Name of file on the (remote) compute
* resource. This can be a full or relative path or a simple file
* name, depending on implementation.
*
* @param localFileName Where to place the downloaded file on the
* local machine.
*
* @throws std::invalid_argument If any of the inputs is not set
* properly.
* @throws std::runtime_error If the download operation fails
*/
virtual void downloadRemoteFile(const std::string &transactionID,
const std::string &remoteFileName,
const std::string &localFileName) = 0;
/**
* Get information (status etc.) for all running jobs on the remote
* compute resource
*
* @return Status and general info for all the jobs found on the
* (remote) compute resource. Each of them should come identified by
* its ID.
*
* @throws std::runtime_error If the query fails
*/
virtual std::vector<RemoteJobInfo> queryAllRemoteJobs() const = 0;
/**
* Get the list of files available for a transaction at the (remote)
* compute resource.
*
* @param transactionID ID obtained from startRemoteTransaction()
*
* @return The names of all the available files
*
* @throws std::invalid_argument If there's an issue with the
* transaction ID
*
* @throws std::runtime_error If the query fails
*/
virtual std::vector<std::string>
queryRemoteFile(const std::string &transactionID) const = 0;
/**
* Get information (status etc.) for an (in principle) running job
*
* @param jobID ID of a job as obtained from submitRemoteJob()
*
* @return Status and general info for the job requested
*
* @throws std::invalid_argument If there's an issue with the
* job ID
*
* @throws std::runtime_error If the query fails
*/
virtual RemoteJobInfo queryRemoteJob(const std::string &jobID) const = 0;
/**
* Start a transaction before up/downloading files and submitting
* jobs
*
* @return ID of the transaction as produced by the job scheduler
* and/or remote job manager.
*
* @throws std::runtime_error If the transaction creation fails
*/
virtual std::string startRemoteTransaction() = 0;
/**
* Finish a transaction. This implicitly can cancel all the
* operations (jobs) associated with this transaction.
*
* @param transactionID An Id of a transaction, as returned by
* startRemoteTransaction()
*
* @throws std::invalid_argument If there's an issue with the
* transaction ID
*
* @throws std::runtime_error If the stop operation fails
*/
virtual void stopRemoteTransaction(const std::string &transactionID) = 0;
/**
* Cancel a job (expected to be currently running on the remote resource)
*
* @param jobID ID for a job in a transaction, as returned by
* submitRemoteJob()
*
* @throws std::invalid_argument If there's an issue with the
* job ID
* @throws std::runtime_error If the abort/cancel operation fails
*/
virtual void abortRemoteJob(const std::string &jobID) = 0;
/**
* Upload file for a transaction on the rmeote compute resource
*
* @param transactionID ID, as you get them from
* startRemoteTransaction()
*
* @param remoteFileName Name of file on the (remote) compute
* resource. This can be a full or relative path or a simple file
* name, depending on implementation.
*
* @param localFileName Path to the file to upload
*
* @throws std::invalid_argument If there's an issue with the
* arguments passed
* @throws std::runtime_error If the upload fails
*/
virtual void uploadRemoteFile(const std::string &transactionID,
const std::string &remoteFileName,
const std::string &localFileName) = 0;
};
// shared pointer type for the IRemoteJobManager
typedef boost::shared_ptr<IRemoteJobManager> IRemoteJobManager_sptr;
} // namespace Mantid
#endif // MANTID_API_IREMOTEJOBMANAGER_H