Read standard output from slaves using ipcluster

I created a cluster using

ipcluster start --n=8 

then turned to him using

 from IPython.parallel import Client c=Client() dview=c[:] e=[i for i in c] 

I run processes on slaves (e [0] -e [7]), which are time consuming, and I would like them to send progress reports to the wizard, so I can keep track of how long they are.

There are two ways that I can think of, but so far I have not been able to implement any of them, despite the frequent trawls through the question pages.

Or I want the nodes to return some data back to the master without a hint. that is, during a long process that runs on nodes, I implement a function that, at certain intervals, passes its progress to the master.

Or I could redirect the stdout nodes to the top of the wizard, and then just track the progress using print. This is what I have been working on so far. Each node has its own stdout, so printing does nothing if you run remotely. I tried pushing sys.stdout to the nodes, but that just closes it.

I cannot believe that I am the only person who wants to do this, so maybe I missed something very simple. How can I track lengthy processes running remotely using ipython?

+4
source share
1 answer

stdout is already captured, registered and tracked and arrives at the Clients when it arrives, before the result is completed.

IPython comes with an example script that controls the stdout / err of all the engines, which can be easily configured to track only a subset of this information, etc.

In the client itself, you can check the dict metadata for stdout / err ( Client.metadata[msg_id].stdout ) before the results are executed. Use Client.spin() to clear all incoming messages from zeromq sockets so that this data is current.

If you want stdout to be updated frequently, make sure you call sys.stdout.flush() to ensure that the stream is actually published at this point, rather than relying on implicit flushes, which may not happen until until the work is completed.

+4
source

Source: https://habr.com/ru/post/1402895/


All Articles