Skip to content
Snippets Groups Projects
Commit e36ec96b authored by EXT Jean-Matthieu Etancelin's avatar EXT Jean-Matthieu Etancelin
Browse files

Fix problem when checkpoint_handler is none

parent 3c922011
No related branches found
No related tags found
2 merge requests!24Resolve "Add python3.x support",!15WIP: Resolve "HySoP with tasks"
import sys, datetime
import sys
import datetime
from hysop.constants import Backend, MemoryOrdering
from hysop.tools.types import check_instance, first_not_None, to_tuple, to_list
......@@ -15,7 +16,7 @@ class Problem(ComputationalGraph):
def __init__(self, name=None, method=None, mpi_params=None,
check_unique_clenv=True, **kwds):
mpi_params = first_not_None(mpi_params, MPIParams()) # enforce mpi params for problems
mpi_params = first_not_None(mpi_params, MPIParams()) # enforce mpi params for problems
super(Problem, self).__init__(name=name, method=method, mpi_params=mpi_params, **kwds)
self._do_check_unique_clenv = check_unique_clenv
......@@ -138,8 +139,9 @@ class Problem(ComputationalGraph):
simu.initialize()
check_instance(checkpoint_handler, CheckpointHandler, allow_none=True)
checkpoint_handler.create_checkpoint_template(self, simu)
checkpoint_handler.load_checkpoint(self, simu)
if checkpoint_handler:
checkpoint_handler.create_checkpoint_template(self, simu)
checkpoint_handler.load_checkpoint(self, simu)
vprint('\nSolving problem...')
with Timer() as tm:
......@@ -147,7 +149,7 @@ class Problem(ComputationalGraph):
vprint()
simu.print_state()
self.apply(simulation=simu, dbg=dbg, **kwds)
should_dump_checkpoint = checkpoint_handler.should_dump(simu) # determined before simu advance
should_dump_checkpoint = checkpoint_handler and checkpoint_handler.should_dump(simu) # determined before simu advance
simu.advance(dbg=dbg, plot_freq=plot_freq)
if should_dump_checkpoint:
checkpoint_handler.save_checkpoint(self, simu)
......@@ -166,7 +168,8 @@ class Problem(ComputationalGraph):
vprint_banner(msg, spacing=True, at_border=2)
simu.finalize()
checkpoint_handler.finalize(self.mpi_params)
if checkpoint_handler:
checkpoint_handler.finalize(self.mpi_params)
self.final_report()
if (dbg is not None):
......@@ -179,4 +182,3 @@ class Problem(ComputationalGraph):
def finalize(self):
vprint('Finalizing problem...')
super(Problem, self).finalize()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment