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 parallel optimisation and increase coverage #299

Merged
merged 8 commits into from
Apr 22, 2024
Prev Previous commit
Next Next commit
Update import warning, add changelog entry
  • Loading branch information
BradyPlanden committed Apr 19, 2024
commit 36563a6fe2e3d34c37095a6a706670aa2b4aa000
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ codesigned binaries and source distributions via `sigstore-python`.

## Bug Fixes

- [#299](https://github.com/pybop-team/PyBOP/pull/299) - Bugfix multiprocessing support for Linux, MacOS, Windows (WSL) and improves coverage.
- [#270](https://github.com/pybop-team/PyBOP/pull/270) - Updates PR template.
- [#91](https://github.com/pybop-team/PyBOP/issues/91) - Adds a check on the number of parameters for CMAES and makes XNES the default optimiser.

Expand Down
9 changes: 7 additions & 2 deletions pybop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
mp.set_start_method("spawn")
else:
mp.set_start_method("fork")
except ImportError as e:
print(f"Warning: multiprocessing module not available: {e}")
except Exception as e:
error_message = (

Check warning on line 21 in pybop/__init__.py

View check run for this annotation

Codecov / codecov/patch

pybop/__init__.py#L20-L21

Added lines #L20 - L21 were not covered by tests
"Multiprocessing context could not be set. "
"Continuing import without setting context.\n"
f"Error: {e}"
)
print(error_message)
pass

Check warning on line 27 in pybop/__init__.py

View check run for this annotation

Codecov / codecov/patch

pybop/__init__.py#L26-L27

Added lines #L26 - L27 were not covered by tests

#
# Version info
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def test_multiprocessing_init_win32(monkeypatch):
monkeypatch.setattr(sys, "platform", "win32")
with patch("multiprocessing.set_start_method") as mock_set_start_method:
importlib.reload(pybop)
BradyPlanden marked this conversation as resolved.
Show resolved Hide resolved
# import pybop.__init__ as init
mock_set_start_method.assert_called_once_with("spawn")


Expand Down
Loading