[pyfr] 43/88: Maintain the config file history in .pyfrs files.
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Nov 16 12:05:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository pyfr.
commit 8741a769709778269caacc0a5bad9abf0b27f2c0
Author: Freddie Witherden <freddie at witherden.org>
Date: Wed Jun 1 12:31:20 2016 -0700
Maintain the config file history in .pyfrs files.
Every time a simulation is restarted with a new configuration
file that file is saved as config-<n> where n is a monotonically
increasing counter. This enables the genesis of a .pyfrs file to
be tracked right from the initial start-up phase.
---
pyfr/integrators/base.py | 18 +++++++++++++++++-
pyfr/plugins/tavg.py | 2 +-
pyfr/plugins/writer.py | 2 +-
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/pyfr/integrators/base.py b/pyfr/integrators/base.py
index b275288..a227201 100644
--- a/pyfr/integrators/base.py
+++ b/pyfr/integrators/base.py
@@ -17,8 +17,10 @@ class BaseIntegrator(object, metaclass=ABCMeta):
def __init__(self, backend, systemcls, rallocs, mesh, initsoln, cfg):
self.backend = backend
self.rallocs = rallocs
- self.cfg = cfg
self.isrestart = initsoln is not None
+ self.cfg = cfg
+ self.prevcfgs = {f: initsoln[f] for f in initsoln or []
+ if f.startswith('config-')}
# Ensure the system is compatible with our formulation
if self.formulation not in systemcls.elementscls.formulations:
@@ -201,3 +203,17 @@ class BaseIntegrator(object, metaclass=ABCMeta):
stats.set('solver-time-integrator', 'tcurr', self.tcurr)
stats.set('solver-time-integrator', 'wall-time', wtime)
+
+ @property
+ def cfgmeta(self):
+ cfg = self.cfg.tostr()
+
+ if self.prevcfgs:
+ ret = dict(self.prevcfgs, config=cfg)
+
+ if cfg != ret['config-' + str(len(self.prevcfgs) - 1)]:
+ ret['config-' + str(len(self.prevcfgs))] = cfg
+
+ return ret
+ else:
+ return {'config': cfg, 'config-0': cfg}
diff --git a/pyfr/plugins/tavg.py b/pyfr/plugins/tavg.py
index 45bbe08..88b396e 100644
--- a/pyfr/plugins/tavg.py
+++ b/pyfr/plugins/tavg.py
@@ -94,7 +94,7 @@ class TavgPlugin(BasePlugin):
stats.set('tavg', 'tend', intg.tcurr)
intg.collect_stats(stats)
- metadata = dict(config=self.cfg.tostr(),
+ metadata = dict(intg.cfgmeta,
stats=stats.tostr(),
mesh_uuid=intg.mesh_uuid)
diff --git a/pyfr/plugins/writer.py b/pyfr/plugins/writer.py
index 95e10d4..d9a485b 100644
--- a/pyfr/plugins/writer.py
+++ b/pyfr/plugins/writer.py
@@ -44,7 +44,7 @@ class WriterPlugin(BasePlugin):
intg.collect_stats(stats)
# Prepare the metadata
- metadata = dict(config=self.cfg.tostr(),
+ metadata = dict(intg.cfgmeta,
stats=stats.tostr(),
mesh_uuid=intg.mesh_uuid)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyfr.git
More information about the debian-science-commits
mailing list