Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stream_logs argument to all compose functions that can stream some output #499

Open
7 of 14 tasks
gabrieldemarmiesse opened this issue Nov 12, 2023 · 0 comments
Open
7 of 14 tasks
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@gabrieldemarmiesse
Copy link
Owner

gabrieldemarmiesse commented Nov 12, 2023

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

If 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant