Skip to content

Commit

Permalink
Merge pull request #65 from multimeric/pydantic-2
Browse files Browse the repository at this point in the history
Use pydantic compatibility layer
  • Loading branch information
pr4deepr authored Aug 23, 2024
2 parents 061cff2 + c8a5029 commit f9bf664
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/lls_core/cmds/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from typer.main import get_command

from lls_core.models.output import SaveFileType
from pydantic import ValidationError
from pydantic.v1 import ValidationError

if TYPE_CHECKING:
from lls_core.models.utils import FieldAccessModel
Expand Down
2 changes: 1 addition & 1 deletion core/lls_core/models/crop.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing_extensions import Any, Iterable, List, Tuple
from pydantic import Field, NonNegativeInt, validator
from pydantic.v1 import Field, NonNegativeInt, validator
from lls_core.models.utils import FieldAccessModel
from lls_core.cropping import Roi

Expand Down
2 changes: 1 addition & 1 deletion core/lls_core/models/deconvolution.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from pydantic import Field, NonNegativeInt, validator
from pydantic.v1 import Field, NonNegativeInt, validator

from typing_extensions import Any, List, Literal, Union

Expand Down
2 changes: 1 addition & 1 deletion core/lls_core/models/deskew.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
# class for initializing lattice data and setting metadata
# TODO: handle scenes
from pydantic import Field, NonNegativeFloat, validator, root_validator
from pydantic.v1 import Field, NonNegativeFloat, validator, root_validator

from typing_extensions import Self, TYPE_CHECKING, Any, Tuple

Expand Down
2 changes: 1 addition & 1 deletion core/lls_core/models/lattice_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
# class for initializing lattice data and setting metadata
# TODO: handle scenes
from pydantic import Field, root_validator, validator
from pydantic.v1 import Field, root_validator, validator
from dask.array.core import Array as DaskArray

from typing_extensions import Any, Iterable, Optional, TYPE_CHECKING, Type
Expand Down
2 changes: 1 addition & 1 deletion core/lls_core/models/output.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import Field, DirectoryPath, validator
from pydantic.v1 import Field, DirectoryPath, validator
from strenum import StrEnum
from pathlib import Path
from typing import TYPE_CHECKING
Expand Down
2 changes: 1 addition & 1 deletion core/lls_core/models/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from typing import Iterable, Optional, Tuple, Union, cast, TYPE_CHECKING, overload
from typing_extensions import Generic, TypeVar
from pydantic import BaseModel, NonNegativeInt, Field
from pydantic.v1 import BaseModel, NonNegativeInt, Field
from lls_core.types import ArrayLike, is_arraylike
from lls_core.utils import make_filename_suffix
from lls_core.writers import RoiIndex, Writer
Expand Down
2 changes: 1 addition & 1 deletion core/lls_core/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, Type
from typing_extensions import Self
from enum import Enum
from pydantic import BaseModel, Extra
from pydantic.v1 import BaseModel, Extra
from contextlib import contextmanager

def enum_choices(enum: Type[Enum]) -> str:
Expand Down
2 changes: 1 addition & 1 deletion core/lls_core/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from lls_core.types import ArrayLike

from pydantic import NonNegativeInt
from pydantic.v1 import NonNegativeInt

from lls_core.utils import make_filename_suffix
RoiIndex = Optional[NonNegativeInt]
Expand Down
4 changes: 3 additions & 1 deletion core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ dependencies = [
"pandas",
"pyclesperanto_prototype>=0.20.0",
"pyopencl",
"pydantic~=1.0",
# This is the first pydantic version that supports the "compatibility mode"
# https://docs.pydantic.dev/latest/migration/#using-pydantic-v1-features-in-a-v1v2-environment
"pydantic>=1.10.17",
"pyyaml",
"read-roi",
"rich",
Expand Down
2 changes: 1 addition & 1 deletion core/tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from lls_core.models.deskew import DeskewParams
from lls_core.models.output import OutputParams
import pytest
from pydantic import ValidationError
from pydantic.v1 import ValidationError
import tempfile
from unittest.mock import patch, PropertyMock

Expand Down
2 changes: 1 addition & 1 deletion plugin/napari_lattice/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def exception_to_html(e: BaseException) -> str:
"""
Converts an exception to HTML for reporting back to the user
"""
from pydantic import ValidationError
from pydantic.v1 import ValidationError
if isinstance(e, ValidationError):
message = []
for error in e.errors():
Expand Down
2 changes: 1 addition & 1 deletion plugin/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies = [
"napari-spreadsheet",
"napari-workflow-inspector",
"napari-workflows>=0.2.8",
"napari>=0.4.11,<0.5",
"napari>=0.4.11",
"npy2bdv",
"numpy",
"psutil",
Expand Down

0 comments on commit f9bf664

Please sign in to comment.