From 1f9b874fcb7e9020ebfb29cce0caf6d10503192d Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Thu, 14 Nov 2024 17:32:53 -0800 Subject: [PATCH 1/2] Remove experimental where not needed --- libs/labelbox/src/labelbox/client.py | 1 - .../src/labelbox/schema/labeling_service.py | 4 ---- .../schema/labeling_service_dashboard.py | 7 +------ libs/labelbox/src/labelbox/schema/model_run.py | 17 +++++------------ libs/labelbox/src/labelbox/schema/project.py | 17 +++++++---------- 5 files changed, 13 insertions(+), 33 deletions(-) diff --git a/libs/labelbox/src/labelbox/client.py b/libs/labelbox/src/labelbox/client.py index 76aff8257..6d1b7f092 100644 --- a/libs/labelbox/src/labelbox/client.py +++ b/libs/labelbox/src/labelbox/client.py @@ -2026,7 +2026,6 @@ def get_batch(self, project_id: str, batch_id: str) -> Entity.Batch: get_batch_str, {"projectId": project_id, "batchId": batch_id}, timeout=180.0, - experimental=True, )["project"]["batches"]["nodes"][0] return Entity.Batch(self, project_id, batch) diff --git a/libs/labelbox/src/labelbox/schema/labeling_service.py b/libs/labelbox/src/labelbox/schema/labeling_service.py index 0b7dab6bd..c71034aeb 100644 --- a/libs/labelbox/src/labelbox/schema/labeling_service.py +++ b/libs/labelbox/src/labelbox/schema/labeling_service.py @@ -26,10 +26,6 @@ class LabelingService(_CamelCaseMixin): def __init__(self, **kwargs): super().__init__(**kwargs) - if not self.client.enable_experimental: - raise RuntimeError( - "Please enable experimental in client to use LabelingService" - ) @classmethod def start(cls, client, project_id: Cuid) -> "LabelingService": diff --git a/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py b/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py index b8e2fe226..9179a4665 100644 --- a/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py +++ b/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py @@ -83,10 +83,6 @@ class LabelingServiceDashboard(_CamelCaseMixin): def __init__(self, **kwargs): super().__init__(**kwargs) - if not self.client.enable_experimental: - raise RuntimeError( - "Please enable experimental in client to use LabelingService" - ) @property def service_type(self): @@ -140,7 +136,7 @@ def get(cls, client, project_id: str) -> "LabelingServiceDashboard": }} }} """ - result = client.execute(query, {"id": project_id}, experimental=True) + result = client.execute(query, {"id": project_id}) if result["getProjectById"] is None: raise ResourceNotFoundError( message="The project does not have a labeling service data yet." @@ -196,7 +192,6 @@ def convert_to_labeling_service_dashboard(client, data): dereferencing=["searchProjects", "nodes"], obj_class=convert_to_labeling_service_dashboard, cursor_path=["searchProjects", "pageInfo", "endCursor"], - experimental=True, ) @model_validator(mode="before") diff --git a/libs/labelbox/src/labelbox/schema/model_run.py b/libs/labelbox/src/labelbox/schema/model_run.py index 94ffb29dd..f64681c08 100644 --- a/libs/labelbox/src/labelbox/schema/model_run.py +++ b/libs/labelbox/src/labelbox/schema/model_run.py @@ -7,18 +7,17 @@ from pathlib import Path from typing import ( TYPE_CHECKING, + Any, Dict, Iterable, - Union, - Tuple, List, Optional, - Any, + Tuple, + Union, ) - from labelbox.orm.db_object import DbObject, experimental -from labelbox.orm.model import Field, Relationship, Entity +from labelbox.orm.model import Entity, Field, Relationship from labelbox.orm.query import results_query_part from labelbox.pagination import PaginatedCollection from labelbox.schema.conflict_resolution_strategy import ( @@ -26,7 +25,7 @@ ) from labelbox.schema.export_params import ModelRunExportParams from labelbox.schema.export_task import ExportTask -from labelbox.schema.identifiables import GlobalKeys, DataRowIds +from labelbox.schema.identifiables import DataRowIds, GlobalKeys from labelbox.schema.send_to_annotate_params import ( SendToAnnotateFromModelParams, build_destination_task_queue_input, @@ -458,7 +457,6 @@ def update_status( experimental=True, ) - @experimental def update_config(self, config: Dict[str, Any]) -> Dict[str, Any]: """ Updates the Model Run's training metadata config @@ -474,11 +472,9 @@ def update_config(self, config: Dict[str, Any]) -> Dict[str, Any]: } """, {"modelRunId": self.uid, "data": data}, - experimental=True, ) return res["updateModelRunConfig"] - @experimental def reset_config(self) -> Dict[str, Any]: """ Resets Model Run's training metadata config @@ -491,11 +487,9 @@ def reset_config(self) -> Dict[str, Any]: } """, {"modelRunId": self.uid}, - experimental=True, ) return res["resetModelRunConfig"] - @experimental def get_config(self) -> Dict[str, Any]: """ Gets Model Run's training metadata @@ -508,7 +502,6 @@ def get_config(self) -> Dict[str, Any]: } """, {"modelRunId": self.uid}, - experimental=True, ) return res["modelRun"]["trainingMetadata"] diff --git a/libs/labelbox/src/labelbox/schema/project.py b/libs/labelbox/src/labelbox/schema/project.py index 9f753bf79..2589e6ab1 100644 --- a/libs/labelbox/src/labelbox/schema/project.py +++ b/libs/labelbox/src/labelbox/schema/project.py @@ -26,7 +26,7 @@ from labelbox import utils from labelbox.orm import query -from labelbox.orm.db_object import DbObject, Deletable, Updateable, experimental +from labelbox.orm.db_object import DbObject, Deletable, Updateable from labelbox.orm.model import Entity, Field, Relationship from labelbox.pagination import PaginatedCollection from labelbox.schema.consensus_settings import ConsensusSettings @@ -861,9 +861,9 @@ def create_batches( }, } - tasks = self.client.execute(mutation_str, params, experimental=True)[ - "project" - ][method]["tasks"] + tasks = self.client.execute(mutation_str, params)["project"][method][ + "tasks" + ] batch_ids = [task["batchUuid"] for task in tasks] task_ids = [task["taskId"] for task in tasks] @@ -926,9 +926,9 @@ def create_batches_from_dataset( }, } - tasks = self.client.execute(mutation_str, params, experimental=True)[ - "project" - ][method]["tasks"] + tasks = self.client.execute(mutation_str, params)["project"][method][ + "tasks" + ] batch_ids = [task["batchUuid"] for task in tasks] task_ids = [task["taskId"] for task in tasks] @@ -1595,7 +1595,6 @@ def clone(self) -> "Project": result = self.client.execute(mutation, {"projectId": self.uid}) return self.client.get_project(result["cloneProject"]["id"]) - @experimental def get_labeling_service(self) -> LabelingService: """Get the labeling service for this project. @@ -1606,7 +1605,6 @@ def get_labeling_service(self) -> LabelingService: """ return LabelingService.getOrCreate(self.client, self.uid) - @experimental def get_labeling_service_status(self) -> LabelingServiceStatus: """Get the labeling service status for this project. @@ -1618,7 +1616,6 @@ def get_labeling_service_status(self) -> LabelingServiceStatus: """ return self.get_labeling_service().status - @experimental def get_labeling_service_dashboard(self) -> LabelingServiceDashboard: """Get the labeling service for this project. From f45fc0dfc24eb441e3fda3101c15d741ef6a146b Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Fri, 15 Nov 2024 10:20:53 -0800 Subject: [PATCH 2/2] Restore enable_experimental setter --- libs/labelbox/src/labelbox/client.py | 4 ++++ libs/labelbox/tests/unit/test_client.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/libs/labelbox/src/labelbox/client.py b/libs/labelbox/src/labelbox/client.py index 6d1b7f092..ec50fa97f 100644 --- a/libs/labelbox/src/labelbox/client.py +++ b/libs/labelbox/src/labelbox/client.py @@ -147,6 +147,10 @@ def rest_endpoint(self) -> str: def enable_experimental(self) -> bool: return self._request_client.enable_experimental + @enable_experimental.setter + def enable_experimental(self, value: bool): + self._request_client.enable_experimental = value + @property def app_url(self) -> str: return self._request_client.app_url diff --git a/libs/labelbox/tests/unit/test_client.py b/libs/labelbox/tests/unit/test_client.py index 718e47f65..3f3d51566 100644 --- a/libs/labelbox/tests/unit/test_client.py +++ b/libs/labelbox/tests/unit/test_client.py @@ -9,3 +9,8 @@ def test_headers(): assert client.headers["Content-Type"] == "application/json" assert client.headers["User-Agent"] assert client.headers["X-Python-Version"] + + +def test_enable_experimental(): + client = Client(api_key="api_key", enable_experimental=True) + assert client.enable_experimental