Skip to content

Commit

Permalink
Use Pydantic v2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Nov 4, 2024
1 parent 85ed3b6 commit 0d863a3
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 55 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

test:

name: 💻 ${{ matrix.os }}, 🐍 ${{ matrix.python-version }}, 👀 ${{ matrix.openeye }}, pymbar ${{ matrix.pymbar-version }}, Pydantic ${{ matrix.pydantic-version }}, OpenMM ${{ matrix.openmm-version }}
name: 💻 ${{ matrix.os }}, 🐍 ${{ matrix.python-version }}, 👀 ${{ matrix.openeye }}, pymbar ${{ matrix.pymbar-version }}, OpenMM ${{ matrix.openmm-version }}
runs-on: ${{ matrix.os }}

env:
Expand All @@ -35,8 +35,6 @@ jobs:
- "3.11"
pymbar-version:
- "3.1"
pydantic-version:
- "2"
openmm-version:
- "8"
openeye:
Expand All @@ -54,7 +52,6 @@ jobs:
create-args: >-
python=${{ matrix.python-version }}
pymbar=${{ matrix.pymbar-version }}
pydantic=${{ matrix.pydantic-version }}
openmm=${{ matrix.openmm-version }}
- name: Install OpenEye
Expand Down
14 changes: 0 additions & 14 deletions openff/evaluator/_pydantic.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pandas
import pytest
from openff.units import unit
from pydantic import ValidationError

from openff.evaluator._pydantic import ValidationError
from openff.evaluator.datasets import (
MeasurementSource,
PhysicalPropertyDataSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from typing import overload

import pandas
from pydantic import BaseModel

from openff.evaluator._pydantic import BaseModel
from openff.evaluator.datasets import PhysicalPropertyDataSet

logger = logging.getLogger(__name__)
Expand Down
12 changes: 2 additions & 10 deletions openff/evaluator/datasets/curation/components/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,17 @@

import functools
import logging
from typing import TYPE_CHECKING, Union
from typing import Union

import pandas
from pydantic import Field, conint
from typing_extensions import Literal

from openff.evaluator._pydantic import Field
from openff.evaluator.datasets.curation.components import (
CurationComponent,
CurationComponentSchema,
)

if TYPE_CHECKING:
conint = int
PositiveInt = int
PositiveFloat = float

else:
from openff.evaluator._pydantic import conint

logger = logging.getLogger(__name__)


Expand Down
28 changes: 11 additions & 17 deletions openff/evaluator/datasets/curation/components/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@
import itertools
import logging
from collections import defaultdict
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
from typing import Dict, List, Optional, Tuple, Union

import numpy
import pandas
from openff.units import unit
from pydantic import (
Field,
PositiveFloat,
PositiveInt,
confloat,
conint,
constr,
root_validator,
validator,
)
from scipy.optimize import linear_sum_assignment
from typing_extensions import Literal

from openff.evaluator._pydantic import Field, root_validator, validator
from openff.evaluator.datasets.curation.components import (
CurationComponent,
CurationComponentSchema,
Expand All @@ -24,21 +33,6 @@
analyse_functional_groups,
)

if TYPE_CHECKING:
conint = int
confloat = float
PositiveInt = int
PositiveFloat = float

else:
from openff.evaluator._pydantic import (
PositiveFloat,
PositiveInt,
confloat,
conint,
constr,
)

logger = logging.getLogger(__name__)

ComponentEnvironments = List[List[ChemicalEnvironment]]
Expand Down
7 changes: 1 addition & 6 deletions openff/evaluator/datasets/curation/components/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import numpy
import pandas
from pydantic import BaseModel, Field, PositiveInt, conlist, validator
from typing_extensions import Literal

from openff.evaluator._pydantic import BaseModel, Field, conlist, validator
from openff.evaluator.datasets.curation.components import (
CurationComponent,
CurationComponentSchema,
Expand All @@ -28,16 +28,11 @@
PropertyType = Tuple[str, int]

if TYPE_CHECKING:
PositiveInt = int

try:
from openeye.oegraphsim import OEFingerPrint
except ImportError:
OEFingerPrint = None

else:
from openff.evaluator._pydantic import PositiveInt


class State(BaseModel):
temperature: float = Field(..., description="The temperature (K) of interest.")
Expand Down
2 changes: 1 addition & 1 deletion openff/evaluator/datasets/curation/components/thermoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import pandas
import requests
from pydantic import Field, HttpUrl
from typing_extensions import Literal

from openff.evaluator._pydantic import Field, HttpUrl
from openff.evaluator.datasets.curation.components import (
CurationComponent,
CurationComponentSchema,
Expand Down
2 changes: 1 addition & 1 deletion openff/evaluator/datasets/curation/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import numpy
import pandas
from pydantic import BaseModel, Field

from openff.evaluator._pydantic import BaseModel, Field
from openff.evaluator.datasets import PhysicalPropertyDataSet
from openff.evaluator.datasets.curation.components import CurationComponent
from openff.evaluator.datasets.curation.components.conversion import (
Expand Down

0 comments on commit 0d863a3

Please sign in to comment.