avik-pal / Wandb.jl

Unofficial Julia bindings for logging experiments to wandb.ai
https://avik-pal.github.io/Wandb.jl/stable/
MIT License
82 stars 11 forks source link

Capture stdout/log messages #11

Open JoshKImperial opened 2 years ago

JoshKImperial commented 2 years ago

When using the wandb Python api it captures log messages which can then be viewed live in the log tab of wandb.ai. It would be helpful if Julia log messages could be captured in the same way, although I cannot find how the Python API captures these messages so I'm unsure how to implement it here. Wandb.log seem to the specifically for logging data which doesn't seem appropriate.

Interestingly, I have found wandb captures the logs from both Gurobi and Ipopt, but again, I'm unsure how they write their logs.

I'm using LoggingExtras.TeeLogger to setup a FileLogger, ConsoleLogger, and Wandb.WandbLogger

avik-pal commented 2 years ago

Yeah, I am not sure how they do it and that's why I did not implement it in the first place. If someone can point me towards how it is implemented, I might be able to take out some time and incorporate it here.

vanpelt commented 2 years ago

@avik-pal I left some comments in the ticket @JoshKImperial just logged. It's complicated, but we might be able to implement a basic solution that doesn't handle all the edge cases that our python console logger does. I would be happy to pair or answer specific questions.

Looking at your implementation if this is actually calling wandb.init in a python process, we can probably just mirror Julia's stdout to that python processes stdout / stderr.

This Julia project is awesome and we would love to help you make it even more so 🤩

JoshKImperial commented 2 years ago

@vanpelt while my knowledge here may be more limited than @avik-pal, I'm happy to help where possible. After reading both of your replies, mirroring Julia's stdout seems like a sensible quick solution. It is my understanding that wandb python is imported here and then initialised here with PyCall.jl handling the interface between Python and Julia. So presumably mirroring the stdout should be viable.

avik-pal commented 2 years ago

@JoshKImperial I agree. If anyone can work out the version, I am happy to quickly review and merge it. (Unfortunately, I have some tight upcoming deadlines to personally implement it rn). From a quick search, https://github.com/JuliaPy/pyjulia/issues/49 might be relevant.