Skip to content

Commit

Permalink
Update to HOOMD 5 (#95)
Browse files Browse the repository at this point in the history
* Support HOOMD 5 build configuration

* Add new required method to anisotropic pair potentials

* Update readthedocs environment

* Run pre-commit on all files

* Cleanup automock list
  • Loading branch information
mphoward authored Dec 9, 2024
1 parent 529ad29 commit 303e6f4
Show file tree
Hide file tree
Showing 20 changed files with 230 additions and 227 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:

#############################################################################################
# HOOMD-blue version to build.
HOOMD_BLUE_VERSION: v4.8.2
HOOMD_BLUE_VERSION: v5.0.0
# prevent deadlocked MPI tests from causing the job to cancel
MPIEXEC_TIMEOUT: 3000
# allow mpirun to execute as root in the tests
Expand Down
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ repos:
- id: check-json
- id: check-yaml
- id: check-case-conflict
- id: fix-encoding-pragma
args:
- --remove
- id: mixed-line-ending
- repo: https://github.com/glotzerlab/fix-license-header
rev: v0.4.1
Expand Down Expand Up @@ -48,12 +45,14 @@ repos:
- --keep-after=.. automodule
- --comment-prefix=..
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.1
rev: v19.1.4
hooks:
- id: clang-format
types_or: [c, c++, cuda, inc]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.8.1
hooks:
- id: ruff-format
types_or: [python]
- id: ruff
types_or: [python]
10 changes: 5 additions & 5 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ sphinx:
fail_on_warning: true

build:
os: ubuntu-22.04
os: ubuntu-24.04
tools:
python: "mambaforge-22.9"
python: "mambaforge-23.11"
jobs:
post_install:
- wget https://github.com/glotzerlab/hoomd-blue/releases/download/v4.8.2/hoomd-4.8.2.tar.gz
- tar -xzvf hoomd-4.8.2.tar.gz
- python doc/mock_install.py hoomd-4.8.2/hoomd src
- wget https://github.com/glotzerlab/hoomd-blue/releases/download/v5.0.0/hoomd-5.0.0.tar.gz
- tar -xzvf hoomd-5.0.0.tar.gz
- python doc/mock_install.py hoomd-5.0.0/hoomd src

conda:
environment: doc/environment.yaml
54 changes: 0 additions & 54 deletions .ruff.toml

This file was deleted.

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.9 FATAL_ERROR)
project(azplugins LANGUAGES C CXX)

# Find the installed HOOMD.
find_package(HOOMD 4.0.0 REQUIRED)
find_package(HOOMD 5.0.0 REQUIRED)

message(STATUS "Found HOOMD ${HOOMD_VERSION}: ${HOOMD_INSTALL_PREFIX}/${PYTHON_SITE_INSTALL_DIR}")

Expand Down
81 changes: 39 additions & 42 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,79 +14,76 @@
import datetime
import os

project = 'azplugins'
project = "azplugins"
year = datetime.date.today().year
copyright = f'2018-2020, Michael P. Howard. 2021-{year}, Auburn University.' # noqa: A001
author = 'Michael P. Howard'
release = '1.0.0'
copyright = f"2018-2020, Michael P. Howard. 2021-{year}, Auburn University."
author = "Michael P. Howard"
release = "1.0.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

default_role = 'any'
default_role = "any"

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

extensions = [
'sphinx.ext.mathjax',
"sphinx.ext.mathjax",
]

extensions += ['sphinx.ext.autodoc', 'sphinx.ext.autosummary']
extensions += ["sphinx.ext.autodoc", "sphinx.ext.autosummary"]
autodoc_docstring_signature = True
autodoc_typehints_format = 'short'
autodoc_mock_imports = ['hoomd.azplugins._azplugins']
if os.getenv('READTHEDOCS'):
autodoc_typehints_format = "short"
autodoc_mock_imports = ["hoomd.azplugins._azplugins"]
if os.getenv("READTHEDOCS"):
autodoc_mock_imports += [
'hoomd._hoomd',
'hoomd.version_config',
'hoomd.md._md',
'hoomd.metal._metal',
'hoomd.mpcd._mpcd',
'hoomd.minimize._minimize',
'hoomd.hpmc._jit',
'hoomd.hpmc._hpmc',
"hoomd._hoomd",
"hoomd.version_config",
"hoomd.hpmc._hpmc",
"hoomd.md._md",
"hoomd.mpcd._mpcd",
]

extensions += ['sphinx.ext.napoleon']
extensions += ["sphinx.ext.napoleon"]
napoleon_include_special_with_doc = True

extensions += ['sphinx.ext.intersphinx']
extensions += ["sphinx.ext.intersphinx"]
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://numpy.org/doc/stable', None),
'gsd': ('https://gsd.readthedocs.io/en/stable/', None),
'hoomd': ('https://hoomd-blue.readthedocs.io/en/stable/', None),
"python": ("https://docs.python.org/3", None),
"numpy": ("https://numpy.org/doc/stable", None),
"gsd": ("https://gsd.readthedocs.io/en/stable/", None),
"hoomd": ("https://hoomd-blue.readthedocs.io/en/stable/", None),
}

extensions += ['sphinx.ext.todo']
extensions += ["sphinx.ext.todo"]
todo_include_todos = False

extensions += ['sphinx_copybutton']
copybutton_prompt_text = '$ '
extensions += ["sphinx_copybutton"]
copybutton_prompt_text = "$ "
copybutton_remove_prompts = True
copybutton_line_continuation_character = '\\'
copybutton_line_continuation_character = "\\"

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
html_static_path = ['_static']
html_theme = "furo"
html_static_path = ["_static"]
# html_logo = "hoomdblue-logo-vertical.svg"
html_theme_options = {
# "sidebar_hide_name": True,
'top_of_page_buttons': [],
'navigation_with_keys': True,
'dark_css_variables': {
'color-brand-primary': '#5187b2',
'color-brand-content': '#5187b2',
"top_of_page_buttons": [],
"navigation_with_keys": True,
"dark_css_variables": {
"color-brand-primary": "#5187b2",
"color-brand-content": "#5187b2",
},
'light_css_variables': {
'color-brand-primary': '#406a8c',
'color-brand-content': '#406a8c',
"light_css_variables": {
"color-brand-primary": "#406a8c",
"color-brand-content": "#406a8c",
},
}
# html_favicon = "hoomdblue-logo-favicon.svg"

pygments_style = 'friendly'
pygments_dark_style = 'native'
pygments_style = "friendly"
pygments_dark_style = "native"
4 changes: 2 additions & 2 deletions doc/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ channels:
- defaults
dependencies:
- python=3.12
- numpy=2.1.2
- numpy=2.1.3
- sphinx=8.1.3
- furo=2024.8.6
- tornado=6.4.1
- tornado=6.4.2
- sphinx-copybutton=0.5.2
6 changes: 3 additions & 3 deletions doc/mock_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
install_dir = Path(site.getsitepackages()[0])

hoomd_dir = Path(sys.argv[1])
for file in hoomd_dir.rglob('*.py'):
for file in hoomd_dir.rglob("*.py"):
relative_file = file.relative_to(hoomd_dir.parent)
os.makedirs(install_dir / relative_file.parent, exist_ok=True)
shutil.copy(file, install_dir / relative_file.parent)

azplugins_dir = Path(sys.argv[2])
for file in azplugins_dir.rglob('*.py'):
relative_file = Path('hoomd') / 'azplugins' / file.relative_to(azplugins_dir)
for file in azplugins_dir.rglob("*.py"):
relative_file = Path("hoomd") / "azplugins" / file.relative_to(azplugins_dir)
os.makedirs(install_dir / relative_file.parent, exist_ok=True)
shutil.copy(file, install_dir / relative_file.parent)
43 changes: 43 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
include = ["*.py"]
extend-exclude = [".git",
"__pycache__",
"build",
]
line-length = 88
indent-width = 4

[lint]
select = [
"E",
"F",
"N",
"W",
"D",
"NPY",
"RUF",
]
ignore = [
"D105", # Magic methods don't require documentation
"D107", # do not document __init__ separately from the class
"D301", # Allow backslashes in docstrings
"D205", "D415", # Allow no summary line. The rendered Sphinx documentation is cleaner without them.
"N816", "N806","N803", # allow occasional use of uppercase variable and argument names
"D214", # ignore overindented sections in Trigger - this is Google napoleon formatting
"RUF012", # hoomd does not use typing annotations
"NPY002", # TODO: refactor tests to use modern numpy Generator API.
]

[lint.pydocstyle]
convention = "google"

[lint.per-file-ignores]
# allow unused imports in init files
"__init__.py" = ["F401"]
# do not require docstrings in unit test or documentation example files
"**/pytest/*" = ["D", "F811", "N999"]

[format]
indent-style = "space"
line-ending = "auto"
docstring-code-line-length = 72
docstring-code-format = true
5 changes: 5 additions & 0 deletions src/AnisoPairEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ class AnisoPairEvaluator
throw std::runtime_error("Name not defined for this pair potential.");
}

static std::string getShapeParamName()
{
throw std::runtime_error("Shape name not defined for this pair potential.");
}

std::string getShapeSpec() const
{
throw std::runtime_error("Shape definition not supported for this pair potential.");
Expand Down
5 changes: 5 additions & 0 deletions src/AnisoPairEvaluatorTwoPatchMorse.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ class AnisoPairEvaluatorTwoPatchMorse : public AnisoPairEvaluator
{
return std::string("TwoPatchMorse");
}

static std::string getShapeParamName()
{
return std::string("");
}
#endif

private:
Expand Down
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

from hoomd.azplugins import bond, flow, pair

__version__ = '1.0.0'
__version__ = "1.0.0"
12 changes: 6 additions & 6 deletions src/bond.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ class DoubleWell(bond.Bond):
"""

_ext_module = _azplugins
_cpp_class_name = 'PotentialBondDoubleWell'
_cpp_class_name = "PotentialBondDoubleWell"

def __init__(self):
super().__init__()
params = TypeParameter(
'params',
'bond_types',
"params",
"bond_types",
TypeParameterDict(
r_0=float, r_1=float, U_1=float, U_tilt=float, len_keys=1
),
Expand Down Expand Up @@ -135,13 +135,13 @@ class Quartic(bond.Bond):
"""

_ext_module = _azplugins
_cpp_class_name = 'PotentialBondQuartic'
_cpp_class_name = "PotentialBondQuartic"

def __init__(self):
super().__init__()
params = TypeParameter(
'params',
'bond_types',
"params",
"bond_types",
TypeParameterDict(
k=float,
r_0=float,
Expand Down
4 changes: 2 additions & 2 deletions src/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import pytest


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def bonded_two_particle_snapshot_factory(two_particle_snapshot_factory):
"""Fixture for a single bond."""

def make_snapshot(bond_types=None, **kwargs):
if bond_types is None:
bond_types = ['A-A']
bond_types = ["A-A"]
snap = two_particle_snapshot_factory(**kwargs)
if snap.communicator.rank == 0:
snap.bonds.types = bond_types
Expand Down
Loading

0 comments on commit 303e6f4

Please sign in to comment.