Home | News | Documentation | Download

Order of Print() statement output in distributed execution

Hello,
I am running some Python code which filters ntuples with a RDataFrame and collects statistics report with something like:

report = df.Report()
report.Print()

The code is executed on a distributed computing cluster.
In the output file that comes out, the output of report.Print() is at the very top, not at the actual position it should be (after some other messages that get printed before by simple Python print()s).
This has probably something to do with the distributed computing platform (I use HTCondor to submit jobs), but I was wondering if is possible to tell ROOT to put the result of Print() exactly where it is called.

Cheers,
Andrea
P.S. I don’t believe this is a RDataFrame problem, I remember this happening with other ROOT objects’ Print()


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.24/06
Platform: x86_64
Compiler: Not Provided


Hi @avilla,

Maybe @vpadulan or @etejedor know how to workaround that.

Cheers,
J.

Is this an HTCondor job that runs a single process in a single node and the output just comes from that single process?

Do you also observe it if you submit a job that simply does:

import ROOT
print("In Python")
ROOT.gInterpreter.ProcessLine('cout << "In C++" << endl;')
print("In Python (2)")

It happens both when running on a single node or in multi-threaded execution.
The output I get from your script is

In C++
In Python
In Python (2)

If I add another C++ statement, such as

import ROOT
print("In Python")
ROOT.gInterpreter.ProcessLine('cout << "In C++" << endl;')
print("In Python (2)")
ROOT.gInterpreter.ProcessLine('cout << "In C++(2)" << endl;')

I get

In C++
In C++(2)
In Python
In Python (2)

Before the first “print”, try to add:
ROOT.gInterpreter.ProcessLine('ios::sync_with_stdio();')

Thanks for the suggestion, but unfortunately the output stays the same even with this addition.

Try to run python adding the “-u” option, or “export PYTHONUNBUFFERED=1” before running it.

That works, thank you very much!