Skip to content

Fix exception type for labeling service test #1835

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 1 commit into from
Sep 23, 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
41 changes: 19 additions & 22 deletions libs/labelbox/src/labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,61 +25,59 @@
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,
)
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__)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 6 additions & 3 deletions libs/labelbox/tests/integration/test_labeling_service.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -51,7 +54,7 @@ def test_request_labeling_service_moe_project(

labeling_service = project.get_labeling_service()
with pytest.raises(
LabelboxError,
MalformedQueryException,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file has actual changes, the rest is linting changes

match='[{"errorType":"PROJECT_MODEL_CONFIG","errorMessage":"Project model config is not completed"}]',
):
labeling_service.request()
Expand All @@ -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()
Loading