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

Avoid pickling simulation_runners before complete initialisation #2

Merged
merged 1 commit into from
Jul 4, 2024
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
6 changes: 5 additions & 1 deletion a3fe/run/_simulation_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(
dg_multiplier: int = 1,
ensemble_size: int = 5,
update_paths: bool = True,
dump: bool = True,
) -> None:
"""
base_dir : str, Optional, default: None
Expand All @@ -80,6 +81,8 @@ def __init__(
update_paths: bool, Optional, default: True
If True, if the simulation runner is loaded by unpickling, then
update_paths() is called.
dump: bool, Optional, default: True
If True, the state of the simulation runner is saved to a pickle file.
"""
# Set up the directories (which may be overwritten if the
# simulation runner is subsequently loaded from a pickle file)
Expand Down Expand Up @@ -140,7 +143,8 @@ def __init__(
self._set_up_logging()

# Save state
self._dump()
if dump:
self._dump()

def _set_up_logging(self, null: bool = False) -> None:
"""
Expand Down
1 change: 1 addition & 0 deletions a3fe/run/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(
stream_log_level=stream_log_level,
ensemble_size=ensemble_size,
update_paths=update_paths,
dump=False,
)

if not self.loaded_from_pickle:
Expand Down
1 change: 1 addition & 0 deletions a3fe/run/lambda_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def __init__(
stream_log_level=stream_log_level,
ensemble_size=ensemble_size,
update_paths=update_paths,
dump=False,
)

if not self.loaded_from_pickle:
Expand Down
1 change: 1 addition & 0 deletions a3fe/run/leg.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def __init__(
stream_log_level=stream_log_level,
ensemble_size=ensemble_size,
update_paths=update_paths,
dump=False,
)

if not self.loaded_from_pickle:
Expand Down
1 change: 1 addition & 0 deletions a3fe/run/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(
output_dir=output_dir,
stream_log_level=stream_log_level,
update_paths=update_paths,
dump=False,
)

if not self.loaded_from_pickle:
Expand Down
1 change: 1 addition & 0 deletions a3fe/run/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def __init__(
stream_log_level=stream_log_level,
ensemble_size=ensemble_size,
update_paths=update_paths,
dump=False,
)

if not self.loaded_from_pickle:
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Change Log
===============

v0.1.1

- Ensured that ``simulation_runner`` objects only get pickled once they've been fully initialised. This avoids issues where an error occurs during initialisation and the object is pickled in an incomplete state. Addresses https://github.com/michellab/a3fe/issues/1.

v0.1.0
====================

Expand Down
Loading