Skip to content

Commit 6528cbc

Browse files
authored
[PLT-1487] Remaining sdk deprecated items removed (#1853)
1 parent da184c8 commit 6528cbc

File tree

20 files changed

+6
-540
lines changed

20 files changed

+6
-540
lines changed

libs/labelbox/src/labelbox/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
from labelbox.schema.project_resource_tag import ProjectResourceTag
6060
from labelbox.schema.media_type import MediaType
6161
from labelbox.schema.slice import Slice, CatalogSlice, ModelSlice
62-
from labelbox.schema.queue_mode import QueueMode
6362
from labelbox.schema.task_queue import TaskQueue
6463
from labelbox.schema.label_score import LabelScore
6564
from labelbox.schema.identifiables import UniqueIds, GlobalKeys, DataRowIds

libs/labelbox/src/labelbox/client.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
CONSENSUS_AUTO_AUDIT_PERCENTAGE,
7373
QualityMode,
7474
)
75-
from labelbox.schema.queue_mode import QueueMode
7675
from labelbox.schema.role import Role
7776
from labelbox.schema.search_filters import SearchFilter
7877
from labelbox.schema.send_to_annotate_params import (
@@ -468,13 +467,11 @@ def _create(self, db_object_type, data, extra_params={}):
468467
res = self.execute(
469468
query_string, params, raise_return_resource_not_found=True
470469
)
471-
472470
if not res:
473471
raise LabelboxError(
474472
"Failed to create %s" % db_object_type.type_name()
475473
)
476474
res = res["create%s" % db_object_type.type_name()]
477-
478475
return db_object_type(self, res)
479476

480477
def create_model_config(
@@ -621,7 +618,6 @@ def create_project(
621618
name (str): A name for the project
622619
description (str): A short summary for the project
623620
media_type (MediaType): The type of assets that this project will accept
624-
queue_mode (Optional[QueueMode]): The queue mode to use
625621
quality_modes (Optional[List[QualityMode]]): The quality modes to use (e.g. Benchmark, Consensus). Defaults to
626622
Benchmark.
627623
is_benchmark_enabled (Optional[bool]): Whether the project supports benchmark. Defaults to None.
@@ -853,11 +849,7 @@ def create_response_creation_project(
853849
return self._create_project(_CoreProjectInput(**input))
854850

855851
def _create_project(self, input: _CoreProjectInput) -> Project:
856-
media_type_value = input.media_type.value
857-
858852
params = input.model_dump(exclude_none=True)
859-
if media_type_value:
860-
params["media_type"] = media_type_value
861853

862854
extra_params = {
863855
Field.String("dataset_name_or_id"): params.pop(
@@ -1644,10 +1636,6 @@ def get_data_row_ids_for_global_keys(
16441636
"""
16451637
Gets data row ids for a list of global keys.
16461638
1647-
Deprecation Notice: This function will soon no longer return 'Deleted Data Rows'
1648-
as part of the 'results'. Global keys for deleted data rows will soon be placed
1649-
under 'Data Row not found' portion.
1650-
16511639
Args:
16521640
A list of global keys
16531641
Returns:

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,6 @@ def __init__(self, data: Generator[Label, None, None], *args, **kwargs):
2525
self._fns = {}
2626
super().__init__(data, *args, **kwargs)
2727

28-
def assign_feature_schema_ids(
29-
self, ontology_builder: "ontology.OntologyBuilder"
30-
) -> "LabelGenerator":
31-
def _assign_ids(label: Label):
32-
label.assign_feature_schema_ids(ontology_builder)
33-
return label
34-
35-
warnings.warn(
36-
"This method is deprecated and will be "
37-
"removed in a future release. Feature schema ids"
38-
" are no longer required for importing."
39-
)
40-
self._fns["assign_feature_schema_ids"] = _assign_ids
41-
return self
42-
4328
def add_url_to_masks(
4429
self, signer: Callable[[bytes], str]
4530
) -> "LabelGenerator":

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

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -136,42 +136,6 @@ def create_data_row(
136136
self.data.external_id = data_row.external_id
137137
return self
138138

139-
def assign_feature_schema_ids(
140-
self, ontology_builder: ontology.OntologyBuilder
141-
) -> "Label":
142-
"""
143-
Adds schema ids to all FeatureSchema objects in the Labels.
144-
145-
Args:
146-
ontology_builder: The ontology that matches the feature names assigned to objects in this dataset
147-
Returns:
148-
Label. useful for chaining these modifying functions
149-
150-
Note: You can now import annotations using names directly without having to lookup schema_ids
151-
"""
152-
warnings.warn(
153-
"This method is deprecated and will be "
154-
"removed in a future release. Feature schema ids"
155-
" are no longer required for importing."
156-
)
157-
tool_lookup, classification_lookup = get_feature_schema_lookup(
158-
ontology_builder
159-
)
160-
for annotation in self.annotations:
161-
if isinstance(annotation, ClassificationAnnotation):
162-
self._assign_or_raise(annotation, classification_lookup)
163-
self._assign_option(annotation, classification_lookup)
164-
elif isinstance(annotation, ObjectAnnotation):
165-
self._assign_or_raise(annotation, tool_lookup)
166-
for classification in annotation.classifications:
167-
self._assign_or_raise(classification, classification_lookup)
168-
self._assign_option(classification, classification_lookup)
169-
else:
170-
raise TypeError(
171-
f"Unexpected type found for annotation. {type(annotation)}"
172-
)
173-
return self
174-
175139
def _assign_or_raise(self, annotation, lookup: Dict[str, str]) -> None:
176140
if annotation.feature_schema_id is not None:
177141
return

libs/labelbox/src/labelbox/project_validation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
CONSENSUS_AUTO_AUDIT_PERCENTAGE,
1212
QualityMode,
1313
)
14-
from labelbox.schema.queue_mode import QueueMode
1514

1615
PositiveInt = Annotated[int, Field(gt=0)]
1716

@@ -20,7 +19,6 @@ class _CoreProjectInput(BaseModel):
2019
name: str
2120
description: Optional[str] = None
2221
media_type: MediaType
23-
queue_mode: QueueMode = Field(default=QueueMode.Batch, frozen=True)
2422
auto_audit_percentage: Optional[float] = None
2523
auto_audit_number_of_labels: Optional[int] = None
2624
quality_modes: Optional[Set[QualityMode]] = Field(
@@ -33,7 +31,7 @@ class _CoreProjectInput(BaseModel):
3331
data_row_count: Optional[PositiveInt] = None
3432
editor_task_type: Optional[EditorTaskType] = None
3533

36-
model_config = ConfigDict(extra="forbid")
34+
model_config = ConfigDict(extra="forbid", use_enum_values=True)
3735

3836
@model_validator(mode="after")
3937
def validate_fields(self):

libs/labelbox/src/labelbox/schema/asset_attachment.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77

88

99
class AttachmentType(str, Enum):
10-
@classmethod
11-
def __missing__(cls, value: object):
12-
if str(value) == "TEXT":
13-
warnings.warn(
14-
"The TEXT attachment type is deprecated. Use RAW_TEXT instead."
15-
)
16-
return cls.RAW_TEXT
17-
return value
18-
1910
VIDEO = "VIDEO"
2011
IMAGE = "IMAGE"
2112
IMAGE_OVERLAY = "IMAGE_OVERLAY"
@@ -30,7 +21,7 @@ class AssetAttachment(DbObject):
3021
"""Asset attachment provides extra context about an asset while labeling.
3122
3223
Attributes:
33-
attachment_type (str): IMAGE, VIDEO, IMAGE_OVERLAY, HTML, RAW_TEXT, TEXT_URL, or PDF_URL. TEXT attachment type is deprecated.
24+
attachment_type (str): IMAGE, VIDEO, IMAGE_OVERLAY, HTML, RAW_TEXT, TEXT_URL, or PDF_URL.
3425
attachment_value (str): URL to an external file or a string of text
3526
attachment_name (str): The name of the attachment
3627
"""

libs/labelbox/src/labelbox/schema/data_row_metadata.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,8 @@ def bulk_delete(
673673
if not len(deletes):
674674
raise ValueError("The 'deletes' list cannot be empty.")
675675

676-
passed_strings = False
677676
for i, delete in enumerate(deletes):
678677
if isinstance(delete.data_row_id, str):
679-
passed_strings = True
680678
deletes[i] = DeleteDataRowMetadata(
681679
data_row_id=UniqueId(delete.data_row_id),
682680
fields=delete.fields,
@@ -690,12 +688,6 @@ def bulk_delete(
690688
f"Invalid data row identifier type '{type(delete.data_row_id)}' for '{delete.data_row_id}'"
691689
)
692690

693-
if passed_strings:
694-
warnings.warn(
695-
"Using string for data row id will be deprecated. Please use "
696-
"UniqueId instead."
697-
)
698-
699691
def _batch_delete(
700692
deletes: List[_DeleteBatchDataRowMetadata],
701693
) -> List[DataRowMetadataBatchResponse]:

libs/labelbox/src/labelbox/schema/dataset.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -166,49 +166,9 @@ def create_data_row(self, items=None, **kwargs) -> "DataRow":
166166

167167
return self.client.get_data_row(res[0]["id"])
168168

169-
def create_data_rows_sync(
170-
self, items, file_upload_thread_count=FILE_UPLOAD_THREAD_COUNT
171-
) -> None:
172-
"""Synchronously bulk upload data rows.
173-
174-
Use this instead of `Dataset.create_data_rows` for smaller batches of data rows that need to be uploaded quickly.
175-
Cannot use this for uploads containing more than 1000 data rows.
176-
Each data row is also limited to 5 attachments.
177-
178-
Args:
179-
items (iterable of (dict or str)):
180-
See the docstring for `Dataset._create_descriptor_file` for more information.
181-
Returns:
182-
None. If the function doesn't raise an exception then the import was successful.
183-
184-
Raises:
185-
ResourceCreationError: If the `items` parameter does not conform to
186-
the specification in Dataset._create_descriptor_file or if the server did not accept the
187-
DataRow creation request (unknown reason).
188-
InvalidAttributeError: If there are fields in `items` not valid for
189-
a DataRow.
190-
ValueError: When the upload parameters are invalid
191-
"""
192-
warnings.warn(
193-
"This method is deprecated and will be "
194-
"removed in a future release. Please use create_data_rows instead."
195-
)
196-
197-
self._create_data_rows_sync(
198-
items, file_upload_thread_count=file_upload_thread_count
199-
)
200-
201-
return None # Return None if no exception is raised
202-
203169
def _create_data_rows_sync(
204170
self, items, file_upload_thread_count=FILE_UPLOAD_THREAD_COUNT
205171
) -> "DataUpsertTask":
206-
max_data_rows_supported = 1000
207-
if len(items) > max_data_rows_supported:
208-
raise ValueError(
209-
f"Dataset.create_data_rows_sync() supports a max of {max_data_rows_supported} data rows."
210-
" For larger imports use the async function Dataset.create_data_rows()"
211-
)
212172
if file_upload_thread_count < 1:
213173
raise ValueError(
214174
"file_upload_thread_count must be a positive integer"
@@ -235,8 +195,6 @@ def create_data_rows(
235195
) -> "DataUpsertTask":
236196
"""Asynchronously bulk upload data rows
237197
238-
Use this instead of `Dataset.create_data_rows_sync` uploads for batches that contain more than 1000 data rows.
239-
240198
Args:
241199
items (iterable of (dict or str))
242200

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
ProjectOverview,
6262
ProjectOverviewDetailed,
6363
)
64-
from labelbox.schema.queue_mode import QueueMode
6564
from labelbox.schema.resource_tag import ResourceTag
6665
from labelbox.schema.task import Task
6766
from labelbox.schema.task_queue import TaskQueue
@@ -109,7 +108,6 @@ class Project(DbObject, Updateable, Deletable):
109108
created_at (datetime)
110109
setup_complete (datetime)
111110
last_activity_time (datetime)
112-
queue_mode (string)
113111
auto_audit_number_of_labels (int)
114112
auto_audit_percentage (float)
115113
is_benchmark_enabled (bool)
@@ -132,7 +130,6 @@ class Project(DbObject, Updateable, Deletable):
132130
created_at = Field.DateTime("created_at")
133131
setup_complete = Field.DateTime("setup_complete")
134132
last_activity_time = Field.DateTime("last_activity_time")
135-
queue_mode = Field.Enum(QueueMode, "queue_mode")
136133
auto_audit_number_of_labels = Field.Int("auto_audit_number_of_labels")
137134
auto_audit_percentage = Field.Float("auto_audit_percentage")
138135
# Bind data_type and allowedMediaTYpe using the GraphQL type MediaType
@@ -734,9 +731,6 @@ def create_batch(
734731
Raises:
735732
lbox.exceptions.ValueError if a project is not batch mode, if the project is auto data generation, if the batch exceeds 100k data rows
736733
"""
737-
# @TODO: make this automatic?
738-
if self.queue_mode != QueueMode.Batch:
739-
raise ValueError("Project must be in batch mode")
740734

741735
if self.is_auto_data_generation():
742736
raise ValueError(
@@ -816,9 +810,6 @@ def create_batches(
816810
Returns: a task for the created batches
817811
"""
818812

819-
if self.queue_mode != QueueMode.Batch:
820-
raise ValueError("Project must be in batch mode")
821-
822813
dr_ids = []
823814
if data_rows is not None:
824815
for dr in data_rows:
@@ -901,9 +892,6 @@ def create_batches_from_dataset(
901892
Returns: a task for the created batches
902893
"""
903894

904-
if self.queue_mode != QueueMode.Batch:
905-
raise ValueError("Project must be in batch mode")
906-
907895
if consensus_settings:
908896
consensus_settings = ConsensusSettings(
909897
**consensus_settings

libs/labelbox/src/labelbox/schema/queue_mode.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)