Gadfly.jl icon indicating copy to clipboard operation
Gadfly.jl copied to clipboard

How to supress output to stdout?

Open nomadbl opened this issue 1 year ago • 8 comments

In https://github.com/JuliaLogging/TensorBoardLogger.jl/pull/127 I'm constantly getting

Compose.Image{Compose.PNGBackend}(IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=false, append=true, size=30688, maxsize=Inf, ptr=1, mark=-1), Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x0000000000000000, 535.0, 378.0), CairoContext(Ptr{Nothing} @0x0000000000000000, Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x0000000000000000, 535.0, 378.0), Ptr{Nothing} @0x0000000006376250), 534.5059133378628, 377.9527559055118, RGBA{Float64}(0.0,0.0,0.0,0.0), RGBA{Float64}(0.0,0.0,0.0,1.0), Float64[], Compose.LineCapButt(), Compose.LineJoinMiter(), true, 0.3mm, 3.880555555555555mm, "Helvetica Neue,Helvetica,Arial,sans", nothing, false, Compose.ImagePropertyState[], Compose.ImagePropertyFrame[], Dict{Type, Union{Nothing, Compose.Property}}(), true, false, nothing, true, true, 3.7795275590551185, nothing, nothing)

On the cmd on each show(...)

The source is at https://github.com/JuliaLogging/TensorBoardLogger.jl/blob/d5842d17802e3b8b42d295ccd31c4f14ed4b0d32/src/Optional/Gadfly.jl Is there a way to avoid this?

nomadbl avatar Jul 03 '23 15:07 nomadbl

in julia in general to suppress output put a semicolon at the end of the line. just like matlab.

bjarthur avatar Jul 03 '23 16:07 bjarthur

Thanks for the quick response. I did actually try it and it didn't work (line 14 in the link), so it's probably something with render?

nomadbl avatar Jul 03 '23 16:07 nomadbl

try on line 15.

your syntax is unusual for lines 10-15. if you're trying to define a function, then it should be:

function preproces...
...
end

not sure what you're trying to do with a begin block.

bjarthur avatar Jul 03 '23 16:07 bjarthur

Thanks for that additional catch. I've tried the semicolon in all these places just now, still no dice... Is there some way you would approach how to track down the print that's going on? It seems to come from Compose since we're seeing Compose.Image here, no?

nomadbl avatar Jul 03 '23 16:07 nomadbl

I can reproduce the print on the REPL with:

using Gadfly, Cairo, Fontconfig
pb = PipeBuffer();
p = plot(x=rand(100), Geom.point);
show(pb, MIME("image/png"), render(p));

nomadbl avatar Jul 03 '23 16:07 nomadbl

I did a bit more investigating. I think the output we are seeing is coming from this line in the Compose code or somewhere around that.. Still trying to figure out the code, so any help is welcome :smiley:

nomadbl avatar Jul 06 '23 11:07 nomadbl

might try reducing your MWE to sth that just uses Compose and not Gadfly. if you can do that, then cross-post an issue to Compose.

bjarthur avatar Jul 06 '23 11:07 bjarthur

I'm working on putting together that MWE, just stopping to mention this line img.emit_on_finish && typeof(img.out) == IOBuffer && display(img) In some cases, which is our case I suspect, img.emit_on_finish is true

nomadbl avatar Jul 06 '23 16:07 nomadbl