Skip to content

Add MacOS X tests #239

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

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
64f34f7
Update unittests-openmpi.yml
jan-janssen Aug 1, 2024
f6197d0
Update unittests-mpich.yml
jan-janssen Aug 1, 2024
7ed6690
Merge remote-tracking branch 'refs/remotes/origin/main' into mac
jan-janssen Aug 2, 2024
b900542
Add hostname_localhost parameter
jan-janssen Aug 2, 2024
d80fa11
fix tests
jan-janssen Aug 2, 2024
ab377bb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2024
2f7995b
Merge remote-tracking branch 'origin/main' into mac
jan-janssen Jul 17, 2025
6e9d0e1
merge changes
jan-janssen Jul 17, 2025
d1984da
add mac
jan-janssen Jul 17, 2025
c8e69b1
Merge remote-tracking branch 'origin/mac' into mac
jan-janssen Jul 17, 2025
ba64c25
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 17, 2025
dd80221
Merge branch 'main' into mac
jan-janssen Jul 17, 2025
5242603
fix dependencies
jan-janssen Jul 17, 2025
10e726a
downgrade openmpi
jan-janssen Jul 17, 2025
5ebe5e4
remove unused parameters
jan-janssen Jul 17, 2025
a2476bd
fix sed
jan-janssen Jul 17, 2025
0a95d82
downgrade numpy
jan-janssen Jul 17, 2025
b9be91b
disable displacement test
jan-janssen Jul 17, 2025
cb2d269
Test mac os with Python 3.12
jan-janssen Jul 17, 2025
a9fa861
downgrade lammps
jan-janssen Jul 17, 2025
f0daed3
separate environment
jan-janssen Jul 17, 2025
eeb28f7
downgrade mpi4py
jan-janssen Jul 17, 2025
73ca61f
flexible mpi4py
jan-janssen Jul 17, 2025
87b2559
old mpi4py
jan-janssen Jul 17, 2025
e85af4b
set task to done
jan-janssen Jul 17, 2025
b835417
Merge remote-tracking branch 'origin/main' into mac
jan-janssen Jul 17, 2025
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
11 changes: 11 additions & 0 deletions .ci_support/environment-openmpi-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
channels:
- conda-forge
dependencies:
- coverage
- lammps =2024.06.27=*_mpi_openmpi_*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the LAMMPS bug conda-forge/lammps-feedstock#207

- openmpi =4.1.6
- numpy =1.26.4
- mpi4py =3.1.6
- executorlib =1.6.0
- ase =3.25.0
- scipy =1.15.2
48 changes: 45 additions & 3 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
pip install . --no-deps --no-build-isolation
pip check

unittest_mpich:
unittest_linux_mpich:
needs: [black]
runs-on: ubuntu-latest
strategy:
Expand All @@ -113,7 +113,28 @@ jobs:
pip install . --no-deps --no-build-isolation
python -m unittest discover tests

unittest_openmpi:
unittest_mac_mpich:
needs: [black]
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Conda config
run: echo -e "channels:\n - conda-forge\n" > .condarc
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.12'
miniforge-version: latest
condarc-file: .condarc
environment-file: .ci_support/environment-mpich.yml
- name: Test
shell: bash -l {0}
timeout-minutes: 5
run: |
pip install versioneer[toml]==0.29
pip install . --no-deps --no-build-isolation
python -m unittest discover tests

unittest_linux_openmpi:
needs: [black]
runs-on: ubuntu-latest
strategy:
Expand All @@ -137,6 +158,27 @@ jobs:
pip install . --no-deps --no-build-isolation
python -m unittest discover tests

unittest_mac_openmpi:
needs: [black]
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Conda config
run: echo -e "channels:\n - conda-forge\n" > .condarc
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.12'
miniforge-version: latest
condarc-file: .condarc
environment-file: .ci_support/environment-openmpi-mac.yml
- name: Test
shell: bash -l {0}
timeout-minutes: 5
run: |
pip install versioneer[toml]==0.29
pip install . --no-deps --no-build-isolation
python -m unittest discover tests

unittest_old:
needs: [black]
runs-on: ubuntu-latest
Expand All @@ -159,7 +201,7 @@ jobs:
python -m unittest discover tests

autobot:
needs: [unittest_old, unittest_openmpi, unittest_mpich, pip_check, coverage]
needs: [unittest_old, unittest_linux_openmpi, unittest_mac_openmpi, unittest_mac_mpich, unittest_linux_mpich, pip_check, coverage]
permissions:
contents: write
pull-requests: write
Expand Down
5 changes: 4 additions & 1 deletion pylammpsmpi/wrapper/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(
log_file: Optional[str] = None,
library: Optional[object] = None,
disable_log_file: bool = True,
hostname_localhost: bool = False,
):
self._logger = logger
self._prism = None
Expand All @@ -60,7 +61,9 @@ def __init__(
)
else:
self._interactive_library = LammpsBase(
cores=self._cores, working_directory=working_directory
cores=self._cores,
working_directory=working_directory,
hostname_localhost=hostname_localhost,
)

def interactive_lib_command(self, command: str) -> None:
Expand Down
7 changes: 7 additions & 0 deletions pylammpsmpi/wrapper/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def execute_async(
cmdargs: Optional[list[str]] = None,
cores: int = 1,
oversubscribe: bool = False,
hostname_localhost: bool = False,
cwd: Optional[str] = None,
) -> None:
"""
Expand Down Expand Up @@ -59,10 +60,12 @@ def execute_async(
cores=cores,
openmpi_oversubscribe=oversubscribe,
),
hostname_localhost=hostname_localhost,
)
while True:
task_dict = future_queue.get()
if "shutdown" in task_dict and task_dict["shutdown"]:
future_queue.task_done()
interface.shutdown(wait=task_dict["wait"])
break
elif "command" in task_dict and "future" in task_dict:
Expand All @@ -73,6 +76,7 @@ def execute_async(
except Exception as error:
f.set_exception(error)
break
future_queue.task_done()


class LammpsConcurrent:
Expand All @@ -82,6 +86,7 @@ def __init__(
oversubscribe: bool = False,
working_directory: str = ".",
cmdargs: list = None,
hostname_localhost: bool = False,
):
"""
Initialize the LammpsConcurrent object.
Expand All @@ -106,6 +111,7 @@ def __init__(
self._future_queue = Queue()
self._process = None
self._oversubscribe = oversubscribe
self._hostname_localhost = hostname_localhost
self._cmdargs = cmdargs
self._start_process()

Expand All @@ -118,6 +124,7 @@ def _start_process(self):
"cores": self.cores,
"oversubscribe": self._oversubscribe,
"cwd": self.working_directory,
"hostname_localhost": self._hostname_localhost,
},
)
self._process.start()
Expand Down
2 changes: 2 additions & 0 deletions pylammpsmpi/wrapper/extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def __init__(
client: Any = None,
mode: str = "local",
cmdargs: Optional[list[str]] = None,
hostname_localhost: bool = False,
) -> None:
self.cores = cores
self.working_directory = working_directory
Expand All @@ -268,6 +269,7 @@ def __init__(
oversubscribe=self.oversubscribe,
working_directory=self.working_directory,
cmdargs=cmdargs,
hostname_localhost=hostname_localhost,
)

def __getattr__(self, name: str) -> Any:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_ase_interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import sys
import unittest

import numpy as np
Expand Down Expand Up @@ -27,6 +28,7 @@ def test_static(self):
log_file=None,
library=LammpsLibrary(cores=2, mode="local"),
disable_log_file=True,
hostname_localhost=True,
)
structure = bulk("Al", cubic=True).repeat([2, 2, 2])
lmp.interactive_structure_setter(
Expand Down Expand Up @@ -86,6 +88,7 @@ def test_small_displacement(self):
log_file=None,
library=LammpsLibrary(cores=2, mode="local"),
disable_log_file=True,
hostname_localhost=True,
)
structure = bulk("Al", cubic=True)
lmp.interactive_structure_setter(
Expand Down Expand Up @@ -121,6 +124,7 @@ def test_small_displacement(self):
np.all(np.isclose(lmp.interactive_positions_getter(), positions))
)

@unittest.skipIf(sys.platform == "darwin", "This test is not supported on MacOs")
def test_small_displacement_skewed(self):
lmp = LammpsASELibrary(
working_directory=None,
Expand All @@ -130,6 +134,7 @@ def test_small_displacement_skewed(self):
log_file=None,
library=LammpsLibrary(cores=2, mode="local"),
disable_log_file=True,
hostname_localhost=True,
)
structure = bulk("Al").repeat([2, 2, 2])
lmp.interactive_structure_setter(
Expand Down Expand Up @@ -175,6 +180,7 @@ def test_static_with_statement(self):
log_file=None,
library=None,
disable_log_file=True,
hostname_localhost=True,
) as lmp:
lmp.interactive_structure_setter(
structure=structure,
Expand Down Expand Up @@ -419,6 +425,7 @@ def test_individual_calculation(self):
log_file=None,
library=LammpsLibrary(cores=2, mode="local"),
disable_log_file=True,
hostname_localhost=True,
)
lmp.interactive_structure_setter(
structure=structure,
Expand All @@ -444,6 +451,7 @@ def test_interactive_calculation(self):
log_file=None,
library=LammpsLibrary(cores=2, mode="local"),
disable_log_file=True,
hostname_localhost=True,
)
for structure in self.structure_lst:
lmp.interactive_structure_setter(
Expand All @@ -470,6 +478,7 @@ def test_interactive_calculation_inverse(self):
log_file=None,
library=LammpsLibrary(cores=2, mode="local"),
disable_log_file=True,
hostname_localhost=True,
)
for structure in self.structure_lst[::-1]:
lmp.interactive_structure_setter(
Expand Down
2 changes: 2 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def setUpClass(cls):
oversubscribe=False,
working_directory=".",
cmdargs=["-cite", cls.citation_file],
hostname_localhost=True,
)
cls.lmp.file(cls.lammps_file)

Expand All @@ -33,6 +34,7 @@ def test_file_not_found(self):
oversubscribe=False,
working_directory=".",
cmdargs=["-cite", self.citation_file],
hostname_localhost=True,
)
with self.assertRaises(FileNotFoundError):
lmp.file("file_does_not_exist.txt")
Expand Down
1 change: 1 addition & 0 deletions tests/test_concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def setUpClass(cls):
oversubscribe=False,
working_directory=".",
cmdargs=["-cite", cls.citation_file],
hostname_localhost=True,
)
cls.lmp.file(cls.lammps_file).result()

Expand Down
1 change: 1 addition & 0 deletions tests/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def calc_lmp(structure):
log_file=None,
library=None,
disable_log_file=True,
hostname_localhost=True,
)
lmp.interactive_structure_setter(
structure=structure,
Expand Down
Loading