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

Replace pkg_resources with importlib and add python 3.13 to test suite. #574

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
23d5361
fix dep warnings
chrisjonesBSU Jul 12, 2024
b4bf573
use new conda package for lark
chrisjonesBSU Jul 13, 2024
44bb166
fix pytest fixture
chrisjonesBSU Jul 14, 2024
09f8dcf
Merge branch 'main' of github.com:mosdef-hub/foyer into fix-dep-warnings
chrisjonesBSU Aug 12, 2024
665b5ef
merge and fix conflicts
chrisjonesBSU Aug 19, 2024
82cce0b
Merge branch 'main' of github.com:mosdef-hub/foyer into fix-dep-warnings
chrisjonesBSU Aug 20, 2024
3d52981
merge upstream and fix conflict
chrisjonesBSU Aug 30, 2024
e9e6c17
Merge upstream; fix conflicts
chrisjonesBSU Aug 30, 2024
3a59bb5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2024
11b07c8
fix import
chrisjonesBSU Aug 30, 2024
ec895b6
Merge branch 'main' of github.com:mosdef-hub/foyer into fix-dep-warnings
chrisjonesBSU Sep 10, 2024
496210f
Merge branch 'main' of github.com:mosdef-hub/foyer into fix-dep-warnings
chrisjonesBSU Sep 19, 2024
d42e158
Merge branch 'main' of github.com:mosdef-hub/foyer into fix-dep-warnings
chrisjonesBSU Oct 25, 2024
037d971
drop python 3.9 and add 3.13
chrisjonesBSU Oct 25, 2024
31f3626
bump python version in env files
chrisjonesBSU Oct 25, 2024
dc1b834
Merge branch 'main' of github.com:mosdef-hub/foyer into fix-dep-warnings
chrisjonesBSU Nov 14, 2024
87e1f0a
Merge branch 'main' of github.com:mosdef-hub/foyer into fix-dep-warnings
chrisjonesBSU Dec 24, 2024
5609a6b
update env file
chrisjonesBSU Feb 14, 2025
4ce0134
Merge branch 'main' of github.com:mosdef-hub/foyer into fix-dep-warnings
chrisjonesBSU Feb 17, 2025
60f77be
use python 3.13 in bleeding edge test
chrisjonesBSU Feb 17, 2025
2fabb4f
update pinned python versions
chrisjonesBSU Feb 18, 2025
c4f6014
replace conda action
chrisjonesBSU Feb 18, 2025
9cc83bb
replace micromamba with mamba
chrisjonesBSU Feb 18, 2025
1ee0c9b
add miniforge variant
chrisjonesBSU Feb 18, 2025
258b34b
fix action args
chrisjonesBSU Feb 18, 2025
0726946
fix typo
chrisjonesBSU Feb 18, 2025
b002133
fix typo
chrisjonesBSU Feb 18, 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
30 changes: 19 additions & 11 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

defaults:
run:
Expand All @@ -30,10 +30,12 @@ jobs:
name: Checkout Branch / Pull Request

- name: Install Mamba (Linux)
uses: mamba-org/setup-micromamba@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
environment-file: environment-dev.yml
create-args: python=${{ matrix.python-version }}
use-mamba: true
python-version: ${{ matrix.python-version }}

- name: Install Package
run: python -m pip install -e .
Expand All @@ -56,7 +58,7 @@ jobs:
fail-fast: false
matrix:
os: [macOS-latest, macOS-13, ubuntu-latest, windows-latest]
python-version: ["3.12"]
python-version: ["3.13"]

defaults:
run:
Expand All @@ -67,17 +69,21 @@ jobs:
name: Checkout Branch / Pull Request

- name: Install Mamba (Linux)
uses: mamba-org/setup-micromamba@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
use-mamba: true
environment-file: environment-dev.yml
create-args: python=${{ matrix.python-version }}
python-version: ${{ matrix.python-version }}
if: runner.os != 'Windows'

- name: Install Mamba (Windows)
uses: mamba-org/setup-micromamba@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
use-mamba: true
environment-file: environment-dev-win.yml
create-args: python=${{ matrix.python-version }}
python-version: ${{ matrix.python-version }}
if: runner.os == 'Windows'

- name: Install Package
Expand All @@ -99,18 +105,20 @@ jobs:
name: Checkout Branch / Pull Request

- name: Install Mamba
uses: mamba-org/setup-micromamba@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
use-mamba: true
environment-file: environment-dev.yml
create-args: python=3.12
python-version: 3.13

- name: Install Packages from Source
run: |
pip install -e .

- name: Check environment
run: |
micromamba list
conda list

- name: Run Bleeding Edge Tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion docs/docs-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ dependencies:
- sphinxcontrib-svg2pdfconverter
- nbsphinx
- networkx >=2.0
- lark-parser
- lark
- requests
- lxml
2 changes: 1 addition & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: foyer-dev
channels:
- conda-forge
dependencies:
- python>=3.9,<=3.12
- python>=3.9,<=3.13
- boltons
- numpy=1.26.4
- sympy
Expand Down
2 changes: 1 addition & 1 deletion environment-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencies:
- pytest-cov
- pytest-timeout
- pytest-xdist
- python>=3.9
- python>=3.10,<=3.13
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ dependencies:
- parmed>=3.4.3
- ele
- requests
- python>=3.9
- python>=3.10,<=3.13
7 changes: 4 additions & 3 deletions foyer/forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import collections
import glob
import importlib.resources as resources

Check warning on line 5 in foyer/forcefield.py

View check run for this annotation

Codecov / codecov/patch

foyer/forcefield.py#L5

Added line #L5 was not covered by tests
import itertools
import os
import re
import warnings
import xml.etree.ElementTree as ET
from copy import copy
from importlib.metadata import entry_points

Check warning on line 12 in foyer/forcefield.py

View check run for this annotation

Codecov / codecov/patch

foyer/forcefield.py#L12

Added line #L12 was not covered by tests
from tempfile import NamedTemporaryFile
from typing import Callable, Iterable, List

Expand All @@ -31,7 +33,6 @@
_convertParameterToNumber,
)
from parmed.gromacs.gromacstop import _Defaults
from pkg_resources import iter_entry_points, resource_filename

import foyer.element as custom_elem
from foyer import smarts
Expand Down Expand Up @@ -133,7 +134,7 @@
def get_available_forcefield_loaders() -> List[Callable]:
"""Get a list of available force field loader functions."""
available_ff_paths = []
for entry_point in iter_entry_points(group="foyer.forcefields"):
for entry_point in entry_points(group="foyer.forcefields"):
available_ff_paths.append(entry_point.load())

return available_ff_paths
Expand Down Expand Up @@ -566,7 +567,7 @@
if any(self._included_forcefields):
return self._included_forcefields

ff_dir = resource_filename("foyer", "forcefields")
ff_dir = resources.files("foyer").joinpath("forcefields")
ff_filepaths = set(glob.glob(os.path.join(ff_dir, "xml/*.xml")))

for ff_filepath in ff_filepaths:
Expand Down
4 changes: 2 additions & 2 deletions foyer/forcefields/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Plugin support for forcefields."""

from pkg_resources import iter_entry_points
from importlib.metadata import entry_points

Check warning on line 3 in foyer/forcefields/__init__.py

View check run for this annotation

Codecov / codecov/patch

foyer/forcefields/__init__.py#L3

Added line #L3 was not covered by tests


class ForceFields:
Expand All @@ -11,5 +11,5 @@

forcefields = ForceFields()

for entry_point in iter_entry_points(group="foyer.forcefields", name=None):
for entry_point in entry_points(group="foyer.forcefields"):

Check warning on line 14 in foyer/forcefields/__init__.py

View check run for this annotation

Codecov / codecov/patch

foyer/forcefields/__init__.py#L14

Added line #L14 was not covered by tests
setattr(forcefields, entry_point.name, entry_point.load())
6 changes: 3 additions & 3 deletions foyer/forcefields/forcefields.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"""Support user-created forcefield XML files."""

import glob
import importlib.resources as resources

Check warning on line 4 in foyer/forcefields/forcefields.py

View check run for this annotation

Codecov / codecov/patch

foyer/forcefields/forcefields.py#L4

Added line #L4 was not covered by tests
import os
import warnings

from pkg_resources import resource_filename

from foyer import Forcefield
from foyer.validator import ValidationWarning


def get_ff_path():
"""Return path to forcefield locations."""
return [resource_filename("foyer", "forcefields")]
ff_dir = resources.files("foyer").joinpath("forcefields")
return [ff_dir]


def get_forcefield_paths(forcefield_name=None):
Expand Down
6 changes: 4 additions & 2 deletions foyer/tests/base_test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import importlib.resources as resources
from pathlib import Path

import parmed as pmd
import pytest
from pkg_resources import resource_filename

from foyer import forcefields
from foyer.smarts import SMARTS

OPLS_TEST_FILE_DIR = Path(resource_filename("foyer", "opls_validation")).resolve()
OPLS_TEST_FILE_DIR = Path(
resources.files("foyer").joinpath("opls_validation")
).resolve()


class BaseTest:
Expand Down
4 changes: 2 additions & 2 deletions foyer/tests/test_forcefield.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import difflib
import glob
import importlib.resources as resources
import os
from typing import List

import parmed as pmd
import pytest
from lxml import etree as ET
from parmed.gromacs.gromacstop import _Defaults
from pkg_resources import resource_filename

from foyer import Forcefield, forcefields
from foyer.exceptions import (
Expand All @@ -23,7 +23,7 @@
from foyer.tests.utils import get_fn, register_mock_request
from foyer.utils.io import has_mbuild

FF_DIR = resource_filename("foyer", "forcefields")
FF_DIR = resources.files("foyer").joinpath("forcefields")
FORCEFIELDS = glob.glob(os.path.join(FF_DIR, "xml/*.xml"))

RESPONSE_BIB_ETHANE_JA962170 = """@article{Jorgensen_1996,
Expand Down
4 changes: 2 additions & 2 deletions foyer/tests/test_opls.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import glob
import importlib.resources as resources
import itertools as it
import os

import parmed as pmd
import pytest
from pkg_resources import resource_filename

from foyer.tests.base_test import BaseTest
from foyer.tests.utils import atomtype

OPLS_TESTFILES_DIR = resource_filename("foyer", "opls_validation")
OPLS_TESTFILES_DIR = resources.files("foyer").joinpath("opls_validation")


class TestOPLS(BaseTest):
Expand Down
5 changes: 2 additions & 3 deletions foyer/tests/test_trappe.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import glob
import importlib.resources as resources
import itertools as it
import os

import parmed as pmd
import pytest
from pkg_resources import resource_filename

from foyer import Forcefield
from foyer.tests.base_test import BaseTest
from foyer.tests.utils import atomtype

TRAPPE_UA = Forcefield(name="trappe-ua")

TRAPPE_TESTFILES_DIR = resource_filename("foyer", "trappe_validation")
TRAPPE_TESTFILES_DIR = resources.files("foyer").joinpath("trappe_validation")


class TestTraPPE(BaseTest):
Expand Down
4 changes: 2 additions & 2 deletions foyer/tests/test_validator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import glob
import importlib.resources as resources
import os

import pytest
from lxml.etree import DocumentInvalid, XMLSyntaxError
from pkg_resources import resource_filename

from foyer.exceptions import (
MultipleValidationError,
Expand All @@ -21,7 +21,7 @@
"documentinvalid": DocumentInvalid,
}

FF_DIR = resource_filename("foyer", "forcefields")
FF_DIR = resources.files("foyer").joinpath("forcefields")
FORCEFIELDS = glob.glob(os.path.join(FF_DIR, "xml/*.xml"))


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ classifiers=[
"Operating System :: MacOS",
]
urls = {Homepage = "https://github.com/mosdef-hub/foyer"}
requires-python = ">=3.9"
requires-python = ">=3.10"
dynamic = ["version"]

[tool.setuptools]
Expand Down
Loading