Commit 10d21cfb authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Refs #8913 Fix turning off algorithm history.

parent 2a5e9133
......@@ -207,6 +207,7 @@ public:
bool isChild() const;
void setChild(const bool isChild);
void enableHistoryRecordingForChild(const bool on);
bool isRecordingHistoryForChild() { return m_recordHistoryForChild; };
void setAlwaysStoreInADS(const bool doStore);
void setRethrows(const bool rethrow);
......@@ -271,7 +272,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 bool recordHistory = false);
const double endProgress = -1., const bool enableLogging=true, const int& version = -1);
/// 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 bool recordHistory = true);
const double endProgress = -1., const bool enableLogging=true, const int& version = -1);
void setLoadAlg(const std::string & alg);
void setLoadAlgFileProp(const std::string & filePropName);
void setAccumAlg(const std::string & alg);
......
......@@ -806,10 +806,9 @@ 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 recordHistory)
const bool enableLogging, const int& version)
{
Algorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged(name,version);
alg->enableHistoryRecordingForChild(recordHistory);
//set as a child
alg->setChild(true);
alg->setLogging(enableLogging);
......
......@@ -32,6 +32,7 @@ namespace API
m_accumulateAlg = "Plus";
m_loadAlgFileProp = "Filename";
m_useMPI = false;
enableHistoryRecordingForChild(true);
}
//----------------------------------------------------------------------------------------------
......@@ -58,12 +59,12 @@ namespace API
* @return shared pointer to the newly created algorithm object
*/
boost::shared_ptr<Algorithm> DataProcessorAlgorithm::createChildAlgorithm(const std::string& name, const double startProgress,
const double endProgress, const bool enableLogging, const int& version, const bool recordHistory)
const double endProgress, const bool enableLogging, const int& version)
{
//call parent method to create the child algorithm
auto alg = Algorithm::createChildAlgorithm(name, startProgress, endProgress, enableLogging, version, recordHistory);
if (recordHistory)
auto alg = Algorithm::createChildAlgorithm(name, startProgress, endProgress, enableLogging, version);
alg->enableHistoryRecordingForChild(this->isRecordingHistoryForChild());
if(this->isRecordingHistoryForChild())
{
//pass pointer to the history object created in Algorithm to the child
alg->trackAlgorithmHistory(m_history);
......
......@@ -117,7 +117,8 @@ public:
void exec()
{
const bool recordHistory = static_cast<bool>(getProperty("RecordHistory"));
auto alg = createChildAlgorithm("NestedAlgorithm", -1., -1., true, -1, recordHistory);
auto alg = createChildAlgorithm("NestedAlgorithm");
alg->enableHistoryRecordingForChild(recordHistory);
alg->initialize();
alg->execute();
......
......@@ -54,11 +54,14 @@ 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,arg("recordHistory")=false), "Creates and intializes a named child algorithm. Output workspaces are given a dummy name.")
arg("enableLogging")=true,arg("version")=-1), "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") = "")))
.def("enableHistoryRecordingForChild", &Algorithm::enableHistoryRecordingForChild,
(args("on")), "Turns history recording on or off for an algorithm.")
.def("declareProperty", (declarePropertyType2)&PythonAlgorithm::declarePyAlgProperty,
declarePropertyType2_Overload((arg("self"), arg("name"), arg("defaultValue"), arg("validator")=object(), arg("doc")="",arg("direction")=Direction::Input),
"Declares a named property where the type is taken from "
......
......@@ -22,10 +22,6 @@ void export_DataProcessorAlgorithm()
class_<DataProcessorAlgorithm, bases<Algorithm>, boost::shared_ptr<DataProcessorAdapter>,
boost::noncopyable>("DataProcessorAlgorithm", "Base class workflow-type algorithms")
.def("createChildAlgorithm", &Algorithm::createChildAlgorithm,
(arg("name"),arg("startProgress")=-1.0,arg("endProgress")=-1.0,
arg("enableLogging")=true,arg("version")=-1,arg("recordHistory")=true), "Creates and intializes a named child algorithm. Output workspaces are given a dummy name.")
.def("setLoadAlg", &DataProcessorAdapter::setLoadAlgProxy,
"Set the name of the algorithm called using the load() method [Default=Load]")
......
......@@ -23,7 +23,7 @@ class ParentAlg(DataProcessorAlgorithm):
def PyExec(self):
ws_name = self.getProperty("OutputWorkspace").value
alg = self.createChildAlgorithm('ChildAlg', recordHistory=False)
alg = self.createChildAlgorithm('ChildAlg')
alg.initialize()
args = {}
kwargs = {}
......@@ -70,13 +70,15 @@ class AlgorithmHistoryTest(unittest.TestCase):
alg = AlgorithmManager.createUnmanaged('ParentAlg')
alg.initialize()
alg.setChild(True)
alg.enableHistoryRecordingForChild(False)
alg.setProperty("OutputWorkspace", ws_name)
alg.execute()
history = mtd[ws_name].getHistory()
history = alg.getProperty("OutputWorkspace").value.getHistory()
alg_hists = history.getAlgorithmHistories()
self.assertEquals(history.size(), 1)
self.assertEquals(len(alg_hists), 1)
self.assertEquals(history.size(), 0)
self.assertEquals(len(alg_hists), 0)
if __name__ == '__main__':
unittest.main()
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