Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[df] Improve warning message when lazy Snapshot is not triggered #17401

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions tree/dataframe/inc/ROOT/RDF/ActionHelpers.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,18 @@ public:
SnapshotHelper(SnapshotHelper &&) = default;
~SnapshotHelper()
{
if (!fTreeName.empty() /*not moved from*/ && !fOutputFile /* did not run */ && fOptions.fLazy)
Warning("Snapshot", "A lazy Snapshot action was booked but never triggered.");
if (!fTreeName.empty() /*not moved from*/ && !fOutputFile /* did not run */ && fOptions.fLazy) {
const auto fileOpenMode = [&]() {
TString checkupdate = fOptions.fMode;
checkupdate.ToLower();
return checkupdate == "update" ? "updated" : "created";
}();
Warning("Snapshot",
"A lazy Snapshot action was booked but never triggered. The tree '%s' in output file '%s' was not %s. "
"In case it was desired instead, remember to trigger the Snapshot operation, by storing "
"its result in a variable and for example calling the GetValue() method on it.",
fTreeName.c_str(), fFileName.c_str(), fileOpenMode);
}
}

void InitTask(TTreeReader *r, unsigned int /* slot */)
Expand Down Expand Up @@ -1673,8 +1683,18 @@ public:
~SnapshotHelperMT()
{
if (!fTreeName.empty() /*not moved from*/ && fOptions.fLazy && !fOutputFiles.empty() &&
std::all_of(fOutputFiles.begin(), fOutputFiles.end(), [](const auto &f) { return !f; }) /* never run */)
Warning("Snapshot", "A lazy Snapshot action was booked but never triggered.");
std::all_of(fOutputFiles.begin(), fOutputFiles.end(), [](const auto &f) { return !f; }) /* never run */) {
const auto fileOpenMode = [&]() {
TString checkupdate = fOptions.fMode;
checkupdate.ToLower();
return checkupdate == "update" ? "updated" : "created";
}();
Warning("Snapshot",
"A lazy Snapshot action was booked but never triggered. The tree '%s' in output file '%s' was not %s. "
"In case it was desired instead, remember to trigger the Snapshot operation, by storing "
"its result in a variable and for example calling the GetValue() method on it.",
fTreeName.c_str(), fFileName.c_str(), fileOpenMode);
}
}

void InitTask(TTreeReader *r, unsigned int slot)
Expand Down
12 changes: 10 additions & 2 deletions tree/dataframe/test/dataframe_snapshot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,11 @@ void BookLazySnapshot()

TEST(RDFSnapshotMore, LazyNotTriggered)
{
ROOT_EXPECT_WARNING(BookLazySnapshot(), "Snapshot", "A lazy Snapshot action was booked but never triggered.");
ROOT_EXPECT_WARNING(BookLazySnapshot(), "Snapshot",
"A lazy Snapshot action was booked but never triggered. The tree 't' in output file "
"'lazysnapshotnottriggered_shouldnotbecreated.root' was not created. "
"In case it was desired instead, remember to trigger the Snapshot operation, by "
"storing its result in a variable and for example calling the GetValue() method on it.");
}

RResultPtr<RInterface<RLoopManager, void>> ReturnLazySnapshot(const char *fname)
Expand Down Expand Up @@ -1286,7 +1290,11 @@ TEST(RDFSnapshotMore, JittedSnapshotAndAliasedColumns)
TEST(RDFSnapshotMore, LazyNotTriggeredMT)
{
ROOT::EnableImplicitMT(4);
ROOT_EXPECT_WARNING(BookLazySnapshot(), "Snapshot", "A lazy Snapshot action was booked but never triggered.");
ROOT_EXPECT_WARNING(BookLazySnapshot(), "Snapshot",
"A lazy Snapshot action was booked but never triggered. The tree 't' in output file "
"'lazysnapshotnottriggered_shouldnotbecreated.root' was not created. "
"In case it was desired instead, remember to trigger the Snapshot operation, by "
"storing its result in a variable and for example calling the GetValue() method on it.");
ROOT::DisableImplicitMT();
}

Expand Down
Loading