20using Mantid::Types::Core::DateAndTime;
35 "An input workspace.");
37 std::vector<std::string> exts{
".ipynb"};
40 "The name of the file into which the workspace history will "
42 declareProperty(
"NotebookText", std::string(
""),
"Saves the history of the workspace to a variable.",
44 getPointerToProperty(
"NotebookText")->setAutoTrim(
false);
46 declareProperty(
"UnrollAll",
false,
"Unroll all algorithms to show just their child algorithms.",
Direction::Input);
48 declareProperty(
"StartTimestamp", std::string(
""),
"The filter start time in the format YYYY-MM-DD HH:mm:ss",
50 declareProperty(
"EndTimestamp", std::string(
""),
"The filter end time in the format YYYY-MM-DD HH:mm:ss",
53 std::vector<std::string> saveVersions{
"Specify Old",
"Specify All",
"Specify None"};
54 declareProperty(
"SpecifyAlgorithmVersions",
"Specify Old", std::make_shared<StringListValidator>(saveVersions),
55 "When to specify which algorithm version was used by Mantid.");
63 const std::string startTime =
getProperty(
"StartTimestamp");
64 const std::string endTime =
getProperty(
"EndTimestamp");
65 const std::string saveVersions =
getProperty(
"SpecifyAlgorithmVersions");
78 if (!startTime.empty()) {
79 if (endTime.empty()) {
81 view->filterBetweenExecDate(DateAndTime(startTime));
83 view->filterBetweenExecDate(DateAndTime(startTime), DateAndTime(endTime));
87 std::string versionSpecificity;
88 if (saveVersions ==
"Specify Old")
89 versionSpecificity =
"old";
90 else if (saveVersions ==
"Specify None")
91 versionSpecificity =
"none";
93 versionSpecificity =
"all";
96 std::string generatedNotebook;
97 generatedNotebook += builder.
build(ws->getName(), ws->getTitle(), ws->getComment());
103 if (!filename.empty()) {
104 std::ofstream file(filename.c_str(), std::ofstream::trunc);
105 file << generatedNotebook;
#define DECLARE_ALGORITHM(classname)
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void setPropertyValue(const std::string &name, const std::string &value) override
Set the value of a property by string N.B.
@ OptionalSave
to specify a file to write to but an empty string is
const std::string build(const std::string &ws_name, const std::string &ws_title, const std::string &ws_comment)
build an ipython notebook from the history view
This class stores information about the Workspace History used by algorithms on a workspace and the e...
std::shared_ptr< HistoryView > createView() const
Create a flat view of the workspaces algorithm history.
size_t size() const
How many entries are there.
A property class for workspaces.
void exec() override
Run the algorithm.
The Logger class is in charge of the publishing messages from the framework through various channels.
void information(const std::string &msg)
Logs at information level.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< const Workspace > Workspace_const_sptr
shared pointer to Mantid::API::Workspace (const version)
@ Input
An input workspace.
@ Output
An output workspace.