Skip to content

Commit c186ca9

Browse files
authored
Merge pull request #271 from Labelbox/develop
3.3.0
2 parents c33fc04 + e89b9aa commit c186ca9

Some content is hidden

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

47 files changed

+1146
-247
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
# Version 3.3.0 (2021-09-02)
4+
## Added
5+
* `Dataset.create_data_rows_sync()` for synchronous bulk uploads of data rows
6+
* `Model.delete()`, `ModelRun.delete()`, and `ModelRun.delete_annotation_groups()` to
7+
Clean up models, model runs, and annotation groups.
8+
9+
## Fix
10+
* Increased timeout for label exports since projects with many segmentation masks weren't finishing quickly enough.
11+
312
# Version 3.2.1 (2021-08-31)
413
## Fix
514
* Resolved issue with `create_data_rows()` was not working on amazon linux

labelbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "labelbox"
2-
__version__ = "3.2.1"
2+
__version__ = "3.3.0"
33

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

labelbox/data/annotation_types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@
2929
from .collection import LabelGenerator
3030

3131
from .metrics import ScalarMetric
32+
from .metrics import MetricAggregation

labelbox/data/annotation_types/annotation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from typing import Any, Dict, List, Union
22

3-
from pydantic.main import BaseModel
4-
53
from .classification import Checklist, Dropdown, Radio, Text
64
from .feature import FeatureSchema
75
from .geometry import Geometry
@@ -16,6 +14,7 @@ class BaseAnnotation(FeatureSchema):
1614

1715
class ClassificationAnnotation(BaseAnnotation):
1816
"""Class representing classification annotations (annotations that don't have a location) """
17+
1918
value: Union[Text, Checklist, Radio, Dropdown]
2019

2120

labelbox/data/annotation_types/classification/classification.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
from typing import Any, Dict, List
22

3-
from pydantic.main import BaseModel
3+
try:
4+
from typing import Literal
5+
except:
6+
from typing_extensions import Literal
47

8+
from pydantic import BaseModel, validator
59
from ..feature import FeatureSchema
610

711

12+
# TODO: Replace when pydantic adds support for unions that don't coerce types
13+
class _TempName(BaseModel):
14+
name: str
15+
16+
def dict(self, *args, **kwargs):
17+
res = super().dict(*args, **kwargs)
18+
res.pop('name')
19+
return res
20+
21+
822
class ClassificationAnswer(FeatureSchema):
923
"""
1024
- Represents a classification option.
@@ -19,8 +33,9 @@ class Radio(BaseModel):
1933
answer: ClassificationAnswer
2034

2135

22-
class Checklist(BaseModel):
36+
class Checklist(_TempName):
2337
""" A classification with many selected options allowed """
38+
name: Literal["checklist"] = "checklist"
2439
answer: List[ClassificationAnswer]
2540

2641

@@ -29,9 +44,10 @@ class Text(BaseModel):
2944
answer: str
3045

3146

32-
class Dropdown(BaseModel):
47+
class Dropdown(_TempName):
3348
"""
3449
- A classification with many selected options allowed .
3550
- This is not currently compatible with MAL.
3651
"""
52+
name: Literal["dropdown"] = "dropdown"
3753
answer: List[ClassificationAnswer]

labelbox/data/annotation_types/data/raster.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def value(self) -> np.ndarray:
8181
with open(self.file_path, "rb") as img:
8282
im_bytes = img.read()
8383
self.im_bytes = im_bytes
84-
return self.bytes_to_np(im_bytes)
84+
arr = self.bytes_to_np(im_bytes)
85+
return arr
8586
elif self.url is not None:
8687
im_bytes = self.fetch_remote()
8788
self.im_bytes = im_bytes
@@ -92,7 +93,7 @@ def value(self) -> np.ndarray:
9293
def set_fetch_fn(self, fn):
9394
object.__setattr__(self, 'fetch_remote', lambda: fn(self))
9495

95-
@retry.Retry(deadline=15.)
96+
@retry.Retry(deadline=60.)
9697
def fetch_remote(self) -> bytes:
9798
"""
9899
Method for accessing url.
@@ -104,7 +105,7 @@ def fetch_remote(self) -> bytes:
104105
response.raise_for_status()
105106
return response.content
106107

107-
@retry.Retry(deadline=15.)
108+
@retry.Retry(deadline=30.)
108109
def create_url(self, signer: Callable[[bytes], str]) -> str:
109110
"""
110111
Utility for creating a url from any of the other image representations.

labelbox/data/annotation_types/label.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections import defaultdict
2+
from labelbox.data.annotation_types.metrics.scalar import ScalarMetric
23

34
from typing import Any, Callable, Dict, List, Union, Optional
45

@@ -21,7 +22,8 @@ class Label(BaseModel):
2122
data: Union[VideoData, ImageData, TextData]
2223
annotations: List[Union[ClassificationAnnotation, ObjectAnnotation,
2324
VideoObjectAnnotation,
24-
VideoClassificationAnnotation, ScalarMetric]] = []
25+
VideoClassificationAnnotation, ScalarMetric,
26+
ScalarMetric]] = []
2527
extra: Dict[str, Any] = {}
2628

2729
def object_annotations(self) -> List[ObjectAnnotation]:

labelbox/data/annotation_types/metrics.py

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .scalar import ScalarMetric
2+
from .aggregations import MetricAggregation
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from enum import Enum
2+
3+
4+
class MetricAggregation(Enum):
5+
ARITHMETIC_MEAN = "ARITHMETIC_MEAN"
6+
GEOMETRIC_MEAN = "GEOMETRIC_MEAN"
7+
HARMONIC_MEAN = "HARMONIC_MEAN"
8+
SUM = "SUM"

0 commit comments

Comments
 (0)