datalad / datalad

Keep code, data, containers under control with git and git-annex
http://datalad.org
Other
525 stars 110 forks source link

run: make output not interfere with logging and progress bars #5054

Open yarikoptic opened 3 years ago

yarikoptic commented 3 years ago

What is the problem?

If run (or in my case run_procedure upon create within addurl) is not expected to interact with the user, to avoid interference with progress bars and/or any other logging which might be happening in parallel, it is desirable to "capture" and re-output output from the external command via ui.message (which would first properly clear all progressbars, output, and then redrawn progressbars). Without that, output from cfg_ procedures totally ruins UX in parallel execution (#5022). The question is how decision should be made either it is interactive or not I guess - should be required to be explicit (cat /dev/null |), or some procedures could "announce" that they would not have any interaction needed, or higher level function (e.g. addurls) would do that, ...

OR alternative -- we make WitlessRunner without protocol which swallows output to be threadlocked (and force cleaning up of the pbars before and restoring after)... That would cause some slowdown but probably could be tolerable

yarikoptic commented 3 years ago

I think we should provide context manager, similarly to what pyout did recently: https://github.com/pyout/pyout/pull/126 and then may be centralize at the level of the WitlessRunner protocol(s) which would output to the screen.