Snapshot complains when updating existing directory

If one tries to update a directory inside an existing file, Snapshot complains:
Error in <TFile::mkdir>: An object with name hi exists already
Reproducer below.

I have made a pull request that resolves the issue. Note that this is similar to pull request 4649, related to this post in the forum.


Before fix:

In [1]: import ROOT

In [2]: df = ROOT.RDataFrame(10).Define('e', 'rdfentry_')

In [3]: df.Snapshot('hi/there', 'test.root')
Out[3]: <ROOT.ROOT::RDF::RResultPtr<ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void> > object at 0x7fc3a7011730>

In [4]: df2 = ROOT.RDataFrame(10).Define('e', 'rdfentry_ * 10')

In [5]: snapopts = ROOT.RDF.RSnapshotOptions()

In [6]: snapopts.fMode = 'UPDATE'

In [7]: df2.Snapshot('hi/there', 'test.root', '', snapopts)
Error in <TFile::mkdir>: An object with name hi exists already
Out[7]: <ROOT.ROOT::RDF::RResultPtr<ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void> > object at 0x7fc3a3df8150>

after fix:

In [1]: import ROOT

In [2]: df = ROOT.RDataFrame(10).Define('e', 'rdfentry_')

In [3]: df.Snapshot('hi/there', 'test.root')
Out[3]: <ROOT.ROOT::RDF::RResultPtr<ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void> > object at 0x7fe187fadd20>

In [4]: df2 = ROOT.RDataFrame(10).Define('e', 'rdfentry_ * 10')

In [5]: snapopts = ROOT.RDF.RSnapshotOptions()

In [6]: snapopts.fMode = 'UPDATE'

In [7]: df2.Snapshot('hi/there', 'test.root', '', snapopts)
Out[7]: <ROOT.ROOT::RDF::RResultPtr<ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void> > object at 0x7fe189c4b410>

ROOT Version: master
Platform: macOS
Compiler: Not Provided


Replied in the linked PR.

PR has been merged. Thanks a lot!

Thanks to the ROOT team for the prompt response.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.