Add stream_logs argument to all compose functions that can stream some output #499
Open
7 of 14 tasks
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Every compose fonction that logs something interesting (up, exec, run, push, pull, start, build) should have a new argument (or rename the existing one): stream_logs. When this is enabled, an iterator is returned. This iterator is a tuple[str, bytes]. You can see how this iterator looks like here: https://gabrieldemarmiesse.github.io/python-on-whales/user_guide/docker_run/#stream-the-output
If the user set in any function stream_logs=True and quiet=True at the same time, Python-on-whales should throw an error saying that it's not possible to have both arguments being True at once.
When stream_logs=False, then either None is returned, or the already existing object, like in the function docker.compose.run() which already does that and returns a Container when not streaming.
If a function already has a stream argument, then this argument must be changed to stream_logs.
All of that is possible with the function stream_stdout_and_stderr. An example can be found with docker.compose.run().
To help with the conditional type return, we should use the typing.overload decorator. It will allow mypy, pyright, vscode and pycharm tell the user when the iterator is returned or when something else is returned depending on the input arguments. So the conditional type on return should not be a big deal.
Here are the functions to modify
docker.compose.build
✨ Allow the streaming of the docker.compose.build logs #494docker.compose.create
✨ Added stream_logs to docker.compose.create() #498docker.compose.down
✨ Add stream_logs to docker.compose.down() #496docker.compose.execute
docker.compose.kill
docker.compose.pause
docker.compose.pull
Allow the streaming of the docker.compose.pull logs #497docker.compose.push
docker.compose.restart
docker.compose.rm
docker.compose.start
✨ Added stream_logs to docker.compose.start() #508docker.compose.stop
✨ Added stream_logs to docker.compose.stop() #507docker.compose.unpause
docker.compose.up
✨ Added stream_logs to docker.compose.up() #505If you're interested in this ticket, please make one pull request per function. And if you're looking for examples, you can take a look at the pull requests already done on this subject.
The text was updated successfully, but these errors were encountered: