Commit 5c939c5d authored by Ian Bush's avatar Ian Bush
Browse files

Refs #21319 Check if workspace property is optional

parent b82f79d1
......@@ -291,12 +291,11 @@ 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 useTempWorkspaceNames = true);
const int &version = -1);
void setupAsChildAlgorithm(boost::shared_ptr<Algorithm> algorithm,
const double startProgress = -1.,
const double endProgress = -1.,
const bool enableLogging = true,
const bool useTempWorkspaceNames = true);
const bool enableLogging = true);
/// set whether we wish to track the child algorithm's history and pass it the
/// parent object to fill.
......
......@@ -49,7 +49,7 @@ protected:
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 useTemps = true) override;
const int &version = -1) override;
void setLoadAlg(const std::string &alg);
void setLoadAlgFileProp(const std::string &filePropName);
void setAccumAlg(const std::string &alg);
......
......@@ -734,19 +734,16 @@ void Algorithm::store() {
*algorithm
* @param version :: The version of the child algorithm to create. By
*default gives the latest version.
* @param useTempWorkspaceNames :: If true then add placeholder names to
*workspaces that are never added to the ADS, due to running as a child
*algorithm, to preserve the algorithm history
* @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 useTempWorkspaceNames) {
Algorithm_sptr Algorithm::createChildAlgorithm(const std::string &name,
const double startProgress,
const double endProgress,
const bool enableLogging,
const int &version) {
Algorithm_sptr alg =
AlgorithmManager::Instance().createUnmanaged(name, version);
setupAsChildAlgorithm(alg, startProgress, endProgress, enableLogging,
useTempWorkspaceNames);
setupAsChildAlgorithm(alg, startProgress, endProgress, enableLogging);
return alg;
}
......@@ -759,8 +756,7 @@ Algorithm_sptr Algorithm::createChildAlgorithm(
void Algorithm::setupAsChildAlgorithm(Algorithm_sptr alg,
const double startProgress,
const double endProgress,
const bool enableLogging,
const bool useTempWorkspaceNames) {
const bool enableLogging) {
// set as a child
alg->setChild(true);
alg->setLogging(enableLogging);
......@@ -779,7 +775,7 @@ void Algorithm::setupAsChildAlgorithm(Algorithm_sptr alg,
for (auto prop : props) {
auto wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
if (prop->direction() == Mantid::Kernel::Direction::Output && wsProp) {
if (prop->value().empty() && useTempWorkspaceNames) {
if (prop->value().empty() && !wsProp->isOptional()) {
prop->createTemporaryValue();
}
}
......@@ -1321,7 +1317,7 @@ bool Algorithm::processGroups() {
Algorithm_sptr alg_sptr = this->createChildAlgorithm(
this->name(), progress_proportion * static_cast<double>(entry),
progress_proportion * (1 + static_cast<double>(entry)),
this->isLogging(), this->version(), false);
this->isLogging(), this->version());
// Don't make the new algorithm a child so that it's workspaces are stored
// correctly
alg_sptr->setChild(false);
......
......@@ -52,19 +52,14 @@ DataProcessorAlgorithm::DataProcessorAlgorithm()
*algorithm
* @param version :: The version of the child algorithm to create. By
*default gives the latest version.
* @param useTempWorkspaceNames :: If true then add placeholder names to
*workspaces that are never added to the ADS, due to running as a child
*algorithm, to preserve the algorithm history
* @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 useTempWorkspaceNames) {
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,
useTempWorkspaceNames);
enableLogging, version);
alg->enableHistoryRecordingForChild(this->isRecordingHistoryForChild());
if (this->isRecordingHistoryForChild()) {
// pass pointer to the history object created in Algorithm to the child
......
......@@ -94,7 +94,7 @@ void export_leaf_classes() {
.def("createChildAlgorithm", &Algorithm::createChildAlgorithm,
(arg("self"), arg("name"), arg("startProgress") = -1.0,
arg("endProgress") = -1.0, arg("enableLogging") = true,
arg("version") = -1, arg("useTempWorkspaceNames") = true),
arg("version") = -1),
"Creates and intializes a named child algorithm. Output workspaces "
"are given a dummy name.")
.def("declareProperty",
......
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