Commit 0e178c1b authored by Daniel Toyra's avatar Daniel Toyra
Browse files


parents f14d8882 2a0ae4be
# Example on running multiple kat objects at once using the parakat feature.
# Firstly you need to start an ipython cluster on your computer. To do this open
# a new terminal and type the command:
# ipcluster start -n 4
# This will start a cluster with 4 workers. You should set this number to how many
# cores you have.
import pykat
from pykat.parallel import parakat
# Create a connection to the server
pk = parakat()
# Create a bunch of kat objects to run
kat1 = pykat.finesse.kat()
kat2 = pykat.finesse.kat()
kat3 = pykat.finesse.kat()
l l1 1 0 n0
s s1 1 n0 n1
pd P n1
l l1 2 0 n0
s s1 1 n0 n1
pd P n1
l l1 3 0 n0
s s1 1 n0 n1
pd P n1
# Each kat object that is started straightaway when called like this.
# You can add as many as you want, the number that will
# run at once depends on the number of workers in the cluster, cmd_args=["-cr=on"]), cmd_args=["-cr=on"]), cmd_args=["-cr=on"])
# Now you can get the output objects for each of the files run
# They will be returned in order. So you can get each of the outputs using:
out1, out2, out3 = pk.getResults()
# or you could also get the outputs in a list:
outs = pk.getResults()
# so you'd then access the ouputs like: outs[0], outs[1], etc.
# This option is useful if you want to iterate over each output
# result in a for loop for example:
for out in outs:
# Call `clear` to remove the last output results
# After this you could run more in parallel and get the outputs
# for those.
# When finally done you should close the connection to the cluster
......@@ -87,3 +87,11 @@ class parakat(object):
return out
def clear(self):
self._results = []
def close(self):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment