Skip to content

Commit 549568a

Browse files
authored
Release v.3.63.0 (#1425)
2 parents 2b90aea + a75f619 commit 549568a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+722
-273
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# Changelog
2+
# Version 3.63.0 (2024-02-19)
3+
## Added
4+
* Ability for users to install and use sdk with pydantic v.2.* while still maintaining support for pydantic v1.*
5+
* `ModelRun` `export()` and `export_v2()` add model_run_details to support splits
6+
7+
## Notebooks
8+
* Add composite mask notebook
29

310
# Version 3.62.0 (2024-02-12)
411
## Added

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
copyright = '2021, Labelbox'
2222
author = 'Labelbox'
2323

24-
release = '3.62.0'
24+
release = '3.63.0'
2525

2626
# -- General configuration ---------------------------------------------------
2727

examples/exports/composite_mask_export.ipynb

Lines changed: 390 additions & 0 deletions
Large diffs are not rendered by default.

examples/basics/export_data.ipynb renamed to examples/exports/export_data.ipynb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
"metadata": {},
1717
"source": [
1818
"<td>\n",
19-
"<a href=\"https://colab.research.google.com/github/Labelbox/labelbox-python/blob/master/examples/basics/export_data.ipynb\" target=\"_blank\"><img\n",
19+
"<a href=\"https://colab.research.google.com/github/Labelbox/labelbox-python/blob/master/examples/exports/export_data.ipynb\" target=\"_blank\"><img\n",
2020
"src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"></a>\n",
2121
"</td>\n",
2222
"\n",
2323
"<td>\n",
24-
"<a href=\"https://github.com/Labelbox/labelbox-python/tree/master/examples/basics/export_data.ipynb\" target=\"_blank\"><img\n",
24+
"<a href=\"https://github.com/Labelbox/labelbox-python/tree/master/examples/exports/export_data.ipynb\" target=\"_blank\"><img\n",
2525
"src=\"https://img.shields.io/badge/GitHub-100000?logo=github&logoColor=white\" alt=\"GitHub\"></a>\n",
2626
"</td>"
2727
],
@@ -39,7 +39,7 @@
3939
"metadata": {},
4040
"source": [
4141
"!pip install -q \"labelbox[data]\"\n",
42-
"!pip install -q urllib3 "
42+
"!pip install -q urllib3"
4343
],
4444
"cell_type": "code",
4545
"outputs": [],
@@ -136,7 +136,7 @@
136136
{
137137
"metadata": {},
138138
"source": [
139-
"# Set the export params to include/exclude certain fields. \n",
139+
"# Set the export params to include/exclude certain fields.\n",
140140
"export_params= {\n",
141141
" \"attachments\": True,\n",
142142
" \"metadata_fields\": True,\n",
@@ -180,7 +180,7 @@
180180
{
181181
"metadata": {},
182182
"source": [
183-
"# Set the export params to include/exclude certain fields. \n",
183+
"# Set the export params to include/exclude certain fields.\n",
184184
"export_params= {\n",
185185
" \"attachments\": True,\n",
186186
" \"metadata_fields\": True,\n",
@@ -221,7 +221,7 @@
221221
"\n",
222222
"if export_task.has_errors():\n",
223223
" export_task.get_stream(\n",
224-
" \n",
224+
"\n",
225225
" converter=lb.JsonConverter(),\n",
226226
" stream_type=lb.StreamType.ERRORS\n",
227227
" ).start(stream_handler=lambda error: print(error))\n",
@@ -252,7 +252,7 @@
252252
"# stream_type=lb.StreamType.ERRORS\n",
253253
"# ).start()\n",
254254
"\n",
255-
"# if export_task.has_result(): \n",
255+
"# if export_task.has_result():\n",
256256
"# export_task.get_stream(\n",
257257
"# converter=lb.FileConverter(file_path=\"./result.txt\"),\n",
258258
"# stream_type=lb.StreamType.RESULT\n",
@@ -324,7 +324,7 @@
324324
" \"performance_details\": True,\n",
325325
" \"interpolated_frames\": True,\n",
326326
" # \"project_ids\": [\"<project_id>\", \"<project_id>\"],\n",
327-
" # \"model_run_ids\": [\"<model_run_id>\", \"<model_run_id>\"] \n",
327+
" # \"model_run_ids\": [\"<model_run_id>\", \"<model_run_id>\"]\n",
328328
"}\n",
329329
"\n",
330330
"# Note: Filters follow AND logic, so typically using one filter is sufficient.\n",
@@ -367,7 +367,7 @@
367367
" \"performance_details\": True,\n",
368368
" \"interpolated_frames\": True,\n",
369369
" # \"project_ids\": [\"<project_id>\", \"<project_id>\"],\n",
370-
" # \"model_run_ids\": [\"<model_run_id>\", \"<model_run_id>\"] \n",
370+
" # \"model_run_ids\": [\"<model_run_id>\", \"<model_run_id>\"]\n",
371371
"}\n",
372372
"\n",
373373
"# Note: Filters follow AND logic, so typically using one filter is sufficient.\n",
@@ -427,7 +427,7 @@
427427
"# stream_type=lb.StreamType.ERRORS\n",
428428
"# ).start()\n",
429429
"\n",
430-
"# if export_task.has_result(): \n",
430+
"# if export_task.has_result():\n",
431431
"# export_task.get_stream(\n",
432432
"# converter=lb.FileConverter(file_path=\"./result.txt\"),\n",
433433
"# stream_type=lb.StreamType.RESULT\n",
@@ -575,7 +575,7 @@
575575
"# stream_type=lb.StreamType.ERRORS\n",
576576
"# ).start()\n",
577577
"\n",
578-
"# if export_task.has_result(): \n",
578+
"# if export_task.has_result():\n",
579579
"# export_task.get_stream(\n",
580580
"# converter=lb.FileConverter(file_path=\"./result.txt\"),\n",
581581
"# stream_type=lb.StreamType.RESULT\n",
@@ -719,7 +719,7 @@
719719
"# stream_type=lb.StreamType.ERRORS\n",
720720
"# ).start()\n",
721721
"\n",
722-
"# if export_task.has_result(): \n",
722+
"# if export_task.has_result():\n",
723723
"# export_task.get_stream(\n",
724724
"# converter=lb.FileConverter(file_path=\"./result.txt\"),\n",
725725
"# stream_type=lb.StreamType.RESULT\n",
@@ -877,7 +877,7 @@
877877
{
878878
"metadata": {},
879879
"source": [
880-
"# Make the API request \n",
880+
"# Make the API request\n",
881881
"req = urllib.request.Request(mask_url, headers=client.headers)"
882882
],
883883
"cell_type": "code",

labelbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "labelbox"
22

3-
__version__ = "3.62.0"
3+
__version__ = "3.63.0"
44

55
from labelbox.client import Client
66
from labelbox.schema.project import Project

labelbox/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,14 @@ def get_error_status_code(error: dict) -> int:
299299
"extensions", "code")
300300
if internal_server_error is not None:
301301
message = internal_server_error.get("message")
302+
error_status_code = get_error_status_code(internal_server_error)
302303

303-
if get_error_status_code(internal_server_error) == 400:
304+
if error_status_code == 400:
304305
raise labelbox.exceptions.InvalidQueryError(message)
305-
elif get_error_status_code(internal_server_error) == 426:
306+
elif error_status_code == 426:
306307
raise labelbox.exceptions.OperationNotAllowedException(message)
308+
elif error_status_code == 500:
309+
raise labelbox.exceptions.LabelboxError(message)
307310
else:
308311
raise labelbox.exceptions.InternalServerError(message)
309312

labelbox/data/annotation_types/base_annotation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import abc
22
from uuid import UUID
33
from typing import Any, Dict, Optional
4-
from pydantic import PrivateAttr
4+
from labelbox import pydantic_compat
55

66
from .feature import FeatureSchema
77

88

99
class BaseAnnotation(FeatureSchema, abc.ABC):
1010
""" Base annotation class. Shouldn't be directly instantiated
1111
"""
12-
_uuid: Optional[UUID] = PrivateAttr()
12+
_uuid: Optional[UUID] = pydantic_compat.PrivateAttr()
1313
extra: Dict[str, Any] = {}
1414

1515
def __init__(self, **data):

labelbox/data/annotation_types/classification/classification.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
except:
1010
from typing_extensions import Literal
1111

12-
from pydantic import BaseModel, validator
12+
from labelbox import pydantic_compat
1313
from ..feature import FeatureSchema
1414

1515

1616
# TODO: Replace when pydantic adds support for unions that don't coerce types
17-
class _TempName(ConfidenceMixin, BaseModel):
17+
class _TempName(ConfidenceMixin, pydantic_compat.BaseModel):
1818
name: str
1919

2020
def dict(self, *args, **kwargs):
@@ -47,7 +47,7 @@ def dict(self, *args, **kwargs) -> Dict[str, str]:
4747
return res
4848

4949

50-
class Radio(ConfidenceMixin, CustomMetricsMixin, BaseModel):
50+
class Radio(ConfidenceMixin, CustomMetricsMixin, pydantic_compat.BaseModel):
5151
""" A classification with only one selected option allowed
5252
5353
>>> Radio(answer = ClassificationAnswer(name = "dog"))
@@ -66,7 +66,7 @@ class Checklist(_TempName):
6666
answer: List[ClassificationAnswer]
6767

6868

69-
class Text(ConfidenceMixin, CustomMetricsMixin, BaseModel):
69+
class Text(ConfidenceMixin, CustomMetricsMixin, pydantic_compat.BaseModel):
7070
""" Free form text
7171
7272
>>> Text(answer = "some text answer")

labelbox/data/annotation_types/data/base_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from abc import ABC
22
from typing import Optional, Dict, List, Any
33

4-
from pydantic import BaseModel
4+
from labelbox import pydantic_compat
55

66

7-
class BaseData(BaseModel, ABC):
7+
class BaseData(pydantic_compat.BaseModel, ABC):
88
"""
99
Base class for objects representing data.
1010
This class shouldn't directly be used

labelbox/data/annotation_types/data/raster.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55

66
from PIL import Image
77
from google.api_core import retry
8-
from pydantic import BaseModel
9-
from pydantic import root_validator
108
from requests.exceptions import ConnectTimeout
119
import requests
1210
import numpy as np
1311

12+
from labelbox import pydantic_compat
1413
from labelbox.exceptions import InternalServerError
1514
from .base_data import BaseData
1615
from ..types import TypedArray
1716

1817

19-
class RasterData(BaseModel, ABC):
18+
class RasterData(pydantic_compat.BaseModel, ABC):
2019
"""Represents an image or segmentation mask.
2120
"""
2221
im_bytes: Optional[bytes] = None
@@ -156,7 +155,7 @@ def create_url(self, signer: Callable[[bytes], str]) -> str:
156155
"One of url, im_bytes, file_path, arr must not be None.")
157156
return self.url
158157

159-
@root_validator()
158+
@pydantic_compat.root_validator()
160159
def validate_args(cls, values):
161160
file_path = values.get("file_path")
162161
im_bytes = values.get("im_bytes")

0 commit comments

Comments
 (0)