Commit 897f6072 authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Refs #8913 Pass history recording parameter as arg to createChildAlg.

parent 07c31484
......@@ -207,7 +207,6 @@ public:
bool isChild() const;
void setChild(const bool isChild);
void enableHistoryRecordingForChild(const bool on);
bool isRecordingHistoryForChild();
void setAlwaysStoreInADS(const bool doStore);
void setRethrows(const bool rethrow);
......@@ -272,7 +271,7 @@ public:
//@}
virtual boost::shared_ptr<Algorithm> createChildAlgorithm(const std::string& name, const double startProgress = -1.,
const double endProgress = -1., const bool enableLogging=true, const int& version = -1);
const double endProgress = -1., const bool enableLogging=true, const int& version = -1, const bool recordHistory = false);
/// set whether we wish to track the child algorithm's history and pass it the parent object to fill.
void trackAlgorithmHistory(boost::shared_ptr<AlgorithmHistory> parentHist);
......
......@@ -47,7 +47,7 @@ public:
protected:
virtual boost::shared_ptr<Algorithm> createChildAlgorithm(const std::string& name, const double startProgress = -1.,
const double endProgress = -1., const bool enableLogging=true, const int& version = -1);
const double endProgress = -1., const bool enableLogging=true, const int& version = -1, const bool recordHistory = true);
void setLoadAlg(const std::string & alg);
void setLoadAlgFileProp(const std::string & filePropName);
void setAccumAlg(const std::string & alg);
......
......@@ -163,16 +163,6 @@ namespace Mantid
m_recordHistoryForChild = on;
}
/**
* Get the state of the history recording flag. Only applicable for
* child algorithms.
* @return The state of the flag
*/
bool Algorithm::isRecordingHistoryForChild()
{
return m_recordHistoryForChild;
}
/** Do we ALWAYS store in the AnalysisDataService? This is set to true
* for python algorithms' child algorithms
*
......@@ -811,9 +801,10 @@ namespace Mantid
* @return shared pointer to the newly created algorithm object
*/
Algorithm_sptr Algorithm::createChildAlgorithm(const std::string& name, const double startProgress, const double endProgress,
const bool enableLogging, const int& version)
const bool enableLogging, const int& version, const bool recordHistory)
{
Algorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged(name,version);
alg->enableHistoryRecordingForChild(recordHistory);
//set as a child
alg->setChild(true);
alg->setLogging(enableLogging);
......
......@@ -32,7 +32,6 @@ namespace API
m_accumulateAlg = "Plus";
m_loadAlgFileProp = "Filename";
m_useMPI = false;
enableHistoryRecordingForChild(true);
}
//----------------------------------------------------------------------------------------------
......@@ -44,12 +43,12 @@ namespace API
//----------------------------------------------------------------------------------------------
boost::shared_ptr<Algorithm> DataProcessorAlgorithm::createChildAlgorithm(const std::string& name, const double startProgress,
const double endProgress, const bool enableLogging, const int& version)
const double endProgress, const bool enableLogging, const int& version, const bool recordHistory)
{
//call parent method to create the child algorithm
auto alg = Algorithm::createChildAlgorithm(name, startProgress, endProgress, enableLogging, version);
if (isRecordingHistoryForChild())
auto alg = Algorithm::createChildAlgorithm(name, startProgress, endProgress, enableLogging, version, recordHistory);
if (recordHistory)
{
//pass pointer to the history object created in Algorithm to the child
alg->trackAlgorithmHistory(m_history);
......
......@@ -112,10 +112,12 @@ public:
{
declareProperty(new WorkspaceProperty<MatrixWorkspace>("InputWorkspace", "", Direction::Input));
declareProperty(new WorkspaceProperty<MatrixWorkspace>("OutputWorkspace","", Direction::Output));
declareProperty("RecordHistory", true, Direction::Input);
}
void exec()
{
auto alg = createChildAlgorithm("NestedAlgorithm");
const bool recordHistory = static_cast<bool>(getProperty("RecordHistory"));
auto alg = createChildAlgorithm("NestedAlgorithm", -1., -1., true, -1, recordHistory);
alg->initialize();
alg->execute();
......@@ -186,8 +188,8 @@ public:
TopLevelAlgorithm alg;
alg.initialize();
alg.setRethrows(true);
alg.enableHistoryRecordingForChild(false);
alg.setProperty("InputWorkspace", input);
alg.setProperty("RecordHistory", false);
alg.setPropertyValue("OutputWorkspace", "test_output_workspace");
TS_ASSERT_THROWS_NOTHING( alg.execute() );
......
......@@ -54,7 +54,7 @@ void export_leaf_classes()
.def("setOptionalMessage", &Algorithm::setOptionalMessage)
.def("createChildAlgorithm", &Algorithm::createChildAlgorithm,
(arg("name"),arg("startProgress")=-1.0,arg("endProgress")=-1.0,
arg("enableLogging")=true,arg("version")=-1), "Creates and intializes a named child algorithm. Output workspaces are given a dummy name.")
arg("enableLogging")=true,arg("version")=-1,arg("recordHistory")=false), "Creates and intializes a named child algorithm. Output workspaces are given a dummy name.")
.def("declareProperty", (declarePropertyType1)&PythonAlgorithm::declarePyAlgProperty,
declarePropertyType1_Overload((arg("self"), arg("prop"), arg("doc") = "")))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment