<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">I ran into this problem not too long ago. I don't think there is any programmatic way to do this within iPython, but you can use subprocess. I've added in a signal handler, so if I have to stop my script in the middle of a run it automatically shuts down the cluster.</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">
<br></div><blockquote class="gmail_quote" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255);margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace">import subprocess<br>import signal<br>import time</font></blockquote><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace">def signal_handler(signal,frame): <br> print("Shutting Down Cluster") <br> subprocess.Popen(["ipcluster", "stop", "--quiet"]) <br> sys.exit(0) <br>
</font></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="courier new, monospace">signal.signal(signal.SIGINT, signal_handler)<br>
subprocess.Popen(["ipcluster",<br> "start",<br> "--n=" + str(12),<br> "--daemonize",<br> "--quiet"])<br>
time.sleep(5) #time for the cluster to spin up<br>#Code using cluster<br>subprocess.Popen(["ipcluster", "stop", "--quiet"])</font></blockquote><div><br></div><div>Hope this helps.</div></div>
<br><div class="gmail_quote">On Tue, Sep 25, 2012 at 1:13 PM, Brent Pedersen <span dir="ltr"><<a href="mailto:bpederse@gmail.com" target="_blank">bpederse@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
I'm attempting to understand how I can use an ipengine on an LSF cluster.<br>
I've done something like this:<br>
<br>
ipython profile create --parallel --profile=lsf<br>
# edit .ipython/profile_lsf/ipcluster_config.py to use LSF<br>
ipcluster start --profile=lsf --daemonize<br>
<br>
But, I'd like to be able to start the engines programatically.<br>
After the above command, I can do this:<br>
<br>
c = Client(profile='lsf')<br>
<br>
Is there a way to "connect" to the profile and have it dynamically launch<br>
engines via python?<br>
I found the IPEngineApp, but it's not clear to me how to use that.<br>
<br>
Is there an example somewhere that launches engines via the API, rather than<br>
the command line? Even one for PBS would be helpful.<br>
<br>
thanks,<br>
-Brent<br>
_______________________________________________<br>
IPython-User mailing list<br>
<a href="mailto:IPython-User@scipy.org">IPython-User@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
</blockquote></div><br>