diff --git a/docs/requirements.txt b/docs/requirements.txt index f0af923cf..8d19de9d6 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,8 +1,9 @@ sphinx_design pydata_sphinx_theme sphinx -autodoc-pydantic sphinx-copybutton +autodoc-pydantic==1.9.0 +pydantic==1.10.11 myst-nb nglview -e ../qcportal diff --git a/qcarchivetesting/conda-envs/fulltest_qcportal.yaml b/qcarchivetesting/conda-envs/fulltest_qcportal.yaml index d5ce55c52..33532d63f 100644 --- a/qcarchivetesting/conda-envs/fulltest_qcportal.yaml +++ b/qcarchivetesting/conda-envs/fulltest_qcportal.yaml @@ -9,11 +9,11 @@ dependencies: - msgpack-python - requests - pyyaml - - pydantic<2.0 + - pydantic - zstandard - qcelemental - tabulate - tqdm - pandas - pyjwt - - packaging \ No newline at end of file + - packaging diff --git a/qcarchivetesting/conda-envs/fulltest_server.yaml b/qcarchivetesting/conda-envs/fulltest_server.yaml index 981153494..ba1b49ec7 100644 --- a/qcarchivetesting/conda-envs/fulltest_server.yaml +++ b/qcarchivetesting/conda-envs/fulltest_server.yaml @@ -13,7 +13,7 @@ dependencies: - msgpack-python - requests - pyyaml - - pydantic<2.0 + - pydantic - zstandard - qcelemental - tabulate diff --git a/qcarchivetesting/conda-envs/fulltest_snowflake.yaml b/qcarchivetesting/conda-envs/fulltest_snowflake.yaml index 64c1122e5..fa9653ed5 100644 --- a/qcarchivetesting/conda-envs/fulltest_snowflake.yaml +++ b/qcarchivetesting/conda-envs/fulltest_snowflake.yaml @@ -14,7 +14,7 @@ dependencies: - msgpack-python - requests - pyyaml - - pydantic<2.0 + - pydantic - zstandard - qcelemental - tabulate @@ -49,4 +49,4 @@ dependencies: - pip: - "geometric @ git+https://github.com/hjnpark/geomeTRIC" - - scipy # for geometric \ No newline at end of file + - scipy # for geometric diff --git a/qcarchivetesting/conda-envs/fulltest_worker.yaml b/qcarchivetesting/conda-envs/fulltest_worker.yaml index d52f0f624..b32cb6c36 100644 --- a/qcarchivetesting/conda-envs/fulltest_worker.yaml +++ b/qcarchivetesting/conda-envs/fulltest_worker.yaml @@ -13,7 +13,7 @@ dependencies: - msgpack-python - requests - pyyaml - - pydantic<2.0 + - pydantic - zstandard - qcelemental - tabulate diff --git a/qcfractal/qcfractal/components/gridoptimization/record_socket.py b/qcfractal/qcfractal/components/gridoptimization/record_socket.py index 50cfa88df..841b0eff5 100644 --- a/qcfractal/qcfractal/components/gridoptimization/record_socket.py +++ b/qcfractal/qcfractal/components/gridoptimization/record_socket.py @@ -7,7 +7,10 @@ import numpy as np import sqlalchemy.orm.attributes -from pydantic import BaseModel, Extra, parse_obj_as +try: + from pydantic.v1 import BaseModel, Extra, parse_obj_as +except ImportError: + from pydantic import BaseModel, Extra, parse_obj_as from sqlalchemy import select, func from sqlalchemy.dialects.postgresql import insert from sqlalchemy.orm import lazyload, joinedload, undefer, defer diff --git a/qcfractal/qcfractal/components/gridoptimization/testing_helpers.py b/qcfractal/qcfractal/components/gridoptimization/testing_helpers.py index 8bbb367d1..c8fb4dbdd 100644 --- a/qcfractal/qcfractal/components/gridoptimization/testing_helpers.py +++ b/qcfractal/qcfractal/components/gridoptimization/testing_helpers.py @@ -3,7 +3,10 @@ import json from typing import TYPE_CHECKING, Tuple, Optional, Dict, Union, Any -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from qcelemental.models import Molecule, FailedOperation, ComputeError, OptimizationResult from qcelemental.models.procedures import OptimizationProtocols diff --git a/qcfractal/qcfractal/components/managers/test_manager_client.py b/qcfractal/qcfractal/components/managers/test_manager_client.py index 06f920d07..6efdf87a0 100644 --- a/qcfractal/qcfractal/components/managers/test_manager_client.py +++ b/qcfractal/qcfractal/components/managers/test_manager_client.py @@ -4,7 +4,10 @@ from typing import TYPE_CHECKING import pytest -from pydantic import ValidationError +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError from qcfractal.components.singlepoint.testing_helpers import submit_test_data from qcportal import PortalRequestError diff --git a/qcfractal/qcfractal/components/manybody/testing_helpers.py b/qcfractal/qcfractal/components/manybody/testing_helpers.py index 13f057290..e07947f26 100644 --- a/qcfractal/qcfractal/components/manybody/testing_helpers.py +++ b/qcfractal/qcfractal/components/manybody/testing_helpers.py @@ -2,7 +2,10 @@ from typing import TYPE_CHECKING, Tuple, Optional, Dict, Union, Any -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from qcelemental.models import Molecule, FailedOperation, ComputeError, AtomicResult from qcarchivetesting.helpers import read_record_data diff --git a/qcfractal/qcfractal/components/neb/record_socket.py b/qcfractal/qcfractal/components/neb/record_socket.py index 66444b8af..38fe30059 100644 --- a/qcfractal/qcfractal/components/neb/record_socket.py +++ b/qcfractal/qcfractal/components/neb/record_socket.py @@ -8,7 +8,11 @@ import numpy as np import sqlalchemy.orm.attributes import tabulate -from pydantic import BaseModel, Extra +try: + from pydantic.v1 import BaseModel, Extra +except ImportError: + from pydantic import BaseModel, Extra + from sqlalchemy import select, func from sqlalchemy.dialects.postgresql import insert, array_agg, aggregate_order_by, DOUBLE_PRECISION, TEXT from sqlalchemy.orm import lazyload, joinedload, defer, undefer diff --git a/qcfractal/qcfractal/components/neb/testing_helpers.py b/qcfractal/qcfractal/components/neb/testing_helpers.py index 78f0823cb..5777f7482 100644 --- a/qcfractal/qcfractal/components/neb/testing_helpers.py +++ b/qcfractal/qcfractal/components/neb/testing_helpers.py @@ -2,7 +2,10 @@ from typing import TYPE_CHECKING, Tuple, Optional, Dict, List, Union, Any -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from qcelemental.models import Molecule, FailedOperation, ComputeError, AtomicResult, OptimizationResult from qcarchivetesting.helpers import read_record_data diff --git a/qcfractal/qcfractal/components/optimization/testing_helpers.py b/qcfractal/qcfractal/components/optimization/testing_helpers.py index 41de877cc..220531751 100644 --- a/qcfractal/qcfractal/components/optimization/testing_helpers.py +++ b/qcfractal/qcfractal/components/optimization/testing_helpers.py @@ -3,7 +3,10 @@ from datetime import datetime from typing import TYPE_CHECKING, Tuple, Optional, Union, Dict, Any -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from qcelemental.models import Molecule, FailedOperation, ComputeError, OptimizationResult from qcarchivetesting.helpers import read_record_data diff --git a/qcfractal/qcfractal/components/reaction/testing_helpers.py b/qcfractal/qcfractal/components/reaction/testing_helpers.py index dd3581f6f..5c2b1e3dd 100644 --- a/qcfractal/qcfractal/components/reaction/testing_helpers.py +++ b/qcfractal/qcfractal/components/reaction/testing_helpers.py @@ -2,7 +2,10 @@ from typing import TYPE_CHECKING, Tuple, Optional, Dict, List, Union, Any -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from qcelemental.models import Molecule, FailedOperation, ComputeError, AtomicResult, OptimizationResult from qcarchivetesting.helpers import read_record_data diff --git a/qcfractal/qcfractal/components/singlepoint/testing_helpers.py b/qcfractal/qcfractal/components/singlepoint/testing_helpers.py index 8afcf7da5..cb9a0e9f8 100644 --- a/qcfractal/qcfractal/components/singlepoint/testing_helpers.py +++ b/qcfractal/qcfractal/components/singlepoint/testing_helpers.py @@ -3,7 +3,10 @@ from datetime import datetime from typing import TYPE_CHECKING, Tuple, Optional, Union, Dict, Any -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from qcelemental.models import Molecule, FailedOperation, ComputeError, AtomicResult from qcarchivetesting.helpers import read_record_data diff --git a/qcfractal/qcfractal/components/tasks/socket.py b/qcfractal/qcfractal/components/tasks/socket.py index 765808f03..a59eb866e 100644 --- a/qcfractal/qcfractal/components/tasks/socket.py +++ b/qcfractal/qcfractal/components/tasks/socket.py @@ -5,7 +5,10 @@ from datetime import datetime from typing import TYPE_CHECKING -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from qcelemental.models import FailedOperation from sqlalchemy import select, func from sqlalchemy.dialects.postgresql import array diff --git a/qcfractal/qcfractal/components/torsiondrive/record_socket.py b/qcfractal/qcfractal/components/torsiondrive/record_socket.py index 308e6bfac..15e352bbd 100644 --- a/qcfractal/qcfractal/components/torsiondrive/record_socket.py +++ b/qcfractal/qcfractal/components/torsiondrive/record_socket.py @@ -9,7 +9,10 @@ from typing import TYPE_CHECKING import sqlalchemy.orm.attributes -from pydantic import BaseModel, Extra +try: + from pydantic.v1 import BaseModel, Extra +except ImportError: + from pydantic import BaseModel, Extra from sqlalchemy import select, func from sqlalchemy.dialects.postgresql import insert, array_agg, aggregate_order_by, DOUBLE_PRECISION, TEXT from sqlalchemy.orm import lazyload, joinedload, defer, undefer diff --git a/qcfractal/qcfractal/components/torsiondrive/testing_helpers.py b/qcfractal/qcfractal/components/torsiondrive/testing_helpers.py index 8b141874c..9e57b4a0b 100644 --- a/qcfractal/qcfractal/components/torsiondrive/testing_helpers.py +++ b/qcfractal/qcfractal/components/torsiondrive/testing_helpers.py @@ -3,7 +3,10 @@ import json from typing import TYPE_CHECKING, Tuple, Optional, Dict, List, Union, Any -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from qcelemental.models import Molecule, FailedOperation, ComputeError, OptimizationResult from qcelemental.models.procedures import OptimizationProtocols diff --git a/qcfractal/qcfractal/config.py b/qcfractal/qcfractal/config.py index 7f98c00c1..e58f87bed 100644 --- a/qcfractal/qcfractal/config.py +++ b/qcfractal/qcfractal/config.py @@ -11,8 +11,12 @@ import yaml from psycopg2.extensions import make_dsn, parse_dsn -from pydantic import BaseSettings, Field, validator, root_validator, ValidationError -from pydantic.env_settings import SettingsSourceCallable +try: + from pydantic.v1 import BaseSettings, Field, validator, root_validator, ValidationError + from pydantic.v1.env_settings import SettingsSourceCallable +except ImportError: + from pydantic import BaseSettings, Field, validator, root_validator, ValidationError + from pydantic.env_settings import SettingsSourceCallable from sqlalchemy.engine.url import URL, make_url from qcfractal.port_util import find_open_port diff --git a/qcfractal/qcfractal/db_socket/base_orm.py b/qcfractal/qcfractal/db_socket/base_orm.py index 2918871ae..60d3ff3e6 100644 --- a/qcfractal/qcfractal/db_socket/base_orm.py +++ b/qcfractal/qcfractal/db_socket/base_orm.py @@ -10,7 +10,10 @@ if TYPE_CHECKING: from typing import Any, TypeVar, Type, Dict, Optional, Iterable, Union, List - from pydantic import BaseModel + try: + from pydantic.v1 import BaseModel + except ImportError: + from pydantic import BaseModel _T = TypeVar("_T") diff --git a/qcfractal/qcfractal/flask_app/api_v1/helpers.py b/qcfractal/qcfractal/flask_app/api_v1/helpers.py index de4d5113e..c322e764b 100644 --- a/qcfractal/qcfractal/flask_app/api_v1/helpers.py +++ b/qcfractal/qcfractal/flask_app/api_v1/helpers.py @@ -1,7 +1,10 @@ from functools import wraps from typing import Callable -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from flask import request, Response from werkzeug.exceptions import BadRequest diff --git a/qcfractal/qcfractal/old_config.py b/qcfractal/qcfractal/old_config.py index 9c5774700..b1f5e5f30 100644 --- a/qcfractal/qcfractal/old_config.py +++ b/qcfractal/qcfractal/old_config.py @@ -9,7 +9,10 @@ from typing import Optional import yaml -from pydantic import Field, validator +try: + from pydantic.v1 import Field, validator +except ImportError: + from pydantic import Field, validator from .config import ConfigBase, ConfigCommon diff --git a/qcfractalcompute/qcfractalcompute/apps/models.py b/qcfractalcompute/qcfractalcompute/apps/models.py index 461259790..65c57e287 100644 --- a/qcfractalcompute/qcfractalcompute/apps/models.py +++ b/qcfractalcompute/qcfractalcompute/apps/models.py @@ -1,6 +1,9 @@ from __future__ import annotations -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic from qcportal.compression import decompress, CompressionEnum diff --git a/qcfractalcompute/qcfractalcompute/compute_manager.py b/qcfractalcompute/qcfractalcompute/compute_manager.py index 7f06f41fe..9b1a7f8ca 100644 --- a/qcfractalcompute/qcfractalcompute/compute_manager.py +++ b/qcfractalcompute/qcfractalcompute/compute_manager.py @@ -17,7 +17,10 @@ from parsl.dataflow.dflow import DataFlowKernel from parsl.dataflow.futures import Future as ParslFuture from parsl.executors import HighThroughputExecutor, ThreadPoolExecutor -from pydantic import BaseModel, Extra, Field +try: + from pydantic.v1 import BaseModel, Extra, Field +except ImportError: + from pydantic import BaseModel, Extra, Field from requests.exceptions import Timeout from qcfractalcompute.apps.app_manager import AppManager diff --git a/qcfractalcompute/qcfractalcompute/config.py b/qcfractalcompute/qcfractalcompute/config.py index aa854b322..e8380d360 100644 --- a/qcfractalcompute/qcfractalcompute/config.py +++ b/qcfractalcompute/qcfractalcompute/config.py @@ -3,7 +3,10 @@ from typing import List, Optional, Union, Dict, Any import yaml -from pydantic import BaseModel, Field, validator +try: + from pydantic.v1 import BaseModel, Field, validator +except ImportError: + from pydantic import BaseModel, Field, validator from typing_extensions import Literal from qcportal.utils import seconds_to_hms diff --git a/qcportal/pyproject.toml b/qcportal/pyproject.toml index 5d4cb8218..ba52d4c84 100644 --- a/qcportal/pyproject.toml +++ b/qcportal/pyproject.toml @@ -25,7 +25,7 @@ dependencies = [ "msgpack", "requests", "pyyaml", - "pydantic<2.0", + "pydantic", "zstandard", "qcelemental", "tabulate", diff --git a/qcportal/qcportal/auth/models.py b/qcportal/qcportal/auth/models.py index 22fa662bc..019e8c4eb 100644 --- a/qcportal/qcportal/auth/models.py +++ b/qcportal/qcportal/auth/models.py @@ -3,7 +3,10 @@ from enum import Enum from typing import Optional, Union, List -from pydantic import BaseModel, Field, validator, constr, Extra +try: + from pydantic.v1 import BaseModel, Field, validator, constr, Extra +except ImportError: + from pydantic import BaseModel, Field, validator, constr, Extra from ..exceptions import InvalidPasswordError, InvalidUsernameError, InvalidRolenameError, InvalidGroupnameError diff --git a/qcportal/qcportal/base_models.py b/qcportal/qcportal/base_models.py index 1b98a41e8..5d2b08cf4 100644 --- a/qcportal/qcportal/base_models.py +++ b/qcportal/qcportal/base_models.py @@ -2,7 +2,10 @@ from typing import Optional, List, Iterator, Generic, TypeVar -from pydantic import BaseModel, validator, Extra +try: + from pydantic.v1 import BaseModel, validator, Extra +except ImportError: + from pydantic import BaseModel, validator, Extra T = TypeVar("T") diff --git a/qcportal/qcportal/client_base.py b/qcportal/qcportal/client_base.py index 0eabcb27f..f989e782e 100644 --- a/qcportal/qcportal/client_base.py +++ b/qcportal/qcportal/client_base.py @@ -14,7 +14,10 @@ ) import jwt -import pydantic +try: + import pydantic.v1 as pydantic +except ImportError: + import pydantic import requests import yaml from packaging.version import parse as parse_version diff --git a/qcportal/qcportal/dataset_models.py b/qcportal/qcportal/dataset_models.py index 07a852925..2d6169061 100644 --- a/qcportal/qcportal/dataset_models.py +++ b/qcportal/qcportal/dataset_models.py @@ -4,8 +4,12 @@ from typing import Optional, Dict, Any, List, Iterable, Type, Tuple, Union, Callable, ClassVar, Sequence import pandas as pd -import pydantic -from pydantic import BaseModel, Extra, validator, PrivateAttr, Field +try: + import pydantic.v1 as pydantic + from pydantic.v1 import BaseModel, Extra, validator, PrivateAttr, Field +except ImportError: + import pydantic + from pydantic import BaseModel, Extra, validator, PrivateAttr, Field from qcelemental.models.types import Array from tabulate import tabulate from tqdm import tqdm diff --git a/qcportal/qcportal/dataset_view.py b/qcportal/qcportal/dataset_view.py index d3752b5ff..84b3ebc84 100644 --- a/qcportal/qcportal/dataset_view.py +++ b/qcportal/qcportal/dataset_view.py @@ -5,7 +5,10 @@ from typing import Optional, Dict, Any, List, Iterable import zstandard -from pydantic import BaseModel, validator, PrivateAttr, parse_obj_as, Extra +try: + from pydantic.v1 import BaseModel, validator, PrivateAttr, parse_obj_as, Extra +except ImportError: + from pydantic import BaseModel, validator, PrivateAttr, parse_obj_as, Extra from qcportal.serialization import deserialize diff --git a/qcportal/qcportal/gridoptimization/dataset_models.py b/qcportal/qcportal/gridoptimization/dataset_models.py index c4bfaa3c0..c2129d0d6 100644 --- a/qcportal/qcportal/gridoptimization/dataset_models.py +++ b/qcportal/qcportal/gridoptimization/dataset_models.py @@ -1,6 +1,9 @@ from typing import Dict, Any, Union, Optional, Iterable, Tuple -from pydantic import BaseModel, Extra +try: + from pydantic.v1 import BaseModel, Extra +except ImportError: + from pydantic import BaseModel, Extra from typing_extensions import Literal from qcportal.dataset_models import BaseDataset diff --git a/qcportal/qcportal/gridoptimization/record_models.py b/qcportal/qcportal/gridoptimization/record_models.py index ce9801329..82305f951 100644 --- a/qcportal/qcportal/gridoptimization/record_models.py +++ b/qcportal/qcportal/gridoptimization/record_models.py @@ -2,7 +2,10 @@ from enum import Enum from typing import List, Union, Optional, Dict, Iterable, Tuple, Sequence, Any -from pydantic import BaseModel, Extra, Field, constr, validator +try: + from pydantic.v1 import BaseModel, Extra, Field, constr, validator +except ImportError: + from pydantic import BaseModel, Extra, Field, constr, validator from typing_extensions import Literal from qcportal.molecules import Molecule diff --git a/qcportal/qcportal/internal_jobs/models.py b/qcportal/qcportal/internal_jobs/models.py index bc6b40055..d971af260 100644 --- a/qcportal/qcportal/internal_jobs/models.py +++ b/qcportal/qcportal/internal_jobs/models.py @@ -3,7 +3,10 @@ from typing import Optional, Dict, Any, List, Union from dateutil.parser import parse as date_parser -from pydantic import BaseModel, Extra, validator +try: + from pydantic.v1 import BaseModel, Extra, validator +except ImportError: + from pydantic import BaseModel, Extra, validator from qcportal.base_models import QueryProjModelBase from ..base_models import QueryIteratorBase diff --git a/qcportal/qcportal/managers/models.py b/qcportal/qcportal/managers/models.py index 9d60da131..fc4569004 100644 --- a/qcportal/qcportal/managers/models.py +++ b/qcportal/qcportal/managers/models.py @@ -5,7 +5,10 @@ from typing import Optional, Dict, Any, List from dateutil.parser import parse as date_parser -from pydantic import BaseModel, Field, constr, validator, Extra, PrivateAttr +try: + from pydantic.v1 import BaseModel, Field, constr, validator, Extra, PrivateAttr +except ImportError: + from pydantic import BaseModel, Field, constr, validator, Extra, PrivateAttr from qcportal.base_models import RestModelBase, QueryProjModelBase from ..base_models import QueryIteratorBase diff --git a/qcportal/qcportal/manybody/dataset_models.py b/qcportal/qcportal/manybody/dataset_models.py index 2079e0866..0c926356e 100644 --- a/qcportal/qcportal/manybody/dataset_models.py +++ b/qcportal/qcportal/manybody/dataset_models.py @@ -1,6 +1,9 @@ from typing import Dict, Any, Union, Optional, Iterable, Tuple -from pydantic import BaseModel, Extra +try: + from pydantic.v1 import BaseModel, Extra +except ImportError: + from pydantic import BaseModel, Extra from typing_extensions import Literal from qcportal.dataset_models import BaseDataset diff --git a/qcportal/qcportal/manybody/record_models.py b/qcportal/qcportal/manybody/record_models.py index 824808711..a3f1acd0f 100644 --- a/qcportal/qcportal/manybody/record_models.py +++ b/qcportal/qcportal/manybody/record_models.py @@ -1,7 +1,10 @@ from enum import Enum from typing import List, Union, Optional, Dict, Any, Iterable -from pydantic import BaseModel, Extra, validator, constr +try: + from pydantic.v1 import BaseModel, Extra, validator, constr +except ImportError: + from pydantic import BaseModel, Extra, validator, constr from typing_extensions import Literal from qcportal.molecules import Molecule diff --git a/qcportal/qcportal/metadata_models.py b/qcportal/qcportal/metadata_models.py index 66c6929b6..a0a693ae2 100644 --- a/qcportal/qcportal/metadata_models.py +++ b/qcportal/qcportal/metadata_models.py @@ -3,8 +3,12 @@ import dataclasses from typing import List, Optional, Tuple, Dict, Sequence, Any -from pydantic import validator, root_validator -from pydantic.dataclasses import dataclass +try: + from pydantic.v1 import validator, root_validator + from pydantic.v1.dataclasses import dataclass +except ImportError: + from pydantic import validator, root_validator + from pydantic.dataclasses import dataclass @dataclass diff --git a/qcportal/qcportal/neb/dataset_models.py b/qcportal/qcportal/neb/dataset_models.py index daeee6524..8656c078f 100644 --- a/qcportal/qcportal/neb/dataset_models.py +++ b/qcportal/qcportal/neb/dataset_models.py @@ -1,6 +1,9 @@ from typing import Dict, Any, Union, Optional, List, Iterable, Tuple -from pydantic import BaseModel, Extra +try: + from pydantic.v1 import BaseModel, Extra +except ImportError: + from pydantic import BaseModel, Extra from typing_extensions import Literal from qcportal.dataset_models import BaseDataset diff --git a/qcportal/qcportal/neb/record_models.py b/qcportal/qcportal/neb/record_models.py index b1827325d..d1434f4cb 100644 --- a/qcportal/qcportal/neb/record_models.py +++ b/qcportal/qcportal/neb/record_models.py @@ -1,6 +1,9 @@ from typing import List, Optional, Union, Dict, Iterable -from pydantic import BaseModel, Field, Extra, root_validator, constr, validator +try: + from pydantic.v1 import BaseModel, Field, Extra, root_validator, constr, validator +except ImportError: + from pydantic import BaseModel, Field, Extra, root_validator, constr, validator from typing_extensions import Literal from qcportal.molecules import Molecule diff --git a/qcportal/qcportal/optimization/dataset_models.py b/qcportal/qcportal/optimization/dataset_models.py index dc8c88522..1538f8082 100644 --- a/qcportal/qcportal/optimization/dataset_models.py +++ b/qcportal/qcportal/optimization/dataset_models.py @@ -1,6 +1,9 @@ from typing import Dict, Any, Union, Optional, Iterable, Tuple -from pydantic import BaseModel, Extra +try: + from pydantic.v1 import BaseModel, Extra +except ImportError: + from pydantic import BaseModel, Extra from typing_extensions import Literal from qcportal.dataset_models import BaseDataset diff --git a/qcportal/qcportal/optimization/record_models.py b/qcportal/qcportal/optimization/record_models.py index 103647c82..c1d84833e 100644 --- a/qcportal/qcportal/optimization/record_models.py +++ b/qcportal/qcportal/optimization/record_models.py @@ -1,7 +1,10 @@ from copy import deepcopy from typing import Optional, Union, Any, List, Dict, Iterable -from pydantic import BaseModel, Field, constr, validator, Extra +try: + from pydantic.v1 import BaseModel, Field, constr, validator, Extra +except ImportError: + from pydantic import BaseModel, Field, constr, validator, Extra from qcelemental.models import Molecule from qcelemental.models.procedures import ( OptimizationResult, diff --git a/qcportal/qcportal/reaction/dataset_models.py b/qcportal/qcportal/reaction/dataset_models.py index 614d16e2d..6a4120bd7 100644 --- a/qcportal/qcportal/reaction/dataset_models.py +++ b/qcportal/qcportal/reaction/dataset_models.py @@ -1,6 +1,9 @@ from typing import Dict, Any, Union, Optional, List, Iterable, Tuple -from pydantic import BaseModel, Extra +try: + from pydantic.v1 import BaseModel, Extra +except ImportError: + from pydantic import BaseModel, Extra from typing_extensions import Literal from qcportal.dataset_models import BaseDataset diff --git a/qcportal/qcportal/reaction/record_models.py b/qcportal/qcportal/reaction/record_models.py index 549bf2790..3fe747e1e 100644 --- a/qcportal/qcportal/reaction/record_models.py +++ b/qcportal/qcportal/reaction/record_models.py @@ -1,6 +1,9 @@ from typing import List, Union, Optional, Tuple, Iterable -from pydantic import BaseModel, Extra, root_validator, constr +try: + from pydantic.v1 import BaseModel, Extra, root_validator, constr +except ImportError: + from pydantic import BaseModel, Extra, root_validator, constr from typing_extensions import Literal from qcportal.molecules import Molecule diff --git a/qcportal/qcportal/record_models.py b/qcportal/qcportal/record_models.py index d3be8e50f..22d6da826 100644 --- a/qcportal/qcportal/record_models.py +++ b/qcportal/qcportal/record_models.py @@ -6,7 +6,10 @@ from typing import Optional, Dict, Any, List, Union, Iterable, Tuple, Type, Sequence, ClassVar, TypeVar from dateutil.parser import parse as date_parser -from pydantic import BaseModel, Extra, constr, validator, PrivateAttr, Field +try: + from pydantic.v1 import BaseModel, Extra, constr, validator, PrivateAttr, Field +except ImportError: + from pydantic import BaseModel, Extra, constr, validator, PrivateAttr, Field from qcelemental.models.results import Provenance from qcportal.base_models import ( diff --git a/qcportal/qcportal/serialization.py b/qcportal/qcportal/serialization.py index 84674503c..11dffd274 100644 --- a/qcportal/qcportal/serialization.py +++ b/qcportal/qcportal/serialization.py @@ -4,7 +4,10 @@ import msgpack import numpy as np -from pydantic.json import pydantic_encoder +try: + from pydantic.v1.json import pydantic_encoder +except ImportError: + from pydantic.json import pydantic_encoder def _msgpack_encode(obj: Any) -> Any: diff --git a/qcportal/qcportal/serverinfo/models.py b/qcportal/qcportal/serverinfo/models.py index d907b616d..ee54c24a3 100644 --- a/qcportal/qcportal/serverinfo/models.py +++ b/qcportal/qcportal/serverinfo/models.py @@ -3,7 +3,10 @@ from typing import Optional, List, Dict, Any, Union from dateutil.parser import parse as date_parser -from pydantic import BaseModel, Extra, validator, IPvAnyAddress, constr +try: + from pydantic.v1 import BaseModel, Extra, validator, IPvAnyAddress, constr +except ImportError: + from pydantic import BaseModel, Extra, validator, IPvAnyAddress, constr from qcportal.base_models import ( RestModelBase, diff --git a/qcportal/qcportal/singlepoint/dataset_models.py b/qcportal/qcportal/singlepoint/dataset_models.py index 68e7a3e29..d5f41a9da 100644 --- a/qcportal/qcportal/singlepoint/dataset_models.py +++ b/qcportal/qcportal/singlepoint/dataset_models.py @@ -1,6 +1,9 @@ from typing import Dict, Any, Union, Optional, Iterable, Tuple -from pydantic import BaseModel, Extra +try: + from pydantic.v1 import BaseModel, Extra +except ImportError: + from pydantic import BaseModel, Extra from typing_extensions import Literal from qcportal.dataset_models import BaseDataset diff --git a/qcportal/qcportal/singlepoint/record_models.py b/qcportal/qcportal/singlepoint/record_models.py index fcedbf530..b582e759a 100644 --- a/qcportal/qcportal/singlepoint/record_models.py +++ b/qcportal/qcportal/singlepoint/record_models.py @@ -2,7 +2,10 @@ from enum import Enum from typing import Optional, Union, Any, List, Dict, Iterable, Tuple -from pydantic import BaseModel, Field, constr, validator, Extra, PrivateAttr +try: + from pydantic.v1 import BaseModel, Field, constr, validator, Extra, PrivateAttr +except ImportError: + from pydantic import BaseModel, Field, constr, validator, Extra, PrivateAttr from qcelemental.models import Molecule from qcelemental.models.results import ( AtomicResult, diff --git a/qcportal/qcportal/tasks/models.py b/qcportal/qcportal/tasks/models.py index 9cd21896a..58c2fdc82 100644 --- a/qcportal/qcportal/tasks/models.py +++ b/qcportal/qcportal/tasks/models.py @@ -1,6 +1,9 @@ from typing import Dict, List -from pydantic import Field, constr +try: + from pydantic.v1 import Field, BaseModel, constr, Extra +except ImportError: + from pydantic import Field, BaseModel, constr, Extra from qcportal.base_models import RestModelBase from qcportal.managers import ManagerName diff --git a/qcportal/qcportal/torsiondrive/dataset_models.py b/qcportal/qcportal/torsiondrive/dataset_models.py index 42ee101b6..eb5c68a61 100644 --- a/qcportal/qcportal/torsiondrive/dataset_models.py +++ b/qcportal/qcportal/torsiondrive/dataset_models.py @@ -1,6 +1,9 @@ from typing import Dict, Any, Union, Optional, List, Iterable, Tuple -from pydantic import BaseModel, Extra +try: + from pydantic.v1 import BaseModel, Extra +except ImportError: + from pydantic import BaseModel, Extra from typing_extensions import Literal from qcportal.dataset_models import BaseDataset diff --git a/qcportal/qcportal/torsiondrive/record_models.py b/qcportal/qcportal/torsiondrive/record_models.py index be393376b..496e0aeca 100644 --- a/qcportal/qcportal/torsiondrive/record_models.py +++ b/qcportal/qcportal/torsiondrive/record_models.py @@ -1,7 +1,10 @@ import json from typing import List, Optional, Tuple, Union, Dict, Iterable, Sequence, Any -from pydantic import BaseModel, Field, Extra, root_validator, constr, validator +try: + from pydantic.v1 import BaseModel, Field, Extra, root_validator, constr, validator +except ImportError: + from pydantic import BaseModel, Field, Extra, root_validator, constr, validator from typing_extensions import Literal from qcportal.molecules import Molecule