in my pyroot + proof code I have a following hierarchy:
ExampleProofReader class (inherits from TPySelector), containing several utility functions to ease the analysis. One of them is a “runAll” method (a @classMethod) which iterates over all datasets and runs the proof based analysis:
print dataset.Process( 'TPySelector', cls.__name__) # cls is a class, see [docs.python.org/2/library/funct ... lassmethod](https://docs.python.org/2/library/functions.html#classmethod)
PedroAna class, inheriting from the ExampleProofReader class. Among others It implements a “analyze” method (called by the ExampleProofReader class from the Process method).
Above setup normally runs fine. From time to time I see following (unwanted) behaviour: for the first processed dataset all runs fine (histograms are produced and saved). For the second processed dataset for some reason proof picks the analyze method from the ExampleProofReader class instead from PedroAna class. This can be triggered by some innocently looking code change in the PedroAna class (e.g. - once I had this caused by only adding “import math” to the PedroAna class).
Any idea how to debug/prevent this? The root version is 5.27.06b-cms23. Unfortunately I’m not able to provide a code snippet reproducing the problem
without a reproducer, I can only guess, so this below is just that.
The code is written to expect only a single class that is derived from TSelector. Since it is only expecting a single class that meets that criterium, it will pick the very first one that it encounters. It looks for this class at module scope.
Do you have both classes in the the same file? Or if in different file, do you keep the base class scoped?
the classes are in the separate files. As I wrote the surprising thing is that it was working correctly most of the time, and the problem was triggered time to time by some seemingly insignificant code change.
After some random guessing I think I have localized the problem - it seems to be coming from “from ROOT import *” statement. I’ll let know if it reappears with this statement removed
“from ROOT import *” will indeed bring them into the same scope, which as my second guess of trouble, but only if the base class (itself derived from TSelector), is a C++ class. It should not affect python classes (there, rather, even if they live in separate files, if the base imported using “from … import ExampleProofReader”, then it does spell trouble for the same reason).