pythontex icon indicating copy to clipboard operation
pythontex copied to clipboard

Labeling chunks and show progress bar increment on processing each chunk

Open konstunn opened this issue 8 years ago • 7 comments

I would like to know on compilation what particular chunk is executing in a particular time moment. That would make things much more clear. Ideally, it would be nice to see a progress bar like n chunk of N have been executed and so on. How to make pythontex talk more?

konstunn avatar Sep 17 '17 05:09 konstunn

That sounds like a useful feature. I am rewriting the core of PythonTeX, and will look into adding this as part of that process. The rewriting process is going slowly, so this isn't something I will be able to add soon.

gpoore avatar Sep 17 '17 13:09 gpoore

I also suggest providing an opportunity to print messages from code chunk. Now pythontex grabs stderr content, wraps it and print as warning or error unlike knitr, where one can print to stderr e.g. progress bars showing the progress within the chunk. This is useful when running long time procedures such as Monte-Carlo simulation and so on.

konstunn avatar Sep 21 '17 16:09 konstunn

Could you, please, make a quick patch to master that would at least unwrap output to stderr so users can print custom run-time messages (i.e. progress bars, etc.) indicating what is running?

konstunn avatar Oct 12 '17 15:10 konstunn

I'd like to help, but I think this is more complex than a quick patch. Getting stderr in real time would require accessing stderr from a subprocess.Popen(), which is itself used inside of a multiprocessing.Pool(). Getting that to work seems like it could require a combination of pipes, queues, and possibly threads. That's more than I have time to dig into at the moment.

gpoore avatar Oct 13 '17 12:10 gpoore

But what if consider disabling multiprocessing? Will it make things easier or stay the same?

konstunn avatar Oct 14 '17 05:10 konstunn

As a temporary quick workaround I can suggest set max jobs number to 1 and, thus, disable multiprocessing, then I suggest subclassing file-like object (let's call it Logger) so that it would write both to file and to terminal. Then one just should create an instance of Logger and pass it to

subprocess.Popen(..., stderr=logger)

like that.

The only misconception that I see is that we will get the content of stderr one more time on finish. Maybe I am missing something else. I can do this in my fork or you can do this in a separate branch or something else. What do you think?

konstunn avatar Oct 14 '17 19:10 konstunn

See what you can do in your fork, and let me know how it goes. Not needing multiprocessing should make things easier.

gpoore avatar Oct 15 '17 12:10 gpoore