From d18da475a98546e12e70c49843ef94ce917d0b73 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 6 Sep 2024 12:45:04 -0400 Subject: [PATCH 1/3] disable I/O by default in Jupyter also, the first and last plotfile were not respecting io.do_io --- pyro/pyro_sim.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pyro/pyro_sim.py b/pyro/pyro_sim.py index a31086f92..cfe4bd570 100755 --- a/pyro/pyro_sim.py +++ b/pyro/pyro_sim.py @@ -114,11 +114,12 @@ def initialize_problem(self, problem_name, *, inputs_file=None, inputs_dict=None self.rp.load_params(inputs_file, no_new=1) - # manually override the dovis and verbose defaults + # manually override the I/O, dovis, and verbose defaults # for Jupyter, we want runtime vis disabled by default if not self.from_commandline: self.rp.set_param("vis.dovis", 0) self.rp.set_param("driver.verbose", 0) + self.rp.set_param("io.do_io", 0) if inputs_dict is not None: for k, v in inputs_dict.items(): @@ -162,7 +163,10 @@ def run_sim(self): # output the 0th data basename = self.rp.get_param("io.basename") - self.sim.write(f"{basename}{self.sim.n:04d}") + do_io = self.rp.get_param("io.do_io") + + if do_io: + self.sim.write(f"{basename}{self.sim.n:04d}") if self.dovis: plt.figure(num=1, figsize=(8, 6), dpi=100, facecolor='w') @@ -172,10 +176,11 @@ def run_sim(self): self.single_step() # final output - if self.verbose > 0: - msg.warning("outputting...") - basename = self.rp.get_param("io.basename") - self.sim.write(f"{basename}{self.sim.n:04d}") + if do_io: + if self.verbose > 0: + msg.warning("outputting...") + basename = self.rp.get_param("io.basename") + self.sim.write(f"{basename}{self.sim.n:04d}") tm_main.end() # ------------------------------------------------------------------------- From 8a64fb0bc6d487dbc663749bb550c1ae3ecf346b Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 6 Sep 2024 12:55:12 -0400 Subject: [PATCH 2/3] fix regtest --- pyro/_defaults | 1 + pyro/pyro_sim.py | 4 +++- pyro/test.py | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pyro/_defaults b/pyro/_defaults index ff2427904..2f32cc45e 100644 --- a/pyro/_defaults +++ b/pyro/_defaults @@ -16,6 +16,7 @@ basename = pyro_ ; basename for output files dt_out = 0.1 ; simulation time between writing output files n_out = 10000 ; number of timesteps between writing output files do_io = 1 ; do we output at all? +force_final_output = 0 ; regardless of do_io, do we output when the simulation ends? [vis] diff --git a/pyro/pyro_sim.py b/pyro/pyro_sim.py index cfe4bd570..fd554019f 100755 --- a/pyro/pyro_sim.py +++ b/pyro/pyro_sim.py @@ -176,7 +176,9 @@ def run_sim(self): self.single_step() # final output - if do_io: + force_final_output = self.rp.get_param("io.force_final_output") + + if do_io or force_final_output: if self.verbose > 0: msg.warning("outputting...") basename = self.rp.get_param("io.basename") diff --git a/pyro/test.py b/pyro/test.py index d2868c56d..f64bb69f0 100755 --- a/pyro/test.py +++ b/pyro/test.py @@ -64,7 +64,6 @@ def run_test(t, reset_fails, store_all_benchmarks, rtol, nproc): if err == 0: # the test passed; clean up the output files for developer use basename = p.rp.get_param("io.basename") - (test_dir / f"{basename}{start_n:04d}.h5").unlink() (test_dir / f"{basename}{p.sim.n:04d}.h5").unlink() (test_dir / "inputs.auto").unlink() test_dir.rmdir() @@ -86,7 +85,7 @@ def do_tests(out_file, reset_fails=False, store_all_benchmarks=False, single=None, solver=None, rtol=1e-12, nproc=1): - opts = {"driver.verbose": 0, "vis.dovis": 0, "io.do_io": 0} + opts = {"driver.verbose": 0, "vis.dovis": 0, "io.do_io": 0, "io.force_final_output": 1} results = {} From cfb6fc82229ad81d5a33746968797f8d264273e0 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 6 Sep 2024 13:36:57 -0400 Subject: [PATCH 3/3] fix CI --- examples/examples.ipynb | 3 ++- pyro/test.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/examples.ipynb b/examples/examples.ipynb index b5ee26648..27caada76 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -87,8 +87,9 @@ "driver.tmax = 1.0\n", "driver.verbose = 0\n", "io.basename = smooth_\n", - "io.do_io = 1\n", + "io.do_io = 0\n", "io.dt_out = 0.2\n", + "io.force_final_output = 0\n", "io.n_out = 10000\n", "mesh.grid_type = Cartesian2d\n", "mesh.nx = 32\n", diff --git a/pyro/test.py b/pyro/test.py index f64bb69f0..2f5b953bb 100755 --- a/pyro/test.py +++ b/pyro/test.py @@ -57,7 +57,6 @@ def run_test(t, reset_fails, store_all_benchmarks, rtol, nproc): reset_bench_on_fail=reset_fails, make_bench=store_all_benchmarks) p.initialize_problem(t.problem, inputs_file=t.inputs, inputs_dict=t.options) - start_n = p.sim.n err = p.run_sim(rtol) finally: os.chdir(orig_cwd)