Skip to content

[PLT-1487] Remaining sdk deprecated items removed #1853

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 20 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion libs/labelbox/src/labelbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
from labelbox.schema.project_resource_tag import ProjectResourceTag
from labelbox.schema.media_type import MediaType
from labelbox.schema.slice import Slice, CatalogSlice, ModelSlice
from labelbox.schema.queue_mode import QueueMode
from labelbox.schema.task_queue import TaskQueue
from labelbox.schema.label_score import LabelScore
from labelbox.schema.identifiables import UniqueIds, GlobalKeys, DataRowIds
Expand Down
12 changes: 0 additions & 12 deletions libs/labelbox/src/labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
CONSENSUS_AUTO_AUDIT_PERCENTAGE,
QualityMode,
)
from labelbox.schema.queue_mode import QueueMode
from labelbox.schema.role import Role
from labelbox.schema.search_filters import SearchFilter
from labelbox.schema.send_to_annotate_params import (
Expand Down Expand Up @@ -468,13 +467,11 @@ def _create(self, db_object_type, data, extra_params={}):
res = self.execute(
query_string, params, raise_return_resource_not_found=True
)

if not res:
raise LabelboxError(
"Failed to create %s" % db_object_type.type_name()
)
res = res["create%s" % db_object_type.type_name()]

return db_object_type(self, res)

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

def _create_project(self, input: _CoreProjectInput) -> Project:
media_type_value = input.media_type.value

params = input.model_dump(exclude_none=True)
if media_type_value:
params["media_type"] = media_type_value

extra_params = {
Field.String("dataset_name_or_id"): params.pop(
Expand Down Expand Up @@ -1644,10 +1636,6 @@ def get_data_row_ids_for_global_keys(
"""
Gets data row ids for a list of global keys.

Deprecation Notice: This function will soon no longer return 'Deleted Data Rows'
as part of the 'results'. Global keys for deleted data rows will soon be placed
under 'Data Row not found' portion.

Args:
A list of global keys
Returns:
Expand Down
15 changes: 0 additions & 15 deletions libs/labelbox/src/labelbox/data/annotation_types/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,6 @@ def __init__(self, data: Generator[Label, None, None], *args, **kwargs):
self._fns = {}
super().__init__(data, *args, **kwargs)

def assign_feature_schema_ids(
self, ontology_builder: "ontology.OntologyBuilder"
) -> "LabelGenerator":
def _assign_ids(label: Label):
label.assign_feature_schema_ids(ontology_builder)
return label

warnings.warn(
"This method is deprecated and will be "
"removed in a future release. Feature schema ids"
" are no longer required for importing."
)
self._fns["assign_feature_schema_ids"] = _assign_ids
return self

def add_url_to_masks(
self, signer: Callable[[bytes], str]
) -> "LabelGenerator":
Expand Down
36 changes: 0 additions & 36 deletions libs/labelbox/src/labelbox/data/annotation_types/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,42 +136,6 @@ def create_data_row(
self.data.external_id = data_row.external_id
return self

def assign_feature_schema_ids(
self, ontology_builder: ontology.OntologyBuilder
) -> "Label":
"""
Adds schema ids to all FeatureSchema objects in the Labels.

Args:
ontology_builder: The ontology that matches the feature names assigned to objects in this dataset
Returns:
Label. useful for chaining these modifying functions

Note: You can now import annotations using names directly without having to lookup schema_ids
"""
warnings.warn(
"This method is deprecated and will be "
"removed in a future release. Feature schema ids"
" are no longer required for importing."
)
tool_lookup, classification_lookup = get_feature_schema_lookup(
ontology_builder
)
for annotation in self.annotations:
if isinstance(annotation, ClassificationAnnotation):
self._assign_or_raise(annotation, classification_lookup)
self._assign_option(annotation, classification_lookup)
elif isinstance(annotation, ObjectAnnotation):
self._assign_or_raise(annotation, tool_lookup)
for classification in annotation.classifications:
self._assign_or_raise(classification, classification_lookup)
self._assign_option(classification, classification_lookup)
else:
raise TypeError(
f"Unexpected type found for annotation. {type(annotation)}"
)
return self

def _assign_or_raise(self, annotation, lookup: Dict[str, str]) -> None:
if annotation.feature_schema_id is not None:
return
Expand Down
4 changes: 1 addition & 3 deletions libs/labelbox/src/labelbox/project_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
CONSENSUS_AUTO_AUDIT_PERCENTAGE,
QualityMode,
)
from labelbox.schema.queue_mode import QueueMode

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

Expand All @@ -20,7 +19,6 @@ class _CoreProjectInput(BaseModel):
name: str
description: Optional[str] = None
media_type: MediaType
queue_mode: QueueMode = Field(default=QueueMode.Batch, frozen=True)
auto_audit_percentage: Optional[float] = None
auto_audit_number_of_labels: Optional[int] = None
quality_modes: Optional[Set[QualityMode]] = Field(
Expand All @@ -33,7 +31,7 @@ class _CoreProjectInput(BaseModel):
data_row_count: Optional[PositiveInt] = None
editor_task_type: Optional[EditorTaskType] = None

model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(extra="forbid", use_enum_values=True)

@model_validator(mode="after")
def validate_fields(self):
Expand Down
11 changes: 1 addition & 10 deletions libs/labelbox/src/labelbox/schema/asset_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@


class AttachmentType(str, Enum):
@classmethod
def __missing__(cls, value: object):
if str(value) == "TEXT":
warnings.warn(
"The TEXT attachment type is deprecated. Use RAW_TEXT instead."
)
return cls.RAW_TEXT
return value

VIDEO = "VIDEO"
IMAGE = "IMAGE"
IMAGE_OVERLAY = "IMAGE_OVERLAY"
Expand All @@ -30,7 +21,7 @@ class AssetAttachment(DbObject):
"""Asset attachment provides extra context about an asset while labeling.

Attributes:
attachment_type (str): IMAGE, VIDEO, IMAGE_OVERLAY, HTML, RAW_TEXT, TEXT_URL, or PDF_URL. TEXT attachment type is deprecated.
attachment_type (str): IMAGE, VIDEO, IMAGE_OVERLAY, HTML, RAW_TEXT, TEXT_URL, or PDF_URL.
attachment_value (str): URL to an external file or a string of text
attachment_name (str): The name of the attachment
"""
Expand Down
8 changes: 0 additions & 8 deletions libs/labelbox/src/labelbox/schema/data_row_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,8 @@ def bulk_delete(
if not len(deletes):
raise ValueError("The 'deletes' list cannot be empty.")

passed_strings = False
for i, delete in enumerate(deletes):
if isinstance(delete.data_row_id, str):
passed_strings = True
deletes[i] = DeleteDataRowMetadata(
data_row_id=UniqueId(delete.data_row_id),
fields=delete.fields,
Expand All @@ -690,12 +688,6 @@ def bulk_delete(
f"Invalid data row identifier type '{type(delete.data_row_id)}' for '{delete.data_row_id}'"
)

if passed_strings:
warnings.warn(
"Using string for data row id will be deprecated. Please use "
"UniqueId instead."
)

def _batch_delete(
deletes: List[_DeleteBatchDataRowMetadata],
) -> List[DataRowMetadataBatchResponse]:
Expand Down
42 changes: 0 additions & 42 deletions libs/labelbox/src/labelbox/schema/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,49 +166,9 @@ def create_data_row(self, items=None, **kwargs) -> "DataRow":

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

def create_data_rows_sync(
self, items, file_upload_thread_count=FILE_UPLOAD_THREAD_COUNT
) -> None:
"""Synchronously bulk upload data rows.

Use this instead of `Dataset.create_data_rows` for smaller batches of data rows that need to be uploaded quickly.
Cannot use this for uploads containing more than 1000 data rows.
Each data row is also limited to 5 attachments.

Args:
items (iterable of (dict or str)):
See the docstring for `Dataset._create_descriptor_file` for more information.
Returns:
None. If the function doesn't raise an exception then the import was successful.

Raises:
ResourceCreationError: If the `items` parameter does not conform to
the specification in Dataset._create_descriptor_file or if the server did not accept the
DataRow creation request (unknown reason).
InvalidAttributeError: If there are fields in `items` not valid for
a DataRow.
ValueError: When the upload parameters are invalid
"""
warnings.warn(
"This method is deprecated and will be "
"removed in a future release. Please use create_data_rows instead."
)

self._create_data_rows_sync(
items, file_upload_thread_count=file_upload_thread_count
)

return None # Return None if no exception is raised

def _create_data_rows_sync(
self, items, file_upload_thread_count=FILE_UPLOAD_THREAD_COUNT
) -> "DataUpsertTask":
max_data_rows_supported = 1000
if len(items) > max_data_rows_supported:
raise ValueError(
f"Dataset.create_data_rows_sync() supports a max of {max_data_rows_supported} data rows."
" For larger imports use the async function Dataset.create_data_rows()"
)
if file_upload_thread_count < 1:
raise ValueError(
"file_upload_thread_count must be a positive integer"
Expand All @@ -235,8 +195,6 @@ def create_data_rows(
) -> "DataUpsertTask":
"""Asynchronously bulk upload data rows

Use this instead of `Dataset.create_data_rows_sync` uploads for batches that contain more than 1000 data rows.

Args:
items (iterable of (dict or str))

Expand Down
12 changes: 0 additions & 12 deletions libs/labelbox/src/labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
ProjectOverview,
ProjectOverviewDetailed,
)
from labelbox.schema.queue_mode import QueueMode
from labelbox.schema.resource_tag import ResourceTag
from labelbox.schema.task import Task
from labelbox.schema.task_queue import TaskQueue
Expand Down Expand Up @@ -109,7 +108,6 @@ class Project(DbObject, Updateable, Deletable):
created_at (datetime)
setup_complete (datetime)
last_activity_time (datetime)
queue_mode (string)
auto_audit_number_of_labels (int)
auto_audit_percentage (float)
is_benchmark_enabled (bool)
Expand All @@ -132,7 +130,6 @@ class Project(DbObject, Updateable, Deletable):
created_at = Field.DateTime("created_at")
setup_complete = Field.DateTime("setup_complete")
last_activity_time = Field.DateTime("last_activity_time")
queue_mode = Field.Enum(QueueMode, "queue_mode")
auto_audit_number_of_labels = Field.Int("auto_audit_number_of_labels")
auto_audit_percentage = Field.Float("auto_audit_percentage")
# Bind data_type and allowedMediaTYpe using the GraphQL type MediaType
Expand Down Expand Up @@ -734,9 +731,6 @@ def create_batch(
Raises:
lbox.exceptions.ValueError if a project is not batch mode, if the project is auto data generation, if the batch exceeds 100k data rows
"""
# @TODO: make this automatic?
if self.queue_mode != QueueMode.Batch:
raise ValueError("Project must be in batch mode")

if self.is_auto_data_generation():
raise ValueError(
Expand Down Expand Up @@ -816,9 +810,6 @@ def create_batches(
Returns: a task for the created batches
"""

if self.queue_mode != QueueMode.Batch:
raise ValueError("Project must be in batch mode")

dr_ids = []
if data_rows is not None:
for dr in data_rows:
Expand Down Expand Up @@ -901,9 +892,6 @@ def create_batches_from_dataset(
Returns: a task for the created batches
"""

if self.queue_mode != QueueMode.Batch:
raise ValueError("Project must be in batch mode")

if consensus_settings:
consensus_settings = ConsensusSettings(
**consensus_settings
Expand Down
12 changes: 0 additions & 12 deletions libs/labelbox/src/labelbox/schema/queue_mode.py

This file was deleted.

37 changes: 0 additions & 37 deletions libs/labelbox/src/labelbox/schema/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,43 +53,6 @@ class CatalogSlice(Slice):
Represents a Slice used for filtering data rows in Catalog.
"""

def get_data_row_ids(self) -> PaginatedCollection:
"""
Fetches all data row ids that match this Slice

Returns:
A PaginatedCollection of mapping of data row ids to global keys
"""

warnings.warn(
"get_data_row_ids will be deprecated. Use get_data_row_identifiers instead"
)

query_str = """
query getDataRowIdsBySavedQueryPyApi($id: ID!, $from: String, $first: Int!) {
getDataRowIdsBySavedQuery(input: {
savedQueryId: $id,
after: $from
first: $first
}) {
totalCount
nodes
pageInfo {
endCursor
hasNextPage
}
}
}
"""
return PaginatedCollection(
client=self.client,
query=query_str,
params={"id": str(self.uid)},
dereferencing=["getDataRowIdsBySavedQuery", "nodes"],
obj_class=lambda _, data_row_id: data_row_id,
cursor_path=["getDataRowIdsBySavedQuery", "pageInfo", "endCursor"],
)

def get_data_row_identifiers(self) -> PaginatedCollection:
"""
Fetches all data row ids and global keys (where defined) that match this Slice
Expand Down
2 changes: 0 additions & 2 deletions libs/labelbox/src/labelbox/schema/user_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from labelbox.schema.media_type import MediaType
from labelbox.schema.ontology_kind import EditorTaskType
from labelbox.schema.project import Project
from labelbox.schema.queue_mode import QueueMode
from labelbox.schema.user import User


Expand Down Expand Up @@ -411,7 +410,6 @@ def _get_projects_set(self, project_nodes):
project_values = defaultdict(lambda: None)
project_values["id"] = project["id"]
project_values["name"] = project["name"]
project_values["queueMode"] = QueueMode.Batch.value
project_values["editorTaskType"] = EditorTaskType.Missing.value
project_values["mediaType"] = MediaType.Image.value
projects.add(Project(self.client, project_values))
Expand Down
Loading
Loading