Skip to content

Commit

Permalink
Remove use of pkg_resources (#166)
Browse files Browse the repository at this point in the history
* Remove use of deprecated `pkg_resources`

* Parallelize tests
  • Loading branch information
mattwthompson authored Aug 7, 2023
1 parent 41534f5 commit 8bde6a0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Run Tests
shell: bash -l {0}
run: |
pytest -v --cov=openff --cov-report=xml --color=yes openff/fragmenter/tests/
pytest -v --cov=openff --cov-report=xml --color=yes openff/fragmenter/tests/ -nauto
- name: CodeCov
uses: codecov/codecov-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: isort
files: ^openff
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
files: ^openff
12 changes: 6 additions & 6 deletions devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ name: openff-fragmenter-test

channels:
- conda-forge
- defaults

dependencies:

# Core dependencies
# Core
- python
- pydantic
- jinja2

# OpenFF stack
- openff-toolkit-base >=0.11.0
- openff-utilities >=0.1.9

# Optional tools
- ambertools
- rdkit
- pydantic
- jinja2

# Testing
- pytest
Expand Down
12 changes: 8 additions & 4 deletions openff/fragmenter/depiction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
from openff.fragmenter.fragment import BondTuple, FragmentationResult
from openff.fragmenter.utils import get_map_index
from openff.toolkit.topology import Molecule
from openff.utilities import MissingOptionalDependencyError, requires_oe_module
from pkg_resources import resource_filename
from openff.utilities import (
MissingOptionalDependencyError,
get_data_file_path,
requires_oe_module,
)


@requires_oe_module("oechem")
Expand Down Expand Up @@ -341,8 +344,9 @@ def depict_fragments(
for bond_tuple, fragment in fragments.items()
]

template_path = resource_filename(
"openff.fragmenter", os.path.join("data", "report-template.html")
template_path = get_data_file_path(
os.path.join("data", "report-template.html"),
"openff.fragmenter",
)

with open(template_path) as file:
Expand Down
2 changes: 1 addition & 1 deletion openff/fragmenter/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def from_smiles(self, *args, **kwargs):
assert isinstance(Molecule.from_smiles("C"), Molecule)

assert all(
type(original) == type(current)
type(original) is type(current)
for original, current in zip(
original_toolkits, GLOBAL_TOOLKIT_REGISTRY.registered_toolkits
)
Expand Down
7 changes: 4 additions & 3 deletions openff/fragmenter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ToolkitRegistry,
ToolkitWrapper,
)
from pkg_resources import resource_filename
from openff.utilities import get_data_file_path


def default_functional_groups() -> Dict[str, str]:
Expand All @@ -28,8 +28,9 @@ def default_functional_groups() -> Dict[str, str]:
the corresponding SMARTS pattern.
"""

file_name = resource_filename(
"openff.fragmenter", os.path.join("data", "default-functional-groups.json")
file_name = get_data_file_path(
os.path.join("data", "default-functional-groups.json"),
"openff.fragmenter",
)

with open(file_name, "r") as file:
Expand Down

0 comments on commit 8bde6a0

Please sign in to comment.