Skip to content

Commit

Permalink
Use Pydantic v1 from v2 backdoor
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Jul 16, 2024
1 parent e1b408b commit 61c438d
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 12 deletions.
18 changes: 18 additions & 0 deletions alchemiscale/_pydantic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
try:
from pydantic.v1 import (
BaseModel,
Field,
validator,
root_validator,
BaseSettings,
ValidationError,
)
except ImportError:
from pydantic import (
BaseModel,
Field,
validator,
root_validator,
BaseSettings,
ValidationError,
)
2 changes: 1 addition & 1 deletion alchemiscale/compute/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path
from typing import Union, Optional, List, Dict, Tuple
from pydantic import BaseModel, Field
from alchemiscale._pydantic import BaseModel, Field

from ..models import Scope, ScopedKey

Expand Down
2 changes: 1 addition & 1 deletion alchemiscale/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from typing import Optional, Union
from pydantic import BaseModel, Field, validator, root_validator
from alchemiscale._pydantic import BaseModel, Field, validator, root_validator
from gufe.tokenization import GufeKey
from re import fullmatch

Expand Down
2 changes: 1 addition & 1 deletion alchemiscale/security/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from fastapi.security import OAuth2PasswordBearer
from jose import JWTError, jwt
from passlib.context import CryptContext
from pydantic import BaseModel
from alchemiscale._pydantic import BaseModel

from .models import Token, TokenData, CredentialedEntity

Expand Down
2 changes: 1 addition & 1 deletion alchemiscale/security/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from datetime import datetime, timedelta
from typing import List, Union, Optional

from pydantic import BaseModel, validator
from alchemiscale._pydantic import BaseModel, validator

from ..models import Scope

Expand Down
2 changes: 1 addition & 1 deletion alchemiscale/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from functools import lru_cache
from typing import Optional

from pydantic import BaseSettings
from alchemiscale._pydantic import BaseSettings


class FrozenSettings(BaseSettings):
Expand Down
2 changes: 1 addition & 1 deletion alchemiscale/storage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import hashlib


from pydantic import BaseModel, Field
from alchemiscale._pydantic import BaseModel, Field
from gufe.tokenization import GufeTokenizable, GufeKey

from ..models import ScopedKey, Scope
Expand Down
2 changes: 1 addition & 1 deletion alchemiscale/tests/unit/test_base_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from fastapi import HTTPException
from pydantic import ValidationError
from alchemiscale._pydantic import ValidationError

from alchemiscale.base.api import validate_scopes, validate_scopes_query
from alchemiscale.models import Scope, ScopedKey
Expand Down
2 changes: 1 addition & 1 deletion alchemiscale/tests/unit/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from pydantic import ValidationError
from alchemiscale._pydantic import ValidationError

from alchemiscale.models import Scope

Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/alchemiscale-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- requests
- click
- httpx
- pydantic<2.0
- pydantic<3.0

## user client printing
- rich
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/alchemiscale-compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- requests
- click
- httpx
- pydantic<2.0
- pydantic<3.0

# perses dependencies
- openeye-toolkits
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/alchemiscale-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- openmmforcefields>=0.12.0
- requests
- click
- pydantic<2.0
- pydantic<3.0

## state store
- neo4j-python-driver
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- gufe>=1.0.0
- openfe>=1.0.1
- openmmforcefields>=0.12.0
- pydantic<2.0
- pydantic<3.0

## state store
- neo4j-python-driver
Expand Down

0 comments on commit 61c438d

Please sign in to comment.