From 85724e66af676c36ea94e681040cdc37bc117758 Mon Sep 17 00:00:00 2001 From: Janik Zikovsky <zikovskyjl@ornl.gov> Date: Wed, 8 Feb 2012 16:53:32 -0500 Subject: [PATCH] Refs #4752: make AlgorithmProxy pass-through 'child' setting To fix SANS system tests --- .../Framework/API/inc/MantidAPI/AlgorithmProxy.h | 5 +++-- Code/Mantid/Framework/API/src/Algorithm.cpp | 12 ++++++++++-- Code/Mantid/Framework/API/src/AlgorithmProxy.cpp | 3 ++- Code/Mantid/Framework/API/test/AlgorithmProxyTest.h | 2 -- .../src/EQSANSDarkCurrentSubtraction.cpp | 4 ++-- .../src/HFIRDarkCurrentSubtraction.cpp | 3 ++- .../src/SANSSensitivityCorrection.cpp | 4 +++- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h index 5708e4bdebc..f71a4818aa2 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h @@ -93,9 +93,9 @@ namespace Mantid bool isExecuted() const; /// To query whether algorithm is a child. A proxy is always at top level, returns false - bool isChild() const {return false;} + bool isChild() const {return m_isChild;} void setAlwaysStoreInADS(const bool ) {} - void setChild(const bool) {} ///< Do nothing + void setChild(const bool val) {m_isChild = val;}; void setRethrows(const bool rethrow); /** @name PropertyManager methods */ @@ -156,6 +156,7 @@ namespace Mantid bool m_isExecuted; ///< Executed flag bool m_isLoggingEnabled;///< is the logging of the underlying algorithm enabled bool m_rethrow; ///< Whether or not to rethrow exceptions. + bool m_isChild; ///< Is this a child algo /// Temporary holder of external observers wishing to subscribe mutable std::vector<const Poco::AbstractObserver*> m_externalObservers; diff --git a/Code/Mantid/Framework/API/src/Algorithm.cpp b/Code/Mantid/Framework/API/src/Algorithm.cpp index 9d581d7e7d2..21a8b9b7dd1 100644 --- a/Code/Mantid/Framework/API/src/Algorithm.cpp +++ b/Code/Mantid/Framework/API/src/Algorithm.cpp @@ -411,6 +411,8 @@ namespace Mantid // no logging of input if a child algorithm (except for python child algos) if (!m_isChildAlgorithm || m_alwaysStoreInADS) logAlgorithmInfo(); + g_log.debug() << this->name() << " is executing with isChild = " << this->isChild() << std::endl; + // Check all properties for validity if ( !validateProperties() ) { @@ -491,11 +493,13 @@ namespace Mantid // RJT, 19/3/08: Moved this up from below the catch blocks setExecuted(true); - if (!m_isChildAlgorithm) + if (!m_isChildAlgorithm || m_alwaysStoreInADS) { g_log.notice() << name() << " successful, Duration " << std::fixed << std::setprecision(2) << duration << " seconds" << std::endl; } + else + g_log.debug() << name() << " finished with isChild = " << isChild() << std::endl; m_running = false; } catch(std::runtime_error& ex) @@ -814,6 +818,7 @@ namespace Mantid copyPropertiesFrom(proxy); m_algorithmID = proxy.getAlgorithmID(); setLogging(proxy.isLogging()); + setChild(proxy.isChild()); } @@ -883,7 +888,10 @@ namespace Mantid /** Sends out algorithm parameter information to the logger */ void Algorithm::logAlgorithmInfo() const { - g_log.notice() << name() << " started"<< std::endl; + g_log.notice() << name() << " started"; + if (this->isChild()) + g_log.notice() << " (child)"; + g_log.notice() << std::endl; // Make use of the AlgorithmHistory class, which holds all the info we want here AlgorithmHistory AH(this); g_log.information() << AH; diff --git a/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp b/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp index 262738782ae..9acd83601af 100644 --- a/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp +++ b/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp @@ -25,7 +25,8 @@ namespace Mantid PropertyManagerOwner(),_executeAsync(this,&AlgorithmProxy::executeAsyncImpl), m_name(alg->name()),m_category(alg->category()), m_categorySeparator(alg->categorySeparator()), m_alias(alg->alias()), m_version(alg->version()), m_alg(alg), - m_isExecuted(),m_isLoggingEnabled(true), m_rethrow(false) + m_isExecuted(),m_isLoggingEnabled(true), m_rethrow(false), + m_isChild(false) { if (!alg) { diff --git a/Code/Mantid/Framework/API/test/AlgorithmProxyTest.h b/Code/Mantid/Framework/API/test/AlgorithmProxyTest.h index 07ee08e6dbe..5ee8054b7dc 100644 --- a/Code/Mantid/Framework/API/test/AlgorithmProxyTest.h +++ b/Code/Mantid/Framework/API/test/AlgorithmProxyTest.h @@ -120,8 +120,6 @@ public: TS_ASSERT_EQUALS( alg->category() , "ProxyCat" ); TS_ASSERT_EQUALS( alg->alias(), "Dog"); TS_ASSERT( alg->isInitialized() ); - alg->setChild(true); - TS_ASSERT( !alg->isChild() ); TS_ASSERT( alg->existsProperty("prop1") ); TS_ASSERT( alg->existsProperty("prop2") ); TS_ASSERT( !alg->isRunning() ); diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/EQSANSDarkCurrentSubtraction.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/EQSANSDarkCurrentSubtraction.cpp index 46f3fb1af89..0a7ee475531 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/EQSANSDarkCurrentSubtraction.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/EQSANSDarkCurrentSubtraction.cpp @@ -129,8 +129,8 @@ void EQSANSDarkCurrentSubtraction::exec() loadAlg->setProperty("Filename", fileName); loadAlg->setPropertyValue("OutputWorkspace", darkWSName); loadAlg->execute(); - darkWS = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(darkWSName)); - //darkWS = loadAlg->getProperty("OutputWorkspace"); + //darkWS = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(darkWSName)); + darkWS = loadAlg->getProperty("OutputWorkspace"); } setProperty("OutputDarkCurrentWorkspace", darkWS); } diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp index 6d61a2ecf45..30b97dd2ff3 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp @@ -113,7 +113,8 @@ void HFIRDarkCurrentSubtraction::exec() loadAlg->setProperty("Filename", fileName); loadAlg->setPropertyValue("OutputWorkspace", darkWSName); loadAlg->execute(); - darkWS = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(darkWSName)); + //darkWS = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(darkWSName)); + darkWS = loadAlg->getProperty("OutputWorkspace"); } setProperty("OutputDarkCurrentWorkspace", darkWS); } diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSensitivityCorrection.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSensitivityCorrection.cpp index 025722bcea6..23322f821a2 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSensitivityCorrection.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSensitivityCorrection.cpp @@ -191,7 +191,9 @@ void SANSSensitivityCorrection::exec() if (!isEmpty(center_x) && loadAlg->existsProperty("BeamCenterX")) loadAlg->setProperty("BeamCenterX", center_x); if (!isEmpty(center_y) && loadAlg->existsProperty("BeamCenterY")) loadAlg->setProperty("BeamCenterY", center_y); loadAlg->execute(); - rawFloodWS = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(rawFloodWSName)); + rawFloodWS = loadAlg->getProperty("OutputWorkspace"); + // rawFloodWS = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(rawFloodWSName)); + //AnalysisDataService::Instance().addOrReplace(rawFloodWSName, rawFloodWS); m_output_message += " |Loaded " + fileName + "\n"; if (loadAlg->existsProperty("OutputMessage")) { -- GitLab