Skip to content

Commit 1c50842

Browse files
authored
Fix exception type for labeling service test (#1835)
1 parent 2c0c677 commit 1c50842

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

libs/labelbox/src/labelbox/client.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
import urllib.parse
1010
from collections import defaultdict
1111
from datetime import datetime, timezone
12-
from typing import Any, List, Dict, Union, Optional, overload, Callable
1312
from types import MappingProxyType
13+
from typing import Any, Dict, List, Optional, Union, overload
1414

15-
from labelbox.schema.search_filters import SearchFilter
1615
import requests
1716
import requests.exceptions
1817
from google.api_core import retry
@@ -26,61 +25,59 @@
2625
from labelbox.orm.model import Entity, Field
2726
from labelbox.pagination import PaginatedCollection
2827
from labelbox.schema import role
29-
from labelbox.schema.conflict_resolution_strategy import (
30-
ConflictResolutionStrategy,
31-
)
32-
from labelbox.schema.data_row import DataRow
3328
from labelbox.schema.catalog import Catalog
29+
from labelbox.schema.data_row import DataRow
3430
from labelbox.schema.data_row_metadata import DataRowMetadataOntology
3531
from labelbox.schema.dataset import Dataset
3632
from labelbox.schema.embedding import Embedding
3733
from labelbox.schema.enums import CollectionJobStatus
3834
from labelbox.schema.foundry.foundry_client import FoundryClient
3935
from labelbox.schema.iam_integration import IAMIntegration
40-
from labelbox.schema.identifiables import DataRowIds
41-
from labelbox.schema.identifiables import GlobalKeys
36+
from labelbox.schema.identifiables import DataRowIds, GlobalKeys
37+
from labelbox.schema.label_score import LabelScore
4238
from labelbox.schema.labeling_frontend import LabelingFrontend
39+
from labelbox.schema.labeling_service_dashboard import LabelingServiceDashboard
4340
from labelbox.schema.media_type import (
4441
MediaType,
4542
get_media_type_validation_error,
4643
)
4744
from labelbox.schema.model import Model
4845
from labelbox.schema.model_config import ModelConfig
4946
from labelbox.schema.model_run import ModelRun
50-
from labelbox.schema.ontology import Ontology, DeleteFeatureFromOntologyResult
5147
from labelbox.schema.ontology import (
52-
Tool,
5348
Classification,
49+
DeleteFeatureFromOntologyResult,
5450
FeatureSchema,
51+
Ontology,
5552
PromptResponseClassification,
53+
Tool,
54+
)
55+
from labelbox.schema.ontology_kind import (
56+
EditorTaskType,
57+
EditorTaskTypeMapper,
58+
OntologyKind,
5659
)
5760
from labelbox.schema.organization import Organization
5861
from labelbox.schema.project import Project
5962
from labelbox.schema.quality_mode import (
60-
QualityMode,
6163
BENCHMARK_AUTO_AUDIT_NUMBER_OF_LABELS,
6264
BENCHMARK_AUTO_AUDIT_PERCENTAGE,
6365
CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS,
6466
CONSENSUS_AUTO_AUDIT_PERCENTAGE,
67+
QualityMode,
6568
)
6669
from labelbox.schema.queue_mode import QueueMode
6770
from labelbox.schema.role import Role
71+
from labelbox.schema.search_filters import SearchFilter
6872
from labelbox.schema.send_to_annotate_params import (
6973
SendToAnnotateFromCatalogParams,
74+
build_annotations_input,
7075
build_destination_task_queue_input,
7176
build_predictions_input,
72-
build_annotations_input,
7377
)
7478
from labelbox.schema.slice import CatalogSlice, ModelSlice
75-
from labelbox.schema.task import Task, DataUpsertTask
79+
from labelbox.schema.task import DataUpsertTask, Task
7680
from labelbox.schema.user import User
77-
from labelbox.schema.label_score import LabelScore
78-
from labelbox.schema.ontology_kind import (
79-
OntologyKind,
80-
EditorTaskTypeMapper,
81-
EditorTaskType,
82-
)
83-
from labelbox.schema.labeling_service_dashboard import LabelingServiceDashboard
8481

8582
logger = logging.getLogger(__name__)
8683

@@ -540,7 +537,7 @@ def upload_data(
540537
error_msg = next(iter(errors), {}).get(
541538
"message", "Unknown error"
542539
)
543-
except Exception as e:
540+
except Exception:
544541
error_msg = "Unknown error"
545542
raise labelbox.exceptions.LabelboxError(
546543
"Failed to upload, message: %s" % error_msg
@@ -842,7 +839,7 @@ def create_dataset(
842839

843840
if not validation_result["validateDataset"]["valid"]:
844841
raise labelbox.exceptions.LabelboxError(
845-
f"IAMIntegration was not successfully added to the dataset."
842+
"IAMIntegration was not successfully added to the dataset."
846843
)
847844
except Exception as e:
848845
dataset.delete()

libs/labelbox/tests/integration/test_labeling_service.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import pytest
22

3-
from labelbox.exceptions import LabelboxError, ResourceNotFoundError
3+
from labelbox.exceptions import (
4+
MalformedQueryException,
5+
ResourceNotFoundError,
6+
)
47
from labelbox.schema.labeling_service import LabelingServiceStatus
58

69

@@ -51,7 +54,7 @@ def test_request_labeling_service_moe_project(
5154

5255
labeling_service = project.get_labeling_service()
5356
with pytest.raises(
54-
LabelboxError,
57+
MalformedQueryException,
5558
match='[{"errorType":"PROJECT_MODEL_CONFIG","errorMessage":"Project model config is not completed"}]',
5659
):
5760
labeling_service.request()
@@ -73,5 +76,5 @@ def test_request_labeling_service_incomplete_requirements(ontology, project):
7376
): # No labeling service by default
7477
labeling_service.request()
7578
project.connect_ontology(ontology)
76-
with pytest.raises(LabelboxError):
79+
with pytest.raises(MalformedQueryException):
7780
labeling_service.request()

0 commit comments

Comments
 (0)