Skip to content

Vb/merge 5.2 2 #1867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0bbd7c2
Vb/fix ontology leaks plt 1379 (#1814)
vbrodsky Sep 17, 2024
51ecfea
[PTDT-2553] Added integration tests for MMC MAL/GT imports
real-mjozwiak Sep 9, 2024
8d078c8
[PTDT-2553] Added integration tests for MMC MAL/GT imports (#1795)
real-mjozwiak Sep 17, 2024
24e0766
SDK release v.5.0.0 prep (#1823)
vbrodsky Sep 17, 2024
2faf9a1
Vb/merge 5.0.0 (#1826)
vbrodsky Sep 18, 2024
2c0c677
Revert "Vb/merge 5.0.0 (#1826)" (#1827)
vbrodsky Sep 18, 2024
1c50842
Fix exception type for labeling service test (#1835)
vbrodsky Sep 23, 2024
929ca7f
Added merge environmental settings to prepared request (#1811)
Gabefire Sep 24, 2024
8724901
[PLT-1572] Add wait for label processing for annotation upload tests …
vbrodsky Sep 24, 2024
3493ef9
[PLT-1492] Fix 'flaky' tests spotted during a prod run (#1846)
vbrodsky Sep 27, 2024
45ce0a3
Support percent for rectangles. (#1848)
sfendell-labelbox Sep 27, 2024
2d2def2
v.5.1.0 release prep pr (#1849)
sfendell-labelbox Sep 27, 2024
cba1ce4
[PLT-1611] Vb/placeholder datarows (#1851)
vbrodsky Oct 1, 2024
994b6da
[PLT-0] Add missing tests (#1855)
mnoszczak Oct 7, 2024
58a3f4c
[PLT-1614] Support data row / batch for live mmc projects (#1856)
vbrodsky Oct 8, 2024
b58e902
Simplify some code. (#1857)
sfendell-labelbox Oct 8, 2024
ceafd63
Address QA feedback (#1859)
vbrodsky Oct 9, 2024
b0127cf
Release v.5.2.0 prep (#1860)
vbrodsky Oct 9, 2024
9a12709
Fix encoding for exporter (#1862)
vbrodsky Oct 10, 2024
a75c402
Release v.5.2.1 prep (#1863)
vbrodsky Oct 10, 2024
d96773e
Merge branch 'develop' into VB/merge_5.2-2
Oct 10, 2024
0560dc9
Fix create_model_evaluation_project
Oct 10, 2024
4f7b6bb
fixed export typos
Gabefire Oct 10, 2024
dcfb029
Update metadata to indicate 3.13 not supported yet
Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
project = 'Python SDK reference'
copyright = '2024, Labelbox'
author = 'Labelbox'
release = '5.1.0'
release = '5.2.1'

# -- General configuration ---------------------------------------------------

Expand Down
6 changes: 6 additions & 0 deletions docs/labelbox/datarow_payload_templates.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Datarow payload templates
===============================================================================================

.. automodule:: labelbox.schema.data_row_payload_templates
:members:
:show-inheritance:
10 changes: 9 additions & 1 deletion libs/labelbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog
# Version 5.1.0 (2024-09-27)
# Version 5.2.1 (2024-10-09)
## Fixed
* Exporter encoding

# Version 5.2.0 (2024-10-09)
## Added
* Support data row / batch for live mmc projects([#1856](https://github.com/Labelbox/labelbox-python/pull/1856))

# Version 5.1.0 (2024-09-27)
## Added
* Support self-signed SSL certs([#1811](https://github.com/Labelbox/labelbox-python/pull/1811))
* Rectangle units now correctly support percent inputs([#1848](https://github.com/Labelbox/labelbox-python/pull/1848))

Expand Down
4 changes: 2 additions & 2 deletions libs/labelbox/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "labelbox"
version = "5.1.0"
version = "5.2.1"
description = "Labelbox Python API"
authors = [{ name = "Labelbox", email = "engineering@labelbox.com" }]
dependencies = [
Expand All @@ -15,7 +15,7 @@ dependencies = [
"lbox-clients==1.1.0",
]
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.9,<3.13"
classifiers = [
# How mature is this project?
"Development Status :: 5 - Production/Stable",
Expand Down
64 changes: 43 additions & 21 deletions libs/labelbox/src/labelbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,58 @@
name = "labelbox"

__version__ = "5.1.0"
__version__ = "5.2.1"

from labelbox.client import Client
from labelbox.schema.project import Project
from labelbox.schema.model import Model
from labelbox.schema.model_config import ModelConfig
from labelbox.schema.annotation_import import (
LabelImport,
MALPredictionImport,
MEAPredictionImport,
LabelImport,
MEAToMALPredictionImport,
)
from labelbox.schema.dataset import Dataset
from labelbox.schema.data_row import DataRow
from labelbox.schema.asset_attachment import AssetAttachment
from labelbox.schema.batch import Batch
from labelbox.schema.benchmark import Benchmark
from labelbox.schema.catalog import Catalog
from labelbox.schema.data_row import DataRow
from labelbox.schema.data_row_metadata import (
DataRowMetadata,
DataRowMetadataField,
DataRowMetadataOntology,
DeleteDataRowMetadata,
)
from labelbox.schema.dataset import Dataset
from labelbox.schema.enums import AnnotationImportState
from labelbox.schema.label import Label
from labelbox.schema.batch import Batch
from labelbox.schema.review import Review
from labelbox.schema.user import User
from labelbox.schema.organization import Organization
from labelbox.schema.task import Task
from labelbox.schema.export_task import (
StreamType,
BufferedJsonConverterOutput,
ExportTask,
BufferedJsonConverterOutput,
)
from labelbox.schema.iam_integration import IAMIntegration
from labelbox.schema.identifiable import GlobalKey, UniqueId
from labelbox.schema.identifiables import DataRowIds, GlobalKeys, UniqueIds
from labelbox.schema.invite import Invite, InviteLimit
from labelbox.schema.label import Label
from labelbox.schema.label_score import LabelScore
from labelbox.schema.labeling_frontend import (
LabelingFrontend,
LabelingFrontendOptions,
)
from labelbox.schema.asset_attachment import AssetAttachment
from labelbox.schema.webhook import Webhook
from labelbox.schema.labeling_service import LabelingService
from labelbox.schema.labeling_service_dashboard import LabelingServiceDashboard
from labelbox.schema.labeling_service_status import LabelingServiceStatus
from labelbox.schema.media_type import MediaType
from labelbox.schema.model import Model
from labelbox.schema.model_config import ModelConfig
from labelbox.schema.model_run import DataSplit, ModelRun
from labelbox.schema.ontology import (
Classification,
FeatureSchema,
Ontology,
OntologyBuilder,
Classification,
Option,
PromptResponseClassification,
ResponseOption,
Tool,
FeatureSchema,
)
from labelbox.schema.ontology import PromptResponseClassification
from labelbox.schema.ontology import ResponseOption
Expand All @@ -64,10 +77,19 @@
from labelbox.schema.identifiables import UniqueIds, GlobalKeys, DataRowIds
from labelbox.schema.identifiable import UniqueId, GlobalKey
from labelbox.schema.ontology_kind import OntologyKind
from labelbox.schema.organization import Organization
from labelbox.schema.project import Project
from labelbox.schema.project_model_config import ProjectModelConfig
from labelbox.schema.project_overview import (
ProjectOverview,
ProjectOverviewDetailed,
)
from labelbox.schema.labeling_service import LabelingService
from labelbox.schema.labeling_service_dashboard import LabelingServiceDashboard
from labelbox.schema.labeling_service_status import LabelingServiceStatus
from labelbox.schema.project_resource_tag import ProjectResourceTag
from labelbox.schema.resource_tag import ResourceTag
from labelbox.schema.review import Review
from labelbox.schema.role import ProjectRole, Role
from labelbox.schema.slice import CatalogSlice, ModelSlice, Slice
from labelbox.schema.task import Task
from labelbox.schema.task_queue import TaskQueue
from labelbox.schema.user import User
from labelbox.schema.webhook import Webhook
26 changes: 14 additions & 12 deletions libs/labelbox/src/labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import random
import time
import urllib.parse
import warnings
from collections import defaultdict
from datetime import datetime, timezone
from types import MappingProxyType
Expand Down Expand Up @@ -584,7 +585,7 @@ def create_dataset(
)

if not validation_result["validateDataset"]["valid"]:
raise LabelboxError(
raise labelbox.exceptions.LabelboxError(
"IAMIntegration was not successfully added to the dataset."
)
except Exception as e:
Expand Down Expand Up @@ -649,7 +650,7 @@ def create_model_evaluation_project(
is_consensus_enabled: Optional[bool] = None,
dataset_id: Optional[str] = None,
dataset_name: Optional[str] = None,
data_row_count: int = 100,
data_row_count: Optional[int] = None,
) -> Project:
"""
Use this method exclusively to create a chat model evaluation project.
Expand All @@ -674,19 +675,20 @@ def create_model_evaluation_project(
>>> client.create_model_evaluation_project(name=project_name, dataset_id="clr00u8j0j0j0", data_row_count=10)
>>> 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.

>>> client.create_model_evaluation_project(name=project_name)
>>> This creates a new project with no data rows.

"""
if not dataset_id and not dataset_name:
raise ValueError(
"dataset_name or data_set_id must be present and not be an empty string."
)
dataset_name_or_id = dataset_id or dataset_name
append_to_existing_dataset = bool(dataset_id)

if dataset_id:
append_to_existing_dataset = True
dataset_name_or_id = dataset_id
else:
append_to_existing_dataset = False
dataset_name_or_id = dataset_name
if dataset_name_or_id:
if data_row_count is None:
data_row_count = 100
warnings.warn(
"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.",
DeprecationWarning,
)

media_type = MediaType.Conversational
editor_task_type = EditorTaskType.ModelChatEvaluation
Expand Down
10 changes: 3 additions & 7 deletions libs/labelbox/src/labelbox/data/annotation_types/collection.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import logging
from concurrent.futures import ThreadPoolExecutor, as_completed
from typing import Callable, Generator, Iterable, Union, Optional
from uuid import uuid4
import warnings
from typing import Callable, Generator, Iterable, Union

from tqdm import tqdm

from labelbox.schema import ontology
from labelbox.orm.model import Entity
from ..ontology import get_classifications, get_tools
from labelbox.schema import ontology

from ..generator import PrefetchGenerator
from .label import Label

Expand Down
3 changes: 3 additions & 0 deletions libs/labelbox/src/labelbox/project_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def validate_fields(self):
is_consensus_enabled=True,
)

if self.data_row_count is not None and self.data_row_count < 0:
raise ValueError("data_row_count must be a positive integer.")

return self

def _set_quality_mode_attributes(
Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/schema/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def export_v2(
"""

warnings.warn(
"You are currently utilizing export_v2 for this action, which will be deprecated in a V7. Please refer to docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
"You are currently utilizing export_v2 for this action, which will be removed in 7.0. Please refer to our docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
DeprecationWarning,
stacklevel=2,
)
Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/schema/data_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def export_v2(
"""

warnings.warn(
"You are currently utilizing export_v2 for this action, which will be deprecated in a V7. Please refer to docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
"You are currently utilizing export_v2 for this action, which will be removed in 7.0. Please refer to our docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
DeprecationWarning,
stacklevel=2,
)
Expand Down
41 changes: 41 additions & 0 deletions libs/labelbox/src/labelbox/schema/data_row_payload_templates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from typing import Dict, List, Optional

from pydantic import BaseModel, Field

from labelbox.schema.data_row import DataRowMetadataField


class ModelEvalutationTemplateRowData(BaseModel):
type: str = Field(
default="application/vnd.labelbox.conversational.model-chat-evaluation",
frozen=True,
)
draft: bool = Field(default=True, frozen=True)
rootMessageIds: List[str] = Field(default=[])
actors: Dict = Field(default={})
version: int = Field(default=2, frozen=True)
messages: Dict = Field(default={})
global_key: Optional[str] = None


class ModelEvaluationTemplate(BaseModel):
"""
Use this class to create a model evaluation data row.

Examples:
>>> data = ModelEvaluationTemplate()
>>> data.row_data.rootMessageIds = ["root1"]
>>> vector = [random.uniform(1.0, 2.0) for _ in range(embedding.dims)]
>>> data.embeddings = [...]
>>> data.metadata_fields = [...]
>>> data.attachments = [...]
>>> content = data.model_dump()
>>> task = dataset.create_data_rows([content])
"""

row_data: ModelEvalutationTemplateRowData = Field(
default=ModelEvalutationTemplateRowData()
)
attachments: List[Dict] = Field(default=[])
embeddings: List[Dict] = Field(default=[])
metadata_fields: List[DataRowMetadataField] = Field(default=[])
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/schema/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def export_v2(
"""

warnings.warn(
"You are currently utilizing export_v2 for this action, which will be deprecated in a V7. Please refer to docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
"You are currently utilizing export_v2 for this action, which will be removed in 7.0. Please refer to our docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
DeprecationWarning,
stacklevel=2,
)
Expand Down
14 changes: 8 additions & 6 deletions libs/labelbox/src/labelbox/schema/export_task.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import json
import os
import tempfile
import warnings
from abc import ABC, abstractmethod
from dataclasses import dataclass
from enum import Enum
from functools import lru_cache
import json
from typing import (
TYPE_CHECKING,
Any,
Callable,
Generic,
Iterator,
Optional,
Tuple,
TypeVar,
Union,
TYPE_CHECKING,
Any,
)

import requests
import tempfile
import os
from pydantic import BaseModel

from labelbox.schema.task import Task
from labelbox.utils import _CamelCaseMixin
from pydantic import BaseModel

if TYPE_CHECKING:
from labelbox import Client
Expand Down Expand Up @@ -120,6 +121,7 @@ def _get_file_content(
)
response = requests.get(file_info.file, timeout=30)
response.raise_for_status()
response.encoding = "utf-8"
assert (
len(response.content)
== file_info.offsets.end - file_info.offsets.start + 1
Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/schema/model_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def export_v2(
"""

warnings.warn(
"You are currently utilizing export_v2 for this action, which will be deprecated in a V7. Please refer to docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
"You are currently utilizing export_v2 for this action, which will be removed in 7.0. Please refer to our docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
DeprecationWarning,
stacklevel=2,
)
Expand Down
6 changes: 4 additions & 2 deletions libs/labelbox/src/labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def export_v2(
"""

warnings.warn(
"You are currently utilizing export_v2 for this action, which will be deprecated in a V7. Please refer to docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
"You are currently utilizing export_v2 for this action, which will be removed in 7.0. Please refer to our docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -739,7 +739,9 @@ def create_batch(
lbox.exceptions.ValueError if a project is not batch mode, if the project is auto data generation, if the batch exceeds 100k data rows
"""

if self.is_auto_data_generation():
if (
self.is_auto_data_generation() and not self.is_chat_evaluation()
): # NOTE live chat evaluatiuon projects in sdk do not pre-generate data rows, but use batch as all other projects
raise ValueError(
"Cannot create batches for auto data generation projects"
)
Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/schema/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def export_v2(
"""

warnings.warn(
"You are currently utilizing export_v2 for this action, which will be deprecated in a V7. Please refer to docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
"You are currently utilizing export_v2 for this action, which will be removed in 7.0. Please refer to our docs for export alternatives. https://docs.labelbox.com/reference/export-overview#export-methods",
DeprecationWarning,
stacklevel=2,
)
Expand Down
1 change: 1 addition & 0 deletions libs/labelbox/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Client,
DataRow,
Dataset,
LabelingFrontend,
MediaType,
OntologyBuilder,
Option,
Expand Down
Loading
Loading