I am running a parallelized algorithm using WolframScript and inside the function being passed to the various kernels, I have print statements that track the computation and output the print statements to the terminal. However, whenever a print statement is executed in the slave kernels, its prepended by
From KernelObject[<n>, Local kernel]:
where <n>
is the $KernelID
. So for example, a full print statement would return
From KernelObject[6, Local kernel]:
<my print statement>
where in the code, I have Print[<my print statement>]
. However, with the number of kernels I have up and running, these prepended messages take up a lot of screen real estate. Is it possible to turn off these From KernelObject...
messages so that I just have the original Print
statement printed to screen? I am pretty new to Wolframscript so I haven't been able to determine a potential solution myself. Perhaps printing to an output stream?
A minimal working example would be for example
wolframscript -code 'ParallelEvaluate[Print["Hello"]]'
to be executed in the terminal. In my specific case, all the code is in a Wolfram Language Script file, so I am executing wolframscript -file <myfile>
. But the results are identical, the print messages are prepended by the above message.
Thanks
EDIT:
Ok, I've managed to implement this in the standard front end by using Trace[ParallelEvaluate[Print["Test"]], CellPrint]
, which shows me the exact pattern to overload in the Downvalues of CellPrint. So I simply set
CellPrint[Cell[s_, "Print", label_, ShowCellLabel -> True]] :=
Block[{},
CellPrint[Cell[s, "Print", ShowCellLabel -> False]]];
which is a bit brute force, but it works. However, this doesnt solve my problem. This only works in the FrontEnd, and not when using Wolframscript. Running Trace[ParallelEvaluate[Print["Test"]], Print]
in a Terminal using
wolframscript -c 'Trace[ParallelEvaluate[Print["Test"]], Print]'
Shows me
{HoldForm[Print[From KernelObject[1, Local kernel]:]], HoldForm[Null], HoldForm[Print[d
]], HoldForm[Null]}
so it looks like wolframscript is inserting the values I want to print into a list of other strings that get printed along with it. I'm not sure how to proceed from this point.
Trace
). I noticed, after runningUnprotect[CellPrint]
that CellPrint has other downvalues that are pretty obscure. If i remove all of them, thenParallelEvaluate[Print["Test"]]
evaluates to nothing, theres no print statement, even with the custom definition as the only downvalue. $\endgroup$$Post
can be used? For example, set$Post=If[Head[#]===String,ToUpperCase[#],#]&
and then type"Hello"
. This will not work forPrint
results, but perhaps one can adapt it. $\endgroup$