Skip to content

Commit

Permalink
Merge branch 'master' into 10903_ida_abs_corr_tab
Browse files Browse the repository at this point in the history
Refs #10903

[ci skip]
  • Loading branch information
DanNixon committed Apr 1, 2015
2 parents b9e87e2 + ffb7163 commit 2c003ff
Show file tree
Hide file tree
Showing 138 changed files with 10,625 additions and 6,607 deletions.
@@ -1,5 +1,5 @@
Name: mantid-developer
Version: 1.9
Version: 1.10
Release: 1%{?dist}
Summary: Meta Package to install dependencies for Mantid Development

Expand Down Expand Up @@ -30,7 +30,7 @@ Requires: poco-devel
Requires: PyQt4-devel
Requires: python-devel
Requires: python-ipython >= 1.1
Conflicts: python-ipython >= 2.0
%{?el6:Conflicts: python-ipython >= 2.0}
Requires: python-pip
Requires: python-sphinx
Requires: qscintilla-devel
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/API/CMakeLists.txt
Expand Up @@ -106,6 +106,7 @@ set ( SRC_FILES
src/PropertyManagerDataService.cpp
src/PropertyNexus.cpp
src/RefAxis.cpp
src/RemoteJobManagerFactory.cpp
src/Run.cpp
src/Sample.cpp
src/SampleEnvironment.cpp
Expand Down Expand Up @@ -271,6 +272,7 @@ set ( INC_FILES
inc/MantidAPI/PropertyManagerDataService.h
inc/MantidAPI/PropertyNexus.h
inc/MantidAPI/RefAxis.h
inc/MantidAPI/RemoteJobManagerFactory.h
inc/MantidAPI/Run.h
inc/MantidAPI/Sample.h
inc/MantidAPI/SampleEnvironment.h
Expand Down Expand Up @@ -367,6 +369,7 @@ set ( TEST_FILES
ProjectionTest.h
PropertyManagerDataServiceTest.h
PropertyNexusTest.h
RemoteJobManagerFactoryTest.h
RunTest.h
SampleEnvironmentTest.h
SampleShapeValidatorTest.h
Expand Down
4 changes: 4 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IFuncMinimizer.h
Expand Up @@ -69,6 +69,10 @@ class MANTID_API_DLL IFuncMinimizer : public Kernel::PropertyManager {
/// Get value of cost function
virtual double costFunctionVal() = 0;

/// Finalize minimization, eg store additional outputs
virtual void finalize() {}


protected:
/// Error string.
std::string m_errorString;
Expand Down
Expand Up @@ -137,7 +137,7 @@ class MANTID_API_DLL IRemoteJobManager {
* @param numNodes number of nodes to use (optional and dependent on
* implementation and compute resource)
*
* @parm coresPerNode number of cores to use in each node (optional
* @param coresPerNode number of cores to use in each node (optional
* and dependent on implemenation and compute resource)
*
* @return jobID string for the job started (if successful).
Expand Down
124 changes: 124 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h
@@ -0,0 +1,124 @@
#ifndef MANTID_API_REMOTEJOBMANAGERFACTORY_H_
#define MANTID_API_REMOTEJOBMANAGERFACTORY_H_

#include "MantidAPI/DllConfig.h"
#include "MantidAPI/IRemoteJobManager.h"
#include "MantidKernel/DynamicFactory.h"
#include "MantidKernel/SingletonHolder.h"

namespace Mantid {
namespace API {
/**
The RemoteJobManagerFactory handles the creation of remote job
managers specialised for different types of compute resources (for
different underlying job schedulers, web services, front-ends,
etc.). Through the create method of this class a shared pointer to a
remote job manager object can be obtained for a particular compute
resource.
The remote job managers built by this factory know how to start and
stop jobs, upload/download files, etc. for the compute resource
specified when creating the job manager (as long as the compute
resource is found for the current facility in the facilities
definition file).
Remote job manager classes must be registered/subscribe using the
macro DECLARE_REMOTEJOBMANAGER (the same way you use DECLARE_ALGORITHM
for algorithms and remote algorithms).
As the algorithm, workspace and other factories in Mantid, this
factory is implemented as a singleton class. Typical usages:
Mantid::API::IRemoteJob|Manager_sptr jobManager =
Mantid::API::RemoteJobManagerFactory::Instance().create("Fermi");
Mantid::API::IRemoteJob|Manager_sptr jobManager =
Mantid::API::RemoteJobManagerFactory::Instance().create("SCARF@STFC");
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 RemoteJobManagerFactoryImpl
: public Kernel::DynamicFactory<IRemoteJobManager> {
public:
/// Create a remote job manager that will know how to use the
/// underlying mechanism that suits the compute resource passed
IRemoteJobManager_sptr create(const std::string &computeResourceName) const;

/// alternative (lower level) create where the specific type of
/// manager and base URL are directly given
IRemoteJobManager_sptr create(const std::string baseURL,
const std::string jobManagerType) const;

private:
/// So that the singleton can be created (cons/destructor are private)
friend struct Mantid::Kernel::CreateUsingNew<RemoteJobManagerFactoryImpl>;

/// Private Constructor for singleton class
RemoteJobManagerFactoryImpl();
/// Disallow copy construction
RemoteJobManagerFactoryImpl(const RemoteJobManagerFactoryImpl &);
/// Disallow assignment
RemoteJobManagerFactoryImpl &operator=(const RemoteJobManagerFactoryImpl &);

/// Private Destructor
virtual ~RemoteJobManagerFactoryImpl();

// Unhide the inherited create method but make it private
using Kernel::DynamicFactory<IRemoteJobManager>::create;
};

/// Forward declaration of a specialisation of SingletonHolder for
/// RemoteJobManagerFactoryImpl (needed for dllexport) and a typedef for it.
#ifdef _WIN32
// this breaks new namespace declaraion rules; need to find a better fix
template class MANTID_API_DLL
Mantid::Kernel::SingletonHolder<RemoteJobManagerFactoryImpl>;
#endif /* _WIN32 */

// The factory is just a specialisation of SingletonHolder
typedef MANTID_API_DLL Mantid::Kernel::SingletonHolder<
RemoteJobManagerFactoryImpl> RemoteJobManagerFactory;

} // namespace API
} // namespace Mantid

/* Macro to register (remote job manager) classes into the factory. As
* with the equivalent macros of the workspace factory or the
* algorithm factory, this creates a global object in an anonymous
* namespace. The object itself does nothing, but the comma operator
* is used in the call to its constructor to effect a call to the
* factory's subscribe method.
*
* You need to use this in every remote job manager. For example:
* DECLARE_REMOTEJOBMANAGER(MantidWebServiceAPI)
* DECLARE_REMOTEJOBMANAGER(SCARFLSFJobManager)
*/
#define DECLARE_REMOTEJOBMANAGER(classname) \
namespace { \
Mantid::Kernel::RegistrationHelper register_ws_##classname( \
((Mantid::API::RemoteJobManagerFactory::Instance().subscribe<classname>( \
#classname)), \
0)); \
}

#endif // MANTID_API_REMOTEJOBMANAGERFACTORY_H_
88 changes: 88 additions & 0 deletions Code/Mantid/Framework/API/src/RemoteJobManagerFactory.cpp
@@ -0,0 +1,88 @@
#include "MantidAPI/RemoteJobManagerFactory.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/FacilityInfo.h"
#include "MantidKernel/Logger.h"

namespace Mantid {
namespace API {
namespace {
/// static logger object
Kernel::Logger g_log("RemoteJobManagerFactory");
}

/// Private constructor, singleton class
RemoteJobManagerFactoryImpl::RemoteJobManagerFactoryImpl()
: Mantid::Kernel::DynamicFactory<IRemoteJobManager>() {
g_log.debug() << "RemoteJobManager factory created." << std::endl;
}

/**
* Private destructor, prevent client code from using this.
*/
RemoteJobManagerFactoryImpl::~RemoteJobManagerFactoryImpl() {}

/**
* Create a remote algorithm with the underlying mechanism that suits
* the compute resource passed.
*
* @param computeResourceName Name of a (remote) compute resource
*
* @throw std::invalid_argument If no resource is found by the name
* given (compute resources are looked up in the facilities definition
* (XML) file for the current facility.
*/
IRemoteJobManager_sptr RemoteJobManagerFactoryImpl::create(
const std::string &computeResourceName) const {
IRemoteJobManager_sptr jm;

if (computeResourceName.empty())
return jm;

Mantid::Kernel::ComputeResourceInfo cr =
Mantid::Kernel::ConfigService::Instance().getFacility().computeResource(
computeResourceName);

// this is the default. It could be "MantidWebServiceAPI", "LSF",
// "SCARFLSF", "MOAB", etc.
std::string type = "MantidWebServiceAPIJobManager";
std::string fdfType = cr.remoteJobManagerType();
if (!fdfType.empty())
type = fdfType;
return create(cr.baseURL(), type);
}

/**
* Lower level create method that makes a remote algorithm given a
* base URL and the type of remote job manager.
*
* @param baseURL URL where the resource is accessible
*
* @param jobManagerType Type/class that can handle this remote
* compute resource (string names as used in the facilities definition
* file, for example: MantidWebServiceAPIJobManager).
*
* @throw std::invalid_argument If there is an issue with the URL or
* the type (for example the type is not recognized).
*/
Mantid::API::IRemoteJobManager_sptr
RemoteJobManagerFactoryImpl::create(const std::string baseURL,
const std::string jobManagerType) const {
Mantid::API::IRemoteJobManager_sptr jm;

// use the inherited/generic create method
try {
jm = this->create(jobManagerType);
} catch (Kernel::Exception::NotFoundError &e) {
throw Kernel::Exception::NotFoundError(
"RemoteJobManagerFactory: failed to create a remote job manager of "
"type (class) '" +
jobManagerType + "' with base URL " + baseURL +
". Error description: " + e.what(),
jobManagerType);
}

return jm;
}

} // namespace API
} // Namespace Mantid

0 comments on commit 2c003ff

Please sign in to comment.