1212from PIL import Image
1313from pyproj import Transformer
1414from pygeotile .point import Point as PygeoPoint
15- from pydantic import BaseModel , validator
16- from pydantic .class_validators import root_validator
15+ from labelbox import pydantic_compat
1716
1817from labelbox .data .annotation_types import Rectangle , Point , Line , Polygon
1918from .base_data import BaseData
@@ -41,7 +40,7 @@ class EPSG(Enum):
4140 EPSG3857 = 3857
4241
4342
44- class TiledBounds (BaseModel ):
43+ class TiledBounds (pydantic_compat . BaseModel ):
4544 """ Bounds for a tiled image asset related to the relevant epsg.
4645
4746 Bounds should be Point objects.
@@ -55,7 +54,7 @@ class TiledBounds(BaseModel):
5554 epsg : EPSG
5655 bounds : List [Point ]
5756
58- @validator ('bounds' )
57+ @pydantic_compat . validator ('bounds' )
5958 def validate_bounds_not_equal (cls , bounds ):
6059 first_bound = bounds [0 ]
6160 second_bound = bounds [1 ]
@@ -67,7 +66,7 @@ def validate_bounds_not_equal(cls, bounds):
6766 return bounds
6867
6968 #validate bounds are within lat,lng range if they are EPSG4326
70- @root_validator
69+ @pydantic_compat . root_validator
7170 def validate_bounds_lat_lng (cls , values ):
7271 epsg = values .get ('epsg' )
7372 bounds = values .get ('bounds' )
@@ -83,7 +82,7 @@ def validate_bounds_lat_lng(cls, values):
8382 return values
8483
8584
86- class TileLayer (BaseModel ):
85+ class TileLayer (pydantic_compat . BaseModel ):
8786 """ Url that contains the tile layer. Must be in the format:
8887
8988 https://c.tile.openstreetmap.org/{z}/{x}/{y}.png
@@ -99,7 +98,7 @@ class TileLayer(BaseModel):
9998 def asdict (self ) -> Dict [str , str ]:
10099 return {"tileLayerUrl" : self .url , "name" : self .name }
101100
102- @validator ('url' )
101+ @pydantic_compat . validator ('url' )
103102 def validate_url (cls , url ):
104103 xyz_format = "/{z}/{x}/{y}"
105104 if xyz_format not in url :
@@ -344,7 +343,7 @@ def _validate_num_tiles(self, xstart: float, ystart: float, xend: float,
344343 f"Max allowed tiles are { max_tiles } "
345344 f"Increase max tiles or reduce zoom level." )
346345
347- @validator ('zoom_levels' )
346+ @pydantic_compat . validator ('zoom_levels' )
348347 def validate_zoom_levels (cls , zoom_levels ):
349348 if zoom_levels [0 ] > zoom_levels [1 ]:
350349 raise ValueError (
@@ -353,7 +352,7 @@ def validate_zoom_levels(cls, zoom_levels):
353352 return zoom_levels
354353
355354
356- class EPSGTransformer (BaseModel ):
355+ class EPSGTransformer (pydantic_compat . BaseModel ):
357356 """Transformer class between different EPSG's. Useful when wanting to project
358357 in different formats.
359358 """
0 commit comments