Skip to content

Commit

Permalink
REF: Use Pydantic v1 API from v2
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Aug 1, 2023
1 parent ff399c9 commit 650fa88
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ defaults:

jobs:
test:
name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}, OpenMM ${{ matrix.openmm }}
name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}, OpenMM ${{ matrix.openmm }}, Pydantic ${{ matrix.pydantic-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
pydantic-version: ["1", "2"]
openmm: [true, false]
exclude:
- python-version: "3.10"
Expand All @@ -44,6 +45,7 @@ jobs:
environment-file: devtools/conda-envs/test_env.yaml
create-args: >-
python=${{ matrix.python-version }}
pydantic=${{ matrix.pydantic-version }}
- name: Install conda environment without OpenMM
if: ${{ matrix.openmm == false }}
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/no_openmm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- python
- pip
- pydantic <2.0.0a0
- pydantic
- openff-units
- openff-utilities
- pytest
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- python
- pip
- pydantic <2.0.0a0
- pydantic
- openff-units
- openff-utilities
- pytest
Expand Down
7 changes: 6 additions & 1 deletion openff/models/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from typing import Any, Callable, Dict

from openff.units import unit
from pydantic import BaseModel

try:
from pydantic.v1 import BaseModel
except ImportError:
from pydantic import BaseModel


from openff.models.types import custom_quantity_encoder, json_loader

Expand Down
6 changes: 5 additions & 1 deletion openff/models/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import pytest
from openff.units import unit
from openff.utilities.testing import skip_if_missing
from pydantic import ValidationError

from openff.models.exceptions import UnitValidationError
from openff.models.models import DefaultModel
from openff.models.types import ArrayQuantity, FloatQuantity

try:
from pydantic.v1 import ValidationError
except ImportError:
from pydantic import ValidationError


class TestQuantityTypes:
@skip_if_missing("openmm.unit")
Expand Down

0 comments on commit 650fa88

Please sign in to comment.