Skip to content

Commit 912d564

Browse files
author
Val Brodsky
committed
Merge branch 'develop' into VB/merge_5.2-2
2 parents 182aa67 + a75c402 commit 912d564

20 files changed

+391
-170
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
project = 'Python SDK reference'
1717
copyright = '2024, Labelbox'
1818
author = 'Labelbox'
19-
release = '5.1.0'
19+
release = '5.2.1'
2020

2121
# -- General configuration ---------------------------------------------------
2222

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Datarow payload templates
2+
===============================================================================================
3+
4+
.. automodule:: labelbox.schema.data_row_payload_templates
5+
:members:
6+
:show-inheritance:

libs/labelbox/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Changelog
2-
# Version 5.1.0 (2024-09-27)
2+
# Version 5.2.1 (2024-10-09)
33
## Fixed
4+
* Exporter encoding
5+
6+
# Version 5.2.0 (2024-10-09)
7+
## Added
8+
* Support data row / batch for live mmc projects([#1856](https://github.com/Labelbox/labelbox-python/pull/1856))
9+
10+
# Version 5.1.0 (2024-09-27)
11+
## Added
412
* Support self-signed SSL certs([#1811](https://github.com/Labelbox/labelbox-python/pull/1811))
513
* Rectangle units now correctly support percent inputs([#1848](https://github.com/Labelbox/labelbox-python/pull/1848))
614

libs/labelbox/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "labelbox"
3-
version = "5.1.0"
3+
version = "5.2.1"
44
description = "Labelbox Python API"
55
authors = [{ name = "Labelbox", email = "engineering@labelbox.com" }]
66
dependencies = [
Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,58 @@
11
name = "labelbox"
22

3-
__version__ = "5.1.0"
3+
__version__ = "5.2.1"
44

55
from labelbox.client import Client
6-
from labelbox.schema.project import Project
7-
from labelbox.schema.model import Model
8-
from labelbox.schema.model_config import ModelConfig
96
from labelbox.schema.annotation_import import (
7+
LabelImport,
108
MALPredictionImport,
119
MEAPredictionImport,
12-
LabelImport,
1310
MEAToMALPredictionImport,
1411
)
15-
from labelbox.schema.dataset import Dataset
16-
from labelbox.schema.data_row import DataRow
12+
from labelbox.schema.asset_attachment import AssetAttachment
13+
from labelbox.schema.batch import Batch
14+
from labelbox.schema.benchmark import Benchmark
1715
from labelbox.schema.catalog import Catalog
16+
from labelbox.schema.data_row import DataRow
17+
from labelbox.schema.data_row_metadata import (
18+
DataRowMetadata,
19+
DataRowMetadataField,
20+
DataRowMetadataOntology,
21+
DeleteDataRowMetadata,
22+
)
23+
from labelbox.schema.dataset import Dataset
1824
from labelbox.schema.enums import AnnotationImportState
19-
from labelbox.schema.label import Label
20-
from labelbox.schema.batch import Batch
21-
from labelbox.schema.review import Review
22-
from labelbox.schema.user import User
23-
from labelbox.schema.organization import Organization
24-
from labelbox.schema.task import Task
2525
from labelbox.schema.export_task import (
26-
StreamType,
26+
BufferedJsonConverterOutput,
2727
ExportTask,
2828
BufferedJsonConverterOutput,
2929
)
30+
from labelbox.schema.iam_integration import IAMIntegration
31+
from labelbox.schema.identifiable import GlobalKey, UniqueId
32+
from labelbox.schema.identifiables import DataRowIds, GlobalKeys, UniqueIds
33+
from labelbox.schema.invite import Invite, InviteLimit
34+
from labelbox.schema.label import Label
35+
from labelbox.schema.label_score import LabelScore
3036
from labelbox.schema.labeling_frontend import (
3137
LabelingFrontend,
3238
LabelingFrontendOptions,
3339
)
34-
from labelbox.schema.asset_attachment import AssetAttachment
35-
from labelbox.schema.webhook import Webhook
40+
from labelbox.schema.labeling_service import LabelingService
41+
from labelbox.schema.labeling_service_dashboard import LabelingServiceDashboard
42+
from labelbox.schema.labeling_service_status import LabelingServiceStatus
43+
from labelbox.schema.media_type import MediaType
44+
from labelbox.schema.model import Model
45+
from labelbox.schema.model_config import ModelConfig
46+
from labelbox.schema.model_run import DataSplit, ModelRun
3647
from labelbox.schema.ontology import (
48+
Classification,
49+
FeatureSchema,
3750
Ontology,
3851
OntologyBuilder,
39-
Classification,
4052
Option,
53+
PromptResponseClassification,
54+
ResponseOption,
4155
Tool,
42-
FeatureSchema,
4356
)
4457
from labelbox.schema.ontology import PromptResponseClassification
4558
from labelbox.schema.ontology import ResponseOption
@@ -64,10 +77,20 @@
6477
from labelbox.schema.identifiables import UniqueIds, GlobalKeys, DataRowIds
6578
from labelbox.schema.identifiable import UniqueId, GlobalKey
6679
from labelbox.schema.ontology_kind import OntologyKind
80+
from labelbox.schema.organization import Organization
81+
from labelbox.schema.project import Project
82+
from labelbox.schema.project_model_config import ProjectModelConfig
6783
from labelbox.schema.project_overview import (
6884
ProjectOverview,
6985
ProjectOverviewDetailed,
7086
)
71-
from labelbox.schema.labeling_service import LabelingService
72-
from labelbox.schema.labeling_service_dashboard import LabelingServiceDashboard
73-
from labelbox.schema.labeling_service_status import LabelingServiceStatus
87+
from labelbox.schema.project_resource_tag import ProjectResourceTag
88+
from labelbox.schema.queue_mode import QueueMode
89+
from labelbox.schema.resource_tag import ResourceTag
90+
from labelbox.schema.review import Review
91+
from labelbox.schema.role import ProjectRole, Role
92+
from labelbox.schema.slice import CatalogSlice, ModelSlice, Slice
93+
from labelbox.schema.task import Task
94+
from labelbox.schema.task_queue import TaskQueue
95+
from labelbox.schema.user import User
96+
from labelbox.schema.webhook import Webhook

libs/labelbox/src/labelbox/client.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import random
77
import time
88
import urllib.parse
9+
import warnings
910
from collections import defaultdict
1011
from datetime import datetime, timezone
1112
from types import MappingProxyType
@@ -584,7 +585,7 @@ def create_dataset(
584585
)
585586

586587
if not validation_result["validateDataset"]["valid"]:
587-
raise LabelboxError(
588+
raise labelbox.exceptions.LabelboxError(
588589
"IAMIntegration was not successfully added to the dataset."
589590
)
590591
except Exception as e:
@@ -637,6 +638,7 @@ def create_project(
637638
}
638639
return self._create_project(_CoreProjectInput(**input))
639640

641+
@overload
640642
def create_model_evaluation_project(
641643
self,
642644
name: str,
@@ -649,7 +651,17 @@ def create_model_evaluation_project(
649651
is_consensus_enabled: Optional[bool] = None,
650652
dataset_id: Optional[str] = None,
651653
dataset_name: Optional[str] = None,
652-
data_row_count: int = 100,
654+
data_row_count: Optional[int] = None,
655+
**kwargs,
656+
) -> Project:
657+
pass
658+
659+
def create_model_evaluation_project(
660+
self,
661+
dataset_id: Optional[str] = None,
662+
dataset_name: Optional[str] = None,
663+
data_row_count: Optional[int] = None,
664+
**kwargs,
653665
) -> Project:
654666
"""
655667
Use this method exclusively to create a chat model evaluation project.
@@ -674,19 +686,25 @@ def create_model_evaluation_project(
674686
>>> client.create_model_evaluation_project(name=project_name, dataset_id="clr00u8j0j0j0", data_row_count=10)
675687
>>> This creates a new project, and adds 100 datarows to the dataset with id "clr00u8j0j0j0" and assigns a batch of the newly created 10 data rows to the project.
676688
689+
>>> client.create_model_evaluation_project(name=project_name)
690+
>>> This creates a new project with no data rows.
677691
678692
"""
679-
if not dataset_id and not dataset_name:
680-
raise ValueError(
681-
"dataset_name or data_set_id must be present and not be an empty string."
682-
)
693+
dataset_name_or_id = dataset_id or dataset_name
694+
append_to_existing_dataset = bool(dataset_id)
683695

684-
if dataset_id:
685-
append_to_existing_dataset = True
686-
dataset_name_or_id = dataset_id
687-
else:
688-
append_to_existing_dataset = False
689-
dataset_name_or_id = dataset_name
696+
if dataset_name_or_id:
697+
kwargs["dataset_name_or_id"] = dataset_name_or_id
698+
kwargs["append_to_existing_dataset"] = append_to_existing_dataset
699+
if data_row_count is None:
700+
data_row_count = 100
701+
if data_row_count < 0:
702+
raise ValueError("data_row_count must be a positive integer.")
703+
kwargs["data_row_count"] = data_row_count
704+
warnings.warn(
705+
"Automatic generation of data rows of live model evaluation projects is deprecated. dataset_name_or_id, append_to_existing_dataset, data_row_count will be removed in a future version.",
706+
DeprecationWarning,
707+
)
690708

691709
media_type = MediaType.Conversational
692710
editor_task_type = EditorTaskType.ModelChatEvaluation

libs/labelbox/src/labelbox/data/annotation_types/collection.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import logging
2-
from concurrent.futures import ThreadPoolExecutor, as_completed
3-
from typing import Callable, Generator, Iterable, Union, Optional
4-
from uuid import uuid4
52
import warnings
3+
from typing import Callable, Generator, Iterable, Union
64

7-
from tqdm import tqdm
8-
9-
from labelbox.schema import ontology
105
from labelbox.orm.model import Entity
11-
from ..ontology import get_classifications, get_tools
6+
from labelbox.schema import ontology
7+
128
from ..generator import PrefetchGenerator
139
from .label import Label
1410

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from typing import Dict, List, Optional
2+
3+
from pydantic import BaseModel, Field
4+
5+
from labelbox.schema.data_row import DataRowMetadataField
6+
7+
8+
class ModelEvalutationTemplateRowData(BaseModel):
9+
type: str = Field(
10+
default="application/vnd.labelbox.conversational.model-chat-evaluation",
11+
frozen=True,
12+
)
13+
draft: bool = Field(default=True, frozen=True)
14+
rootMessageIds: List[str] = Field(default=[])
15+
actors: Dict = Field(default={})
16+
version: int = Field(default=2, frozen=True)
17+
messages: Dict = Field(default={})
18+
global_key: Optional[str] = None
19+
20+
21+
class ModelEvaluationTemplate(BaseModel):
22+
"""
23+
Use this class to create a model evaluation data row.
24+
25+
Examples:
26+
>>> data = ModelEvaluationTemplate()
27+
>>> data.row_data.rootMessageIds = ["root1"]
28+
>>> vector = [random.uniform(1.0, 2.0) for _ in range(embedding.dims)]
29+
>>> data.embeddings = [...]
30+
>>> data.metadata_fields = [...]
31+
>>> data.attachments = [...]
32+
>>> content = data.model_dump()
33+
>>> task = dataset.create_data_rows([content])
34+
"""
35+
36+
row_data: ModelEvalutationTemplateRowData = Field(
37+
default=ModelEvalutationTemplateRowData()
38+
)
39+
attachments: List[Dict] = Field(default=[])
40+
embeddings: List[Dict] = Field(default=[])
41+
metadata_fields: List[DataRowMetadataField] = Field(default=[])

libs/labelbox/src/labelbox/schema/export_task.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1+
import json
2+
import os
3+
import tempfile
4+
import warnings
15
from abc import ABC, abstractmethod
26
from dataclasses import dataclass
37
from enum import Enum
48
from functools import lru_cache
5-
import json
69
from typing import (
10+
TYPE_CHECKING,
11+
Any,
712
Callable,
813
Generic,
914
Iterator,
1015
Optional,
1116
Tuple,
1217
TypeVar,
1318
Union,
14-
TYPE_CHECKING,
15-
Any,
1619
)
1720

1821
import requests
19-
import tempfile
20-
import os
22+
from pydantic import BaseModel
2123

2224
from labelbox.schema.task import Task
2325
from labelbox.utils import _CamelCaseMixin
24-
from pydantic import BaseModel
2526

2627
if TYPE_CHECKING:
2728
from labelbox import Client
@@ -120,6 +121,7 @@ def _get_file_content(
120121
)
121122
response = requests.get(file_info.file, timeout=30)
122123
response.raise_for_status()
124+
response.encoding = "utf-8"
123125
assert (
124126
len(response.content)
125127
== file_info.offsets.end - file_info.offsets.start + 1

libs/labelbox/src/labelbox/schema/project.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,9 @@ def create_batch(
739739
lbox.exceptions.ValueError if a project is not batch mode, if the project is auto data generation, if the batch exceeds 100k data rows
740740
"""
741741

742-
if self.is_auto_data_generation():
742+
if (
743+
self.is_auto_data_generation() and not self.is_chat_evaluation()
744+
): # NOTE live chat evaluatiuon projects in sdk do not pre-generate data rows, but use batch as all other projects
743745
raise ValueError(
744746
"Cannot create batches for auto data generation projects"
745747
)

0 commit comments

Comments
 (0)