Commit de083dcb authored by Daniel Brown's avatar Daniel Brown

More parakat changes to pass IFO class so you can call those functions on...

More parakat changes to pass IFO class so you can call those functions on cluster. More lockloss catching
parent 7321e8ab
......@@ -64,6 +64,11 @@ class BasePyKatException(Exception):
def __str__(self):
return self.msg
class LockLossException(BasePyKatException):
def __init__(self, step):
self.step = step
BasePyKatException.__init__(self, "Lock was lost after {} steps.".format(step))
class FinesseParse(BasePyKatException) :
def __init__(self, msg):
BasePyKatException.__init__(self, "Error parsing Finesse input\n{0}".format(msg))
......@@ -2075,7 +2075,7 @@ class kat(object):
return vals[2][1:-2] #Format: Finesse 2.2 (2.2-0-g994eac8), 03.07.2017
def run(self, plot=None, save_output=False, save_kat=False, kat_name=None, cmd_args=None,
getTraceData=False, rethrowExceptions=False, usePipe=True, binary_output=False, kat_binary="kat"):
getTraceData=False, rethrowExceptions=False, usePipe=True, binary_output=False, ignore_lockloss=True, kat_binary="kat"):
Runs the current simulation setup that has been built thus far.
It returns a KatRun or KatRun2D object which is populated with the various
......@@ -2104,7 +2104,7 @@ class kat(object):
older versions of Finesse.
rethrowExceptions - if true exceptions will be thrown again rather than being excepted and calling sys.exit()
ignore_lockloss - When True locklosses are ignored and a warning is shown if verbose is True
kat_binary - Name of binary in $FINESSE_DIR to use
start = time.time()
......@@ -2232,6 +2232,12 @@ class kat(object):
if tag == "version":
r.katVersion = line.strip()
elif tag == "lock_fail":
if not ignore_lockloss:
raise pkex.LockLossException(line.strip())
print("\nLock loss ocurred during step {}\n".format(line.strip()))
elif tag == "progress" and self.verbose:
var = line.split("\t")
......@@ -1133,7 +1133,7 @@ class IFO(object):
self.__kat = kat
self.__tuning_keys = frozenset(make_list_copy(tuning_keys_list))
self.__tuning_comps = make_list_copy(tunings_components_list[:])
def kat(self): return self.__kat
......@@ -37,7 +37,7 @@ import os
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
def _run(commands, pwd, **kwargs):
def _run(commands, pwd, IFO, **kwargs):
import os
......@@ -46,6 +46,10 @@ def _run(commands, pwd, **kwargs):
kat = pykat.finesse.kat()
if IFO is not None: # update kat object for IFO to use
kat.IFO = IFO
kat.IFO._IFO__kat = kat
return, **kwargs)
except Exception as ex:
......@@ -96,7 +100,13 @@ class parakat(object):
def run(self, kat, func=None, *args, **kwargs):
if func is None:
func = _run
self._results.append(self._lview.apply_async(func, "".join(kat.generateKatScript()), os.getcwd(), *args, **kwargs))
kat.IFO._IFO__kat = None # can't pickle stored kat
os.getcwd(), *args, **kwargs))
kat.IFO._IFO__kat = kat
self._run_count += 1
def getResults(self):
Markdown is supported
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