Skip to content
Snippets Groups Projects
Commit e080bd01 authored by Harry Jeffery's avatar Harry Jeffery
Browse files

Merge pull request #12797 from mantidproject/12789_better_way_to_define_AppName_for_LSF

Better way to define the AppName when submitting (remote) jobs to LSF systems
parents d1a9805e b3b64c49
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,10 @@ public: ...@@ -79,6 +79,10 @@ public:
const std::string &localFileName); const std::string &localFileName);
protected: protected:
/// define the "application type" (or "submission form" in the LSF web portal)
virtual std::string guessJobSubmissionAppName(const std::string &runnablePath,
const std::string &jobOptions);
typedef std::map<std::string, std::string> StringToStringMap; typedef std::map<std::string, std::string> StringToStringMap;
/// method that deals with the actual HTTP(S) connection (convenient to /// method that deals with the actual HTTP(S) connection (convenient to
......
...@@ -45,6 +45,9 @@ public: ...@@ -45,6 +45,9 @@ public:
virtual void logout(const std::string &username = std::string()); virtual void logout(const std::string &username = std::string());
private: private:
std::string guessJobSubmissionAppName(const std::string &runnablePath,
const std::string &jobOptions);
/// helper to encode uri components (SCARF username / passwords) /// helper to encode uri components (SCARF username / passwords)
static std::string urlComponentEncode(const std::string &in); static std::string urlComponentEncode(const std::string &in);
......
...@@ -511,7 +511,7 @@ std::string LSFJobManager::submitRemoteJob(const std::string &transactionID, ...@@ -511,7 +511,7 @@ std::string LSFJobManager::submitRemoteJob(const std::string &transactionID,
// /work/imat/webservice_test/tomopy/imat_recon_FBP.py;INPUT_ARGS= // /work/imat/webservice_test/tomopy/imat_recon_FBP.py;INPUT_ARGS=
// /work/imat/scripts/test_;JOB_NAME=01_test_job;OUTPUT_FILE=%J.output;ERROR_FILE= // /work/imat/scripts/test_;JOB_NAME=01_test_job;OUTPUT_FILE=%J.output;ERROR_FILE=
// %J.error" // %J.error"
const std::string appName = "TOMOPY_0_0_3"; const std::string appName = guessJobSubmissionAppName(runnable, param);
// this gets executed (for example via 'exec' or 'python', depending on the // this gets executed (for example via 'exec' or 'python', depending on the
// appName // appName
const std::string boundary = "bqJky99mlBWa-ZuqjC53mG6EzbmlxB"; const std::string boundary = "bqJky99mlBWa-ZuqjC53mG6EzbmlxB";
...@@ -647,6 +647,52 @@ void LSFJobManager::uploadRemoteFile(const std::string &transactionID, ...@@ -647,6 +647,52 @@ void LSFJobManager::uploadRemoteFile(const std::string &transactionID,
} }
} }
/**
* Define or guess the application name (AppName) for a job
* submission. This is an LSF concept that is used for example to
* define different application templates (or submission forms) when
* using the web portal interface. In that interface, compute resource
* admins can define application specific forms (job submission
* templates). An application name normally comes with specific
* (default) values for job options (like output file names, job
* queue, processors/memory limits, etc.) and specific commands to set
* environment variables (like additional library paths or python
* packages paths, etc.). For example, there could be a 'Mantid' app
* name that would be associated with the appropriate environment
* variables, etc. on the remote compute resource.
*
* This generic implementation for any LSF compute resource / job
* manager just returns the 'generic' application name which should
* always be available but might well not be the most appropriate for
* your particular applications. Depending on the server settings
* you'll need to specify particular application names so that LSF
* runs the appropriate environment configuration commands. For an
* example of specialized definition/guess of different app names see
* the SCARF LSF derived class.
*
* @param runnablePath path to the runnable (script, binary, etc.) that will
* be run in a job submission - this can be used to guess what app name/
* type is needed.
*
* @param jobOptions options submitted with the runnable (which can be
* command line options, content of a script, etc.) - this info can also be
* useful to define the AppName (to find out for example that a particular
* tool version is required)
*
* @returns Application name (server specific, contact your
* admin). This generic implementation ignores the inputs and always
* returns the 'generic' app name which should be available in any LSF
* system. This will go in the <AppName> parameter of the RESTful queries.
*/
std::string
LSFJobManager::guessJobSubmissionAppName(const std::string &runnablePath,
const std::string &jobOptions) {
UNUSED_ARG(runnablePath);
UNUSED_ARG(jobOptions);
return "generic";
}
/** /**
* Send the HHTP(S) request required to perform one of the actions. * Send the HHTP(S) request required to perform one of the actions.
* *
......
...@@ -232,11 +232,32 @@ std::string SCARFLSFJobManager::urlComponentEncode(const std::string &in) { ...@@ -232,11 +232,32 @@ std::string SCARFLSFJobManager::urlComponentEncode(const std::string &in) {
out << c; out << c;
} else { } else {
// Any non unreserved is pct-escaped // Any non unreserved is pct-escaped
out << '%' << std::setw(2) << int((unsigned char) c); out << '%' << std::setw(2) << int((unsigned char)c);
} }
} }
return out.str(); return out.str();
} }
std::string
SCARFLSFJobManager::guessJobSubmissionAppName(const std::string &runnablePath,
const std::string &jobOptions)
{
UNUSED_ARG(jobOptions);
// Two applications are for now registered and being used on SCARF:
// TOMOPY_0_0_3, PYASTRATOOLBOX_1_1
std::string appName = "TOMOPY_0_0_3";
// Basic guess of the app that we might really need. Not
// fixed/unstable at the moment
if (runnablePath.find("astra-2d-FBP") != std::string::npos
||
runnablePath.find("astra-3d-SIRT3D") != std::string::npos ) {
appName = "PYASTRATOOLBOX_1_1";
}
return appName;
}
} // end namespace RemoteJobManagers } // end namespace RemoteJobManagers
} // end namespace Mantid } // end namespace Mantid
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment