Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix save issues #1154

Merged
merged 6 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions libensemble/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def _save_every_k(self, fname: str, count: int, k: int, complete: bool) -> None:
if not os.path.isfile(filename) and count > 0:
for old_file in glob.glob(fname.format(self.libE_specs["H_file_prefix"], date_start, "*")):
os.remove(old_file)
np.save(filename, self.hist.H)
np.save(filename, self.hist.trim_H())

def _save_every_k_sims(self, complete: bool) -> None:
"""Saves history every kth sim step"""
Expand All @@ -309,7 +309,8 @@ def _save_every_k_gens(self, complete: bool) -> None:
)

def _init_every_k_save(self, complete=False) -> None:
if self.libE_specs.get("save_every_k_sims") or complete:
force_final = complete and not self.libE_specs.get("save_every_k_gens")
if self.libE_specs.get("save_every_k_sims") or force_final:
self._save_every_k_sims(complete)
if self.libE_specs.get("save_every_k_gens"):
self._save_every_k_gens(complete)
Expand Down
1 change: 1 addition & 0 deletions libensemble/tests/functionality_tests/test_1d_splitcomm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
is_manager = libE_specs["mpi_comm"].Get_rank() == 0

libE_specs["save_every_k_gens"] = 300
libE_specs["H_file_prefix"] = "splitcomm_" + str(sub_comm_number)
libE_specs["safe_mode"] = False
libE_specs["disable_log_files"] = True

Expand Down
10 changes: 5 additions & 5 deletions libensemble/tests/unit_tests/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def test_procs_and_machinefile_logic():
f.write(socket.gethostname() + "\n")

task = exctr.submit(calc_type="sim", machinefile=machinefilename, app_args=args_for_sim)
task = polling_loop(exctr, task, delay=0.05)
task = polling_loop(exctr, task, timeout_sec=4, delay=0.05)
assert task.finished, "task.finished should be True. Returned " + str(task.finished)
assert task.state == "FINISHED", "task.state should be FINISHED. Returned " + str(task.state)

Expand All @@ -409,7 +409,7 @@ def test_procs_and_machinefile_logic():
)
else:
task = exctr.submit(calc_type="sim", num_procs=6, num_nodes=2, procs_per_node=3, app_args=args_for_sim)
task = polling_loop(exctr, task, delay=0.05)
task = polling_loop(exctr, task, timeout_sec=4, delay=0.05)
time.sleep(0.25)
assert task.finished, "task.finished should be True. Returned " + str(task.finished)
assert task.state == "FINISHED", "task.state should be FINISHED. Returned " + str(task.state)
Expand All @@ -434,7 +434,7 @@ def test_procs_and_machinefile_logic():
else:
task = exctr.submit(calc_type="sim", num_nodes=2, procs_per_node=3, app_args=args_for_sim)
assert 1
task = polling_loop(exctr, task, delay=0.05)
task = polling_loop(exctr, task, timeout_sec=4, delay=0.05)
time.sleep(0.25)
assert task.finished, "task.finished should be True. Returned " + str(task.finished)
assert task.state == "FINISHED", "task.state should be FINISHED. Returned " + str(task.state)
Expand All @@ -450,14 +450,14 @@ def test_procs_and_machinefile_logic():
# Testing no num_nodes (should not fail).
task = exctr.submit(calc_type="sim", num_procs=2, procs_per_node=2, app_args=args_for_sim)
assert 1
task = polling_loop(exctr, task, delay=0.05)
task = polling_loop(exctr, task, timeout_sec=4, delay=0.05)
assert task.finished, "task.finished should be True. Returned " + str(task.finished)
assert task.state == "FINISHED", "task.state should be FINISHED. Returned " + str(task.state)

# Testing no procs_per_node (shouldn't fail)
task = exctr.submit(calc_type="sim", num_nodes=1, num_procs=2, app_args=args_for_sim)
assert 1
task = polling_loop(exctr, task, delay=0.05)
task = polling_loop(exctr, task, timeout_sec=4, delay=0.05)
assert task.finished, "task.finished should be True. Returned " + str(task.finished)
assert task.state == "FINISHED", "task.state should be FINISHED. Returned " + str(task.state)

Expand Down
Loading