gabrieldemarmiesse / python-on-whales

An awesome Python wrapper for an awesome Docker CLI!
MIT License
543 stars 101 forks source link

[Question] Streaming output from push #493

Open baptistecolle opened 10 months ago

baptistecolle commented 10 months ago

Hi,

First of all thanks for the amazing package.

Is there a way to stream output for the push command? Indeed, for example, the build command as a stream_logs argument that allows this behavior

gabrieldemarmiesse commented 10 months ago

I'm glad this package is useful to you! And thanks for the issue. This is not possible right now, but I'll keep it somewhere on the back of my mind, I might allow it in the future. For the moment, you can only see the logs directly in python's stdout, but I suppose that if you opened the issue, it's not enough to satisfy your use case.

By the way I'd be interested to know why you want to do that. This might help me provide a better api for the users long-term :)

baptistecolle commented 10 months ago

I am currently building a CLI that uses the docker client under the hood. Thus, I need to parse the output of docker commands in order to get information from them. For example, for the push command, I want to parse to output to give an eta on the duration of the push.

However, right now it seems not possible to capture the output of the python-on-whales methods. https://github.com/gabrieldemarmiesse/python-on-whales/issues/292#issuecomment-1809738612

gabrieldemarmiesse commented 10 months ago

Indeed, i'm currently working on capturing the logs of compose commands, I guess we could do something similar for push.

Concerning the default behaviour, the only way I found to avoid messing up the TTY output was to not capture anything. But maybe there is a better way by going through the python process, but I'm not aware of it.