Skip to content

Commit 8518df9

Browse files
author
Val Brodsky
committed
Merge branch 'develop' into VB/merge-5.2
2 parents 8e89cec + a75c402 commit 8518df9

20 files changed

+435
-194
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: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,62 @@
11
name = "labelbox"
22

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

55
from labelbox.client import Client
66
from labelbox.schema.project import Project
77
from labelbox.schema.model import Model
88
from labelbox.schema.model_config import ModelConfig
99
from labelbox.schema.annotation_import import (
10+
LabelImport,
1011
MALPredictionImport,
1112
MEAPredictionImport,
12-
LabelImport,
1313
MEAToMALPredictionImport,
1414
)
15-
from labelbox.schema.dataset import Dataset
16-
from labelbox.schema.data_row import DataRow
15+
from labelbox.schema.asset_attachment import AssetAttachment
16+
from labelbox.schema.batch import Batch
17+
from labelbox.schema.benchmark import Benchmark
18+
from labelbox.schema.bulk_import_request import BulkImportRequest
1719
from labelbox.schema.catalog import Catalog
20+
from labelbox.schema.data_row import DataRow
21+
from labelbox.schema.data_row_metadata import (
22+
DataRowMetadata,
23+
DataRowMetadataField,
24+
DataRowMetadataOntology,
25+
DeleteDataRowMetadata,
26+
)
27+
from labelbox.schema.dataset import Dataset
1828
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
2529
from labelbox.schema.export_task import (
26-
StreamType,
30+
BufferedJsonConverterOutput,
2731
ExportTask,
2832
BufferedJsonConverterOutput,
2933
)
34+
from labelbox.schema.iam_integration import IAMIntegration
35+
from labelbox.schema.identifiable import GlobalKey, UniqueId
36+
from labelbox.schema.identifiables import DataRowIds, GlobalKeys, UniqueIds
37+
from labelbox.schema.invite import Invite, InviteLimit
38+
from labelbox.schema.label import Label
39+
from labelbox.schema.label_score import LabelScore
3040
from labelbox.schema.labeling_frontend import (
3141
LabelingFrontend,
3242
LabelingFrontendOptions,
3343
)
34-
from labelbox.schema.asset_attachment import AssetAttachment
35-
from labelbox.schema.webhook import Webhook
44+
from labelbox.schema.labeling_service import LabelingService
45+
from labelbox.schema.labeling_service_dashboard import LabelingServiceDashboard
46+
from labelbox.schema.labeling_service_status import LabelingServiceStatus
47+
from labelbox.schema.media_type import MediaType
48+
from labelbox.schema.model import Model
49+
from labelbox.schema.model_config import ModelConfig
50+
from labelbox.schema.model_run import DataSplit, ModelRun
3651
from labelbox.schema.ontology import (
52+
Classification,
53+
FeatureSchema,
3754
Ontology,
3855
OntologyBuilder,
39-
Classification,
4056
Option,
57+
PromptResponseClassification,
58+
ResponseOption,
4159
Tool,
42-
FeatureSchema,
4360
)
4461
from labelbox.schema.ontology import PromptResponseClassification
4562
from labelbox.schema.ontology import ResponseOption
@@ -64,10 +81,20 @@
6481
from labelbox.schema.identifiables import UniqueIds, GlobalKeys, DataRowIds
6582
from labelbox.schema.identifiable import UniqueId, GlobalKey
6683
from labelbox.schema.ontology_kind import OntologyKind
84+
from labelbox.schema.organization import Organization
85+
from labelbox.schema.project import Project
86+
from labelbox.schema.project_model_config import ProjectModelConfig
6787
from labelbox.schema.project_overview import (
6888
ProjectOverview,
6989
ProjectOverviewDetailed,
7090
)
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
91+
from labelbox.schema.project_resource_tag import ProjectResourceTag
92+
from labelbox.schema.queue_mode import QueueMode
93+
from labelbox.schema.resource_tag import ResourceTag
94+
from labelbox.schema.review import Review
95+
from labelbox.schema.role import ProjectRole, Role
96+
from labelbox.schema.slice import CatalogSlice, ModelSlice, Slice
97+
from labelbox.schema.task import Task
98+
from labelbox.schema.task_queue import TaskQueue
99+
from labelbox.schema.user import User
100+
from labelbox.schema.webhook import Webhook

libs/labelbox/src/labelbox/client.py

Lines changed: 45 additions & 7 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,11 @@ def create_dataset(
584585
)
585586

586587
if not validation_result["validateDataset"]["valid"]:
588+
<<<<<<< HEAD
587589
raise LabelboxError(
590+
=======
591+
raise labelbox.exceptions.LabelboxError(
592+
>>>>>>> develop
588593
"IAMIntegration was not successfully added to the dataset."
589594
)
590595
except Exception as e:
@@ -637,6 +642,7 @@ def create_project(
637642
}
638643
return self._create_project(_CoreProjectInput(**input))
639644

645+
@overload
640646
def create_model_evaluation_project(
641647
self,
642648
name: str,
@@ -649,7 +655,21 @@ def create_model_evaluation_project(
649655
is_consensus_enabled: Optional[bool] = None,
650656
dataset_id: Optional[str] = None,
651657
dataset_name: Optional[str] = None,
658+
<<<<<<< HEAD
652659
data_row_count: int = 100,
660+
=======
661+
data_row_count: Optional[int] = None,
662+
**kwargs,
663+
) -> Project:
664+
pass
665+
666+
def create_model_evaluation_project(
667+
self,
668+
dataset_id: Optional[str] = None,
669+
dataset_name: Optional[str] = None,
670+
data_row_count: Optional[int] = None,
671+
**kwargs,
672+
>>>>>>> develop
653673
) -> Project:
654674
"""
655675
Use this method exclusively to create a chat model evaluation project.
@@ -674,22 +694,40 @@ def create_model_evaluation_project(
674694
>>> client.create_model_evaluation_project(name=project_name, dataset_id="clr00u8j0j0j0", data_row_count=10)
675695
>>> 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.
676696
697+
>>> client.create_model_evaluation_project(name=project_name)
698+
>>> This creates a new project with no data rows.
677699
678700
"""
701+
<<<<<<< HEAD
679702
if not dataset_id and not dataset_name:
680703
raise ValueError(
681704
"dataset_name or data_set_id must be present and not be an empty string."
682705
)
706+
=======
707+
dataset_name_or_id = dataset_id or dataset_name
708+
append_to_existing_dataset = bool(dataset_id)
709+
>>>>>>> develop
710+
711+
if dataset_name_or_id:
712+
kwargs["dataset_name_or_id"] = dataset_name_or_id
713+
kwargs["append_to_existing_dataset"] = append_to_existing_dataset
714+
if data_row_count is None:
715+
data_row_count = 100
716+
if data_row_count < 0:
717+
raise ValueError("data_row_count must be a positive integer.")
718+
kwargs["data_row_count"] = data_row_count
719+
warnings.warn(
720+
"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.",
721+
DeprecationWarning,
722+
)
683723

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
690-
724+
<<<<<<< HEAD
691725
media_type = MediaType.Conversational
692726
editor_task_type = EditorTaskType.ModelChatEvaluation
727+
=======
728+
kwargs["media_type"] = MediaType.Conversational
729+
kwargs["editor_task_type"] = EditorTaskType.ModelChatEvaluation.value
730+
>>>>>>> develop
693731

694732
input = {
695733
"name": name,

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/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
LabelboxError,
1313
ResourceCreationError,
1414
ResourceNotFoundError,
15-
) # type: ignore
15+
)
1616

1717
import labelbox.schema.internal.data_row_uploader as data_row_uploader
1818
from labelbox.orm import query

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

0 commit comments

Comments
 (0)