diff --git a/libs/labelbox/src/labelbox/client.py b/libs/labelbox/src/labelbox/client.py index b0b5a1407..055bee676 100644 --- a/libs/labelbox/src/labelbox/client.py +++ b/libs/labelbox/src/labelbox/client.py @@ -9,10 +9,9 @@ import urllib.parse from collections import defaultdict from datetime import datetime, timezone -from typing import Any, List, Dict, Union, Optional, overload, Callable from types import MappingProxyType +from typing import Any, Dict, List, Optional, Union, overload -from labelbox.schema.search_filters import SearchFilter import requests import requests.exceptions from google.api_core import retry @@ -26,20 +25,18 @@ from labelbox.orm.model import Entity, Field from labelbox.pagination import PaginatedCollection from labelbox.schema import role -from labelbox.schema.conflict_resolution_strategy import ( - ConflictResolutionStrategy, -) -from labelbox.schema.data_row import DataRow from labelbox.schema.catalog import Catalog +from labelbox.schema.data_row import DataRow from labelbox.schema.data_row_metadata import DataRowMetadataOntology from labelbox.schema.dataset import Dataset from labelbox.schema.embedding import Embedding from labelbox.schema.enums import CollectionJobStatus from labelbox.schema.foundry.foundry_client import FoundryClient from labelbox.schema.iam_integration import IAMIntegration -from labelbox.schema.identifiables import DataRowIds -from labelbox.schema.identifiables import GlobalKeys +from labelbox.schema.identifiables import DataRowIds, GlobalKeys +from labelbox.schema.label_score import LabelScore from labelbox.schema.labeling_frontend import LabelingFrontend +from labelbox.schema.labeling_service_dashboard import LabelingServiceDashboard from labelbox.schema.media_type import ( MediaType, get_media_type_validation_error, @@ -47,40 +44,40 @@ from labelbox.schema.model import Model from labelbox.schema.model_config import ModelConfig from labelbox.schema.model_run import ModelRun -from labelbox.schema.ontology import Ontology, DeleteFeatureFromOntologyResult from labelbox.schema.ontology import ( - Tool, Classification, + DeleteFeatureFromOntologyResult, FeatureSchema, + Ontology, PromptResponseClassification, + Tool, +) +from labelbox.schema.ontology_kind import ( + EditorTaskType, + EditorTaskTypeMapper, + OntologyKind, ) from labelbox.schema.organization import Organization from labelbox.schema.project import Project from labelbox.schema.quality_mode import ( - QualityMode, BENCHMARK_AUTO_AUDIT_NUMBER_OF_LABELS, BENCHMARK_AUTO_AUDIT_PERCENTAGE, CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS, 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 ( SendToAnnotateFromCatalogParams, + build_annotations_input, build_destination_task_queue_input, build_predictions_input, - build_annotations_input, ) from labelbox.schema.slice import CatalogSlice, ModelSlice -from labelbox.schema.task import Task, DataUpsertTask +from labelbox.schema.task import DataUpsertTask, Task from labelbox.schema.user import User -from labelbox.schema.label_score import LabelScore -from labelbox.schema.ontology_kind import ( - OntologyKind, - EditorTaskTypeMapper, - EditorTaskType, -) -from labelbox.schema.labeling_service_dashboard import LabelingServiceDashboard logger = logging.getLogger(__name__) @@ -540,7 +537,7 @@ def upload_data( error_msg = next(iter(errors), {}).get( "message", "Unknown error" ) - except Exception as e: + except Exception: error_msg = "Unknown error" raise labelbox.exceptions.LabelboxError( "Failed to upload, message: %s" % error_msg @@ -842,7 +839,7 @@ def create_dataset( if not validation_result["validateDataset"]["valid"]: raise labelbox.exceptions.LabelboxError( - f"IAMIntegration was not successfully added to the dataset." + "IAMIntegration was not successfully added to the dataset." ) except Exception as e: dataset.delete() diff --git a/libs/labelbox/tests/integration/test_labeling_service.py b/libs/labelbox/tests/integration/test_labeling_service.py index 09b5c24a1..04a1cb507 100644 --- a/libs/labelbox/tests/integration/test_labeling_service.py +++ b/libs/labelbox/tests/integration/test_labeling_service.py @@ -1,6 +1,9 @@ import pytest -from labelbox.exceptions import LabelboxError, ResourceNotFoundError +from labelbox.exceptions import ( + MalformedQueryException, + ResourceNotFoundError, +) from labelbox.schema.labeling_service import LabelingServiceStatus @@ -51,7 +54,7 @@ def test_request_labeling_service_moe_project( labeling_service = project.get_labeling_service() with pytest.raises( - LabelboxError, + MalformedQueryException, match='[{"errorType":"PROJECT_MODEL_CONFIG","errorMessage":"Project model config is not completed"}]', ): labeling_service.request() @@ -73,5 +76,5 @@ def test_request_labeling_service_incomplete_requirements(ontology, project): ): # No labeling service by default labeling_service.request() project.connect_ontology(ontology) - with pytest.raises(LabelboxError): + with pytest.raises(MalformedQueryException): labeling_service.request()