From be02e2e11ab5d0d4c2858a9ad617fd837233aead Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 29 Oct 2024 22:00:03 -0500 Subject: [PATCH 1/4] Added remaining flake rules --- libs/labelbox/pyproject.toml | 2 +- libs/labelbox/src/labelbox/client.py | 2 +- .../labelbox/data/annotation_types/label.py | 2 +- .../labelbox/data/annotation_types/video.py | 4 ---- libs/labelbox/src/labelbox/data/generator.py | 1 - .../src/labelbox/data/metrics/group.py | 2 +- .../data/serialization/ndjson/base.py | 1 - .../data/serialization/ndjson/converter.py | 1 - .../data/serialization/ndjson/label.py | 2 +- .../data/serialization/ndjson/objects.py | 1 - .../data/serialization/ndjson/relationship.py | 1 - .../src/labelbox/schema/data_row_metadata.py | 1 - .../labelbox/src/labelbox/schema/model_run.py | 2 +- libs/labelbox/src/labelbox/schema/ontology.py | 3 ++- libs/labelbox/src/labelbox/types.py | 2 +- libs/labelbox/tests/conftest.py | 5 ----- .../tests/data/annotation_import/conftest.py | 2 -- .../data/annotation_types/data/test_raster.py | 1 - .../annotation_types/geometry/test_mask.py | 2 +- .../annotation_types/geometry/test_point.py | 4 ++-- .../data/annotation_types/test_annotation.py | 2 +- .../tests/data/annotation_types/test_label.py | 4 ++-- .../data/annotation_types/test_metrics.py | 21 +++++++++---------- .../data/annotation_types/test_tiled_image.py | 4 +--- libs/labelbox/tests/data/export/conftest.py | 18 ---------------- .../data/metrics/confusion_matrix/conftest.py | 18 ---------------- .../test_confusion_matrix_data_row.py | 2 +- .../test_confusion_matrix_feature.py | 2 +- .../data/metrics/iou/data_row/conftest.py | 4 ---- libs/labelbox/tests/integration/test_batch.py | 4 ++-- .../tests/integration/test_client_errors.py | 6 +++--- .../test_data_row_delete_metadata.py | 2 +- .../tests/integration/test_data_rows.py | 16 +++++++------- .../tests/integration/test_dataset.py | 7 ------- .../tests/integration/test_global_keys.py | 4 ++-- .../tests/unit/schema/test_user_group.py | 6 +++--- libs/labelbox/tests/unit/test_unit_filter.py | 4 ++-- .../tests/unit/test_unit_search_filters.py | 2 +- 38 files changed, 50 insertions(+), 117 deletions(-) diff --git a/libs/labelbox/pyproject.toml b/libs/labelbox/pyproject.toml index b260ba016..844f69117 100644 --- a/libs/labelbox/pyproject.toml +++ b/libs/labelbox/pyproject.toml @@ -74,7 +74,7 @@ dev-dependencies = [ line-length = 80 [tool.ruff.lint] -ignore = ["F841", "E722", "F811", "F402", "F601", "F403", "F821", "F541"] +ignore = ["E722"] exclude = ["**/__init__.py"] [tool.rye.scripts] diff --git a/libs/labelbox/src/labelbox/client.py b/libs/labelbox/src/labelbox/client.py index d4376d9b4..76aff8257 100644 --- a/libs/labelbox/src/labelbox/client.py +++ b/libs/labelbox/src/labelbox/client.py @@ -577,7 +577,7 @@ def create_dataset( ) if not validation_result["validateDataset"]["valid"]: - raise labelbox.exceptions.LabelboxError( + raise LabelboxError( "IAMIntegration was not successfully added to the dataset." ) except Exception as e: diff --git a/libs/labelbox/src/labelbox/data/annotation_types/label.py b/libs/labelbox/src/labelbox/data/annotation_types/label.py index d13fb8f20..dab6e75ca 100644 --- a/libs/labelbox/src/labelbox/data/annotation_types/label.py +++ b/libs/labelbox/src/labelbox/data/annotation_types/label.py @@ -183,6 +183,6 @@ def validate_union(cls, value): prompt_count += 1 if prompt_count > 1: raise TypeError( - f"Only one prompt annotation is allowed per label" + "Only one prompt annotation is allowed per label" ) return value diff --git a/libs/labelbox/src/labelbox/data/annotation_types/video.py b/libs/labelbox/src/labelbox/data/annotation_types/video.py index 14a692bae..4e59b1e4e 100644 --- a/libs/labelbox/src/labelbox/data/annotation_types/video.py +++ b/libs/labelbox/src/labelbox/data/annotation_types/video.py @@ -6,10 +6,6 @@ ObjectAnnotation, ) -from labelbox.data.annotation_types.annotation import ( - ClassificationAnnotation, - ObjectAnnotation, -) from labelbox.data.annotation_types.feature import FeatureSchema from labelbox.data.mixins import ( ConfidenceNotSupportedMixin, diff --git a/libs/labelbox/src/labelbox/data/generator.py b/libs/labelbox/src/labelbox/data/generator.py index 8270a6715..0eb9e75a2 100644 --- a/libs/labelbox/src/labelbox/data/generator.py +++ b/libs/labelbox/src/labelbox/data/generator.py @@ -2,7 +2,6 @@ import threading from queue import Queue from typing import Any, Iterable -import threading logger = logging.getLogger(__name__) diff --git a/libs/labelbox/src/labelbox/data/metrics/group.py b/libs/labelbox/src/labelbox/data/metrics/group.py index 63718aad4..867899f69 100644 --- a/libs/labelbox/src/labelbox/data/metrics/group.py +++ b/libs/labelbox/src/labelbox/data/metrics/group.py @@ -17,7 +17,7 @@ except ImportError: from typing import Literal -from ..annotation_types import ClassificationAnnotation, Label, ObjectAnnotation +from ..annotation_types import Label, ObjectAnnotation from ..annotation_types.feature import FeatureSchema diff --git a/libs/labelbox/src/labelbox/data/serialization/ndjson/base.py b/libs/labelbox/src/labelbox/data/serialization/ndjson/base.py index 4b9cc0489..e789eafce 100644 --- a/libs/labelbox/src/labelbox/data/serialization/ndjson/base.py +++ b/libs/labelbox/src/labelbox/data/serialization/ndjson/base.py @@ -3,7 +3,6 @@ from labelbox.utils import _CamelCaseMixin, is_exactly_one_set from pydantic import model_validator, Field -from uuid import uuid4 from ....annotated_types import Cuid diff --git a/libs/labelbox/src/labelbox/data/serialization/ndjson/converter.py b/libs/labelbox/src/labelbox/data/serialization/ndjson/converter.py index 4d3c160b5..481f3c4af 100644 --- a/libs/labelbox/src/labelbox/data/serialization/ndjson/converter.py +++ b/libs/labelbox/src/labelbox/data/serialization/ndjson/converter.py @@ -18,7 +18,6 @@ from ...annotation_types.relationship import RelationshipAnnotation from ...annotation_types.mmc import MessageEvaluationTaskAnnotation from .label import NDLabel -import copy logger = logging.getLogger(__name__) diff --git a/libs/labelbox/src/labelbox/data/serialization/ndjson/label.py b/libs/labelbox/src/labelbox/data/serialization/ndjson/label.py index af938e511..f1d787309 100644 --- a/libs/labelbox/src/labelbox/data/serialization/ndjson/label.py +++ b/libs/labelbox/src/labelbox/data/serialization/ndjson/label.py @@ -258,7 +258,7 @@ def _get_segment_frame_ranges( return frame_ranges else: raise ValueError( - f"Video annotations cannot partially have `segment_index` set" + "Video annotations cannot partially have `segment_index` set" ) @classmethod diff --git a/libs/labelbox/src/labelbox/data/serialization/ndjson/objects.py b/libs/labelbox/src/labelbox/data/serialization/ndjson/objects.py index 28f3a45c8..33cb61041 100644 --- a/libs/labelbox/src/labelbox/data/serialization/ndjson/objects.py +++ b/libs/labelbox/src/labelbox/data/serialization/ndjson/objects.py @@ -23,7 +23,6 @@ from labelbox.data.annotation_types.data import GenericDataRowData -from ...annotation_types.data import GenericDataRowData from ...annotation_types.ner import ( DocumentEntity, DocumentTextSelection, diff --git a/libs/labelbox/src/labelbox/data/serialization/ndjson/relationship.py b/libs/labelbox/src/labelbox/data/serialization/ndjson/relationship.py index f692bae41..02169b8bc 100644 --- a/libs/labelbox/src/labelbox/data/serialization/ndjson/relationship.py +++ b/libs/labelbox/src/labelbox/data/serialization/ndjson/relationship.py @@ -4,7 +4,6 @@ from ...annotation_types.relationship import RelationshipAnnotation from ...annotation_types.relationship import Relationship from .objects import NDObjectType -from .base import DataRow SUPPORTED_ANNOTATIONS = NDObjectType diff --git a/libs/labelbox/src/labelbox/schema/data_row_metadata.py b/libs/labelbox/src/labelbox/schema/data_row_metadata.py index 58111828f..6c24ef07d 100644 --- a/libs/labelbox/src/labelbox/schema/data_row_metadata.py +++ b/libs/labelbox/src/labelbox/schema/data_row_metadata.py @@ -25,7 +25,6 @@ conlist, model_serializer, ) -from typing_extensions import Annotated from labelbox.schema.identifiable import GlobalKey, UniqueId from labelbox.schema.identifiables import DataRowIdentifiers, UniqueIds diff --git a/libs/labelbox/src/labelbox/schema/model_run.py b/libs/labelbox/src/labelbox/schema/model_run.py index 94ffb29dd..f57e26f60 100644 --- a/libs/labelbox/src/labelbox/schema/model_run.py +++ b/libs/labelbox/src/labelbox/schema/model_run.py @@ -198,7 +198,7 @@ def _wait_until_done(self, status_fn, timeout_seconds=120, sleep_time=5): if res["status"] == "COMPLETE": return True elif res["status"] == "FAILED": - raise Exception(f"Job failed.") + raise Exception("Job failed.") timeout_seconds -= sleep_time if timeout_seconds <= 0: raise TimeoutError( diff --git a/libs/labelbox/src/labelbox/schema/ontology.py b/libs/labelbox/src/labelbox/schema/ontology.py index 3acd9e1e2..7e6740da6 100644 --- a/libs/labelbox/src/labelbox/schema/ontology.py +++ b/libs/labelbox/src/labelbox/schema/ontology.py @@ -14,6 +14,7 @@ from labelbox.orm.model import Field, Relationship from labelbox.schema.tool_building.step_reasoning_tool import StepReasoningTool from labelbox.schema.tool_building.tool_type import ToolType +from labelbox import Project FeatureSchemaId: Type[str] = Annotated[ str, StringConstraints(min_length=25, max_length=25) @@ -655,7 +656,7 @@ def _update_colors(self): self.tools[index].color = "#%02x%02x%02x" % rgb_color @classmethod - def from_project(cls, project: "project.Project") -> "OntologyBuilder": + def from_project(cls, project: Project) -> "OntologyBuilder": ontology = project.ontology().normalized return cls.from_dict(ontology) diff --git a/libs/labelbox/src/labelbox/types.py b/libs/labelbox/src/labelbox/types.py index 0c0c2904f..4e70ca6f8 100644 --- a/libs/labelbox/src/labelbox/types.py +++ b/libs/labelbox/src/labelbox/types.py @@ -1,5 +1,5 @@ try: - from labelbox.data.annotation_types import * + from labelbox.data.annotation_types import * # noqa: F403 except ImportError: raise ImportError( "There are missing dependencies for `labelbox.types`, use `pip install labelbox[data] --upgrade` to install missing dependencies." diff --git a/libs/labelbox/tests/conftest.py b/libs/labelbox/tests/conftest.py index a07d52c4d..7ce6a0c1f 100644 --- a/libs/labelbox/tests/conftest.py +++ b/libs/labelbox/tests/conftest.py @@ -311,11 +311,6 @@ def ephmeral_client() -> EphemeralClient: return EphemeralClient -@pytest.fixture -def admin_client() -> AdminClient: - return AdminClient - - @pytest.fixture def integration_client() -> IntegrationClient: return IntegrationClient diff --git a/libs/labelbox/tests/data/annotation_import/conftest.py b/libs/labelbox/tests/data/annotation_import/conftest.py index 001b96771..c5faff952 100644 --- a/libs/labelbox/tests/data/annotation_import/conftest.py +++ b/libs/labelbox/tests/data/annotation_import/conftest.py @@ -2471,7 +2471,6 @@ def expected_export_v2_llm_prompt_response_creation(): "name": "first_radio_answer", "value": "first_radio_answer", }, - "name": "radio-response", "value": "radio-response", }, ], @@ -2530,7 +2529,6 @@ def expected_export_v2_llm_response_creation(): "name": "first_radio_answer", "value": "first_radio_answer", }, - "name": "radio-response", "value": "radio-response", }, ], diff --git a/libs/labelbox/tests/data/annotation_types/data/test_raster.py b/libs/labelbox/tests/data/annotation_types/data/test_raster.py index 7e97eb960..0b60ebbc0 100644 --- a/libs/labelbox/tests/data/annotation_types/data/test_raster.py +++ b/libs/labelbox/tests/data/annotation_types/data/test_raster.py @@ -31,7 +31,6 @@ def test_im_url(): def test_ref(): - external_id = "external_id" uid = "uid" metadata = [] media_attributes = {} diff --git a/libs/labelbox/tests/data/annotation_types/geometry/test_mask.py b/libs/labelbox/tests/data/annotation_types/geometry/test_mask.py index 6fe8422cf..d177a0bcd 100644 --- a/libs/labelbox/tests/data/annotation_types/geometry/test_mask.py +++ b/libs/labelbox/tests/data/annotation_types/geometry/test_mask.py @@ -9,7 +9,7 @@ def test_mask(): with pytest.raises(ValidationError): - mask = Mask() + Mask() mask_data = np.zeros((32, 32, 3), dtype=np.uint8) mask_data = cv2.rectangle(mask_data, (0, 0), (10, 10), (255, 255, 255), -1) diff --git a/libs/labelbox/tests/data/annotation_types/geometry/test_point.py b/libs/labelbox/tests/data/annotation_types/geometry/test_point.py index 335fb6a3a..7e92375de 100644 --- a/libs/labelbox/tests/data/annotation_types/geometry/test_point.py +++ b/libs/labelbox/tests/data/annotation_types/geometry/test_point.py @@ -7,10 +7,10 @@ def test_point(): with pytest.raises(ValidationError): - line = Point() + Point() with pytest.raises(TypeError): - line = Point([0, 1]) + Point([0, 1]) point = Point(x=0, y=1) expected = {"coordinates": [0, 1], "type": "Point"} diff --git a/libs/labelbox/tests/data/annotation_types/test_annotation.py b/libs/labelbox/tests/data/annotation_types/test_annotation.py index 01547bd56..298087219 100644 --- a/libs/labelbox/tests/data/annotation_types/test_annotation.py +++ b/libs/labelbox/tests/data/annotation_types/test_annotation.py @@ -106,5 +106,5 @@ def test_confidence_value_range_validation(): name = "line_feature" line = Line(points=[Point(x=1, y=2), Point(x=2, y=2)]) - with pytest.raises(ValueError) as e: + with pytest.raises(ValueError): ObjectAnnotation(value=line, name=name, confidence=14) diff --git a/libs/labelbox/tests/data/annotation_types/test_label.py b/libs/labelbox/tests/data/annotation_types/test_label.py index d2dd2b634..7a9b83233 100644 --- a/libs/labelbox/tests/data/annotation_types/test_label.py +++ b/libs/labelbox/tests/data/annotation_types/test_label.py @@ -52,8 +52,8 @@ def test_prompt_classification_validation(): prompt_text_2 = lb_types.PromptClassificationAnnotation( name="prompt text", value=PromptText(answer="test") ) - with pytest.raises(TypeError) as e_info: - label = Label( + with pytest.raises(TypeError): + Label( data={"global_key": global_key}, annotations=[prompt_text, prompt_text_2], ) diff --git a/libs/labelbox/tests/data/annotation_types/test_metrics.py b/libs/labelbox/tests/data/annotation_types/test_metrics.py index 4e9355573..edacf6828 100644 --- a/libs/labelbox/tests/data/annotation_types/test_metrics.py +++ b/libs/labelbox/tests/data/annotation_types/test_metrics.py @@ -9,7 +9,6 @@ ScalarMetric, ) from labelbox.data.annotation_types import ( - ScalarMetric, Label, GenericDataRowData, ) @@ -166,19 +165,19 @@ def test_custom_confusison_matrix_metric( def test_name_exists(): # Name is only required for ConfusionMatrixMetric for now. - with pytest.raises(ValidationError) as exc_info: - metric = ConfusionMatrixMetric(value=[0, 1, 2, 3]) + with pytest.raises(ValidationError): + ConfusionMatrixMetric(value=[0, 1, 2, 3]) def test_invalid_aggregations(): - with pytest.raises(ValidationError) as exc_info: - metric = ScalarMetric( + with pytest.raises(ValidationError): + ScalarMetric( metric_name="invalid aggregation", value=0.1, aggregation=ConfusionMatrixAggregation.CONFUSION_MATRIX, ) - with pytest.raises(ValidationError) as exc_info: - metric = ConfusionMatrixMetric( + with pytest.raises(ValidationError): + ConfusionMatrixMetric( metric_name="invalid aggregation", value=[0, 1, 2, 3], aggregation=ScalarMetricAggregation.SUM, @@ -187,21 +186,21 @@ def test_invalid_aggregations(): def test_invalid_number_of_confidence_scores(): with pytest.raises(ValidationError) as exc_info: - metric = ScalarMetric(metric_name="too few scores", value={0.1: 0.1}) + ScalarMetric(metric_name="too few scores", value={0.1: 0.1}) assert "Number of confidence scores must be greater" in str(exc_info.value) with pytest.raises(ValidationError) as exc_info: - metric = ConfusionMatrixMetric( + ConfusionMatrixMetric( metric_name="too few scores", value={0.1: [0, 1, 2, 3]} ) assert "Number of confidence scores must be greater" in str(exc_info.value) with pytest.raises(ValidationError) as exc_info: - metric = ScalarMetric( + ScalarMetric( metric_name="too many scores", value={i / 20.0: 0.1 for i in range(20)}, ) assert "Number of confidence scores must be greater" in str(exc_info.value) with pytest.raises(ValidationError) as exc_info: - metric = ConfusionMatrixMetric( + ConfusionMatrixMetric( metric_name="too many scores", value={i / 20.0: [0, 1, 2, 3] for i in range(20)}, ) diff --git a/libs/labelbox/tests/data/annotation_types/test_tiled_image.py b/libs/labelbox/tests/data/annotation_types/test_tiled_image.py index 46f2383d6..514b53278 100644 --- a/libs/labelbox/tests/data/annotation_types/test_tiled_image.py +++ b/libs/labelbox/tests/data/annotation_types/test_tiled_image.py @@ -32,9 +32,7 @@ def test_tiled_bounds(epsg): def test_tiled_bounds_same(epsg): single_bound = Point(x=0, y=0) with pytest.raises(ValidationError): - tiled_bounds = TiledBounds( - epsg=epsg, bounds=[single_bound, single_bound] - ) + TiledBounds(epsg=epsg, bounds=[single_bound, single_bound]) def test_create_tiled_image_data(): diff --git a/libs/labelbox/tests/data/export/conftest.py b/libs/labelbox/tests/data/export/conftest.py index 4d54e3cbc..82a969523 100644 --- a/libs/labelbox/tests/data/export/conftest.py +++ b/libs/labelbox/tests/data/export/conftest.py @@ -5,7 +5,6 @@ from labelbox import Client, MediaType from labelbox.schema.annotation_import import AnnotationImportState, LabelImport -from labelbox.schema.media_type import MediaType @pytest.fixture @@ -367,23 +366,6 @@ def video_ontology(client: Client): return ontology -@pytest.fixture -def polygon_inference(prediction_id_mapping): - polygon = prediction_id_mapping["polygon"].copy() - polygon.update( - { - "polygon": [ - {"x": 147.692, "y": 118.154}, - {"x": 142.769, "y": 104.923}, - {"x": 57.846, "y": 118.769}, - {"x": 28.308, "y": 169.846}, - ] - } - ) - del polygon["tool"] - return polygon - - @pytest.fixture def configured_project_with_ontology( client, initial_dataset, ontology, rand_gen, image_url, teardown_helpers diff --git a/libs/labelbox/tests/data/metrics/confusion_matrix/conftest.py b/libs/labelbox/tests/data/metrics/confusion_matrix/conftest.py index c61c4f1df..a4d2f5f84 100644 --- a/libs/labelbox/tests/data/metrics/confusion_matrix/conftest.py +++ b/libs/labelbox/tests/data/metrics/confusion_matrix/conftest.py @@ -49,18 +49,6 @@ def get_text(name, text_content): return ClassificationAnnotation(name=name, value=Text(answer=text_content)) -def get_checklist(name, answer_names): - return ClassificationAnnotation( - name=name, - value=Radio( - answer=[ - ClassificationAnswer(name=answer_name) - for answer_name in answer_names - ] - ), - ) - - def get_polygon(name, points, subclasses=None): return ObjectAnnotation( name=name, @@ -106,12 +94,6 @@ def get_point(name, x, y, subclasses=None): ) -def get_radio(name, answer_name): - return ClassificationAnnotation( - name=name, value=Radio(answer=ClassificationAnswer(name=answer_name)) - ) - - def get_checklist(name, answer_names): return ClassificationAnnotation( name=name, diff --git a/libs/labelbox/tests/data/metrics/confusion_matrix/test_confusion_matrix_data_row.py b/libs/labelbox/tests/data/metrics/confusion_matrix/test_confusion_matrix_data_row.py index e3ac86213..9ae8d32c0 100644 --- a/libs/labelbox/tests/data/metrics/confusion_matrix/test_confusion_matrix_data_row.py +++ b/libs/labelbox/tests/data/metrics/confusion_matrix/test_confusion_matrix_data_row.py @@ -1,5 +1,5 @@ from pytest_cases import fixture_ref -from pytest_cases import parametrize, fixture_ref +from pytest_cases import parametrize from labelbox.data.metrics.confusion_matrix.confusion_matrix import ( confusion_matrix_metric, diff --git a/libs/labelbox/tests/data/metrics/confusion_matrix/test_confusion_matrix_feature.py b/libs/labelbox/tests/data/metrics/confusion_matrix/test_confusion_matrix_feature.py index 818c01f72..762a11fcd 100644 --- a/libs/labelbox/tests/data/metrics/confusion_matrix/test_confusion_matrix_feature.py +++ b/libs/labelbox/tests/data/metrics/confusion_matrix/test_confusion_matrix_feature.py @@ -1,5 +1,5 @@ from pytest_cases import fixture_ref -from pytest_cases import parametrize, fixture_ref +from pytest_cases import parametrize from labelbox.data.metrics.confusion_matrix.confusion_matrix import ( feature_confusion_matrix_metric, diff --git a/libs/labelbox/tests/data/metrics/iou/data_row/conftest.py b/libs/labelbox/tests/data/metrics/iou/data_row/conftest.py index 6c03c2839..c19187bc0 100644 --- a/libs/labelbox/tests/data/metrics/iou/data_row/conftest.py +++ b/libs/labelbox/tests/data/metrics/iou/data_row/conftest.py @@ -281,7 +281,6 @@ def matching_checklist(): "featureId": "1234567890111213141516171", "schemaId": "ckppid25v0000aeyjmxfwlc7t", "uuid": "76e0dcea-fe46-43e5-95f5-a5e3f378520a", - "schemaId": "ckppid25v0000aeyjmxfwlc7t", "answers": [ { "schemaId": "ckppid25v0000aeyjmxfwlc7t", @@ -319,7 +318,6 @@ def partially_matching_checklist_1(): "featureId": "1234567890111213141516171", "schemaId": "ckppid25v0000aeyjmxfwlc7t", "uuid": "76e0dcea-fe46-43e5-95f5-a5e3f378520a", - "schemaId": "ckppid25v0000aeyjmxfwlc7t", "answers": [ { "schemaId": "ckppid25v0000aeyjmxfwlc7t", @@ -359,7 +357,6 @@ def partially_matching_checklist_2(): "featureId": "1234567890111213141516171", "schemaId": "ckppid25v0000aeyjmxfwlc7t", "uuid": "76e0dcea-fe46-43e5-95f5-a5e3f378520a", - "schemaId": "ckppid25v0000aeyjmxfwlc7t", "answers": [ { "schemaId": "ckppid25v0000aeyjmxfwlc7t", @@ -397,7 +394,6 @@ def partially_matching_checklist_3(): "featureId": "1234567890111213141516171", "schemaId": "ckppid25v0000aeyjmxfwlc7t", "uuid": "76e0dcea-fe46-43e5-95f5-a5e3f378520a", - "schemaId": "ckppid25v0000aeyjmxfwlc7t", "answers": [ { "schemaId": "ckppid25v0000aeyjmxfwlc7t", diff --git a/libs/labelbox/tests/integration/test_batch.py b/libs/labelbox/tests/integration/test_batch.py index f63b4c3d9..4b8f4bf40 100644 --- a/libs/labelbox/tests/integration/test_batch.py +++ b/libs/labelbox/tests/integration/test_batch.py @@ -282,7 +282,7 @@ def test_delete_labels(project, small_dataset): export_task.wait_till_done() stream = export_task.get_buffered_stream() data_rows = [dr.json["data_row"]["id"] for dr in stream] - batch = project.create_batch("batch to delete labels", data_rows) + project.create_batch("batch to delete labels", data_rows) @pytest.mark.skip( @@ -303,7 +303,7 @@ def test_delete_labels_with_templates(project: Project, small_dataset: Dataset): stream = export_task.get_buffered_stream() exported_data_rows = [dr.json["data_row"]["id"] for dr in stream] - res = batch.delete_labels(labels_as_template=True) + batch.delete_labels(labels_as_template=True) export_task = project.export(filters={"batch_ids": [batch.uid]}) export_task.wait_till_done() diff --git a/libs/labelbox/tests/integration/test_client_errors.py b/libs/labelbox/tests/integration/test_client_errors.py index b5444eadf..43848dc4d 100644 --- a/libs/labelbox/tests/integration/test_client_errors.py +++ b/libs/labelbox/tests/integration/test_client_errors.py @@ -28,7 +28,7 @@ def test_bad_key(rand_gen): bad_key = "BAD_KEY_" + rand_gen(str) client = labelbox.client.Client(api_key=bad_key) - with pytest.raises(lbox.exceptions.AuthenticationError) as excinfo: + with pytest.raises(lbox.exceptions.AuthenticationError): client.create_project(name=rand_gen(str), media_type=MediaType.Image) @@ -45,7 +45,7 @@ def test_semantic_error(client): def test_timeout_error(client, project): - with pytest.raises(RetryError) as excinfo: + with pytest.raises(RetryError): query_str = """query getOntology { project (where: {id: %s}) { ontology { @@ -76,7 +76,7 @@ def test_network_error(client): api_key=client._request_client.api_key, endpoint="not_a_valid_URL" ) - with pytest.raises(lbox.exceptions.NetworkError) as excinfo: + with pytest.raises(lbox.exceptions.NetworkError): client.create_project(name="Project name", media_type=MediaType.Image) diff --git a/libs/labelbox/tests/integration/test_data_row_delete_metadata.py b/libs/labelbox/tests/integration/test_data_row_delete_metadata.py index a2ffd31ba..76462c5ef 100644 --- a/libs/labelbox/tests/integration/test_data_row_delete_metadata.py +++ b/libs/labelbox/tests/integration/test_data_row_delete_metadata.py @@ -130,7 +130,7 @@ def data_row_id_as_str(data_row): "data_row_for_delete", ["data_row_id_as_str", "data_row_unique_id", "data_row_global_key"], ) -def test_bulk_delete_datarow_metadata( +def test_bulk_delete_datarow_metadata_with_different_ids( data_row_for_delete, data_row, mdo, request ): """test bulk deletes for all fields""" diff --git a/libs/labelbox/tests/integration/test_data_rows.py b/libs/labelbox/tests/integration/test_data_rows.py index 485719575..322eaa23d 100644 --- a/libs/labelbox/tests/integration/test_data_rows.py +++ b/libs/labelbox/tests/integration/test_data_rows.py @@ -156,7 +156,7 @@ def test_lookup_data_rows(client, dataset): def test_data_row_bulk_creation(dataset, rand_gen, image_url): - client = dataset.client + dataset.client data_rows = [] assert len(list(dataset.data_rows())) == 0 @@ -356,7 +356,7 @@ def test_create_data_row_with_dict_unpacked(dataset, image_url): def test_create_data_row_with_invalid_input(dataset, image_url): - with pytest.raises(ResourceCreationError) as exc: + with pytest.raises(ResourceCreationError): dataset.create_data_row("asdf") @@ -600,7 +600,7 @@ def test_create_data_rows_with_metadata_missing_value( fields = make_metadata_fields fields.append({"schemaId": "some schema id"}) - with pytest.raises(ValueError) as exc: + with pytest.raises(ValueError): dataset.create_data_rows( [ { @@ -618,7 +618,7 @@ def test_create_data_rows_with_metadata_missing_schema_id( fields = make_metadata_fields fields.append({"value": "some value"}) - with pytest.raises(ValueError) as exc: + with pytest.raises(ValueError): dataset.create_data_rows( [ { @@ -636,8 +636,8 @@ def test_create_data_rows_with_metadata_wrong_type( fields = make_metadata_fields fields.append("Neither DataRowMetadataField or dict") - with pytest.raises(ValueError) as exc: - task = dataset.create_data_rows( + with pytest.raises(ValueError): + dataset.create_data_rows( [ { DataRow.row_data: image_url, @@ -807,7 +807,7 @@ def test_data_row_attachments(dataset, image_url): assert len(list(data_row.attachments())) == 1 assert data_row.external_id == "test-id" - with pytest.raises(ValueError) as exc: + with pytest.raises(ValueError): task = dataset.create_data_rows( [ { @@ -1135,7 +1135,7 @@ def test_create_data_row_with_attachments(dataset): def test_create_data_row_with_media_type(dataset, image_url): with pytest.raises(ResourceCreationError) as exc: - dr = dataset.create_data_row( + dataset.create_data_row( row_data={"invalid_object": "invalid_value"}, media_type="IMAGE" ) diff --git a/libs/labelbox/tests/integration/test_dataset.py b/libs/labelbox/tests/integration/test_dataset.py index a32c5541d..bc7404c53 100644 --- a/libs/labelbox/tests/integration/test_dataset.py +++ b/libs/labelbox/tests/integration/test_dataset.py @@ -65,13 +65,6 @@ def test_dataset_filtering(client, dataset_for_filtering): assert list(client.get_datasets(where=Dataset.name == name_2)) == [d2] -def test_dataset_filtering(client, dataset_for_filtering): - name_1, d1, name_2, d2 = dataset_for_filtering - - assert list(client.get_datasets(where=Dataset.name == name_1)) == [d1] - assert list(client.get_datasets(where=Dataset.name == name_2)) == [d2] - - def test_get_data_row_for_external_id(dataset, rand_gen, image_url): external_id = rand_gen(str) diff --git a/libs/labelbox/tests/integration/test_global_keys.py b/libs/labelbox/tests/integration/test_global_keys.py index 9dc357812..53af9f872 100644 --- a/libs/labelbox/tests/integration/test_global_keys.py +++ b/libs/labelbox/tests/integration/test_global_keys.py @@ -9,7 +9,7 @@ def test_assign_global_keys_to_data_rows(client, dataset, image_url): dr_1 = dataset.create_data_row(row_data=image_url, external_id="hello") dr_2 = dataset.create_data_row(row_data=image_url, external_id="world") - row_ids = set([dr_1.uid, dr_2.uid]) + set([dr_1.uid, dr_2.uid]) gk_1 = str(uuid.uuid4()) gk_2 = str(uuid.uuid4()) @@ -172,7 +172,7 @@ def test_get_data_row_ids_for_invalid_global_keys(client, dataset, image_url): gk_1 = str(uuid.uuid4()) gk_2 = str(uuid.uuid4()) - dr_1 = dataset.create_data_row(row_data=image_url, external_id="hello") + dataset.create_data_row(row_data=image_url, external_id="hello") dr_2 = dataset.create_data_row( row_data=image_url, external_id="world", global_key=gk_2 ) diff --git a/libs/labelbox/tests/unit/schema/test_user_group.py b/libs/labelbox/tests/unit/schema/test_user_group.py index 6bc29048d..0c7bc8861 100644 --- a/libs/labelbox/tests/unit/schema/test_user_group.py +++ b/libs/labelbox/tests/unit/schema/test_user_group.py @@ -64,7 +64,7 @@ def test_constructor(self): assert len(group.projects) == 0 assert len(group.users) == 0 - def test_update_with_exception_name(self): + def test_get_with_exception_id(self): group = self.group group.id = "" @@ -157,7 +157,7 @@ def test_update_resource_error_unknown_id(self): group.name = "Test Group" group.id = "group_id" - with pytest.raises(ResourceNotFoundError) as e: + with pytest.raises(ResourceNotFoundError): group.update() def test_update_with_exception_name(self): @@ -167,7 +167,7 @@ def test_update_with_exception_name(self): with pytest.raises(UnprocessableEntityError): group.update() - def test_update_with_exception_name(self): + def test_update_with_exception_id(self): group = self.group group.id = "" diff --git a/libs/labelbox/tests/unit/test_unit_filter.py b/libs/labelbox/tests/unit/test_unit_filter.py index 8b49a6f58..60a7836d4 100644 --- a/libs/labelbox/tests/unit/test_unit_filter.py +++ b/libs/labelbox/tests/unit/test_unit_filter.py @@ -61,6 +61,6 @@ def test_logical_expr_ops(): # Can't create logical expressions with anything except comparisons and # other logical expressions. with pytest.raises(TypeError): - logical_op = comparison_1 & 42 + comparison_1 & 42 with pytest.raises(TypeError): - logical_op = comparison_1 | 42 + comparison_1 | 42 diff --git a/libs/labelbox/tests/unit/test_unit_search_filters.py b/libs/labelbox/tests/unit/test_unit_search_filters.py index 4276c6742..d56e9818a 100644 --- a/libs/labelbox/tests/unit/test_unit_search_filters.py +++ b/libs/labelbox/tests/unit/test_unit_search_filters.py @@ -52,7 +52,7 @@ def test_id_filters(): def test_stage_filter_with_invalid_values(): with pytest.raises( ValueError, match="is not a valid value for ProjectStageFilter" - ) as e: + ): _ = ( ProjectStageFilter( operator=IdOperator.Is, From be88b1f2ef7f29774f00137622ae659c4e4d47d2 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 29 Oct 2024 22:04:25 -0500 Subject: [PATCH 2/4] Fixed error --- libs/labelbox/src/labelbox/schema/ontology.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/labelbox/src/labelbox/schema/ontology.py b/libs/labelbox/src/labelbox/schema/ontology.py index 7e6740da6..4a2f868c0 100644 --- a/libs/labelbox/src/labelbox/schema/ontology.py +++ b/libs/labelbox/src/labelbox/schema/ontology.py @@ -656,7 +656,7 @@ def _update_colors(self): self.tools[index].color = "#%02x%02x%02x" % rgb_color @classmethod - def from_project(cls, project: Project) -> "OntologyBuilder": + def from_project(cls, project: "Project") -> "OntologyBuilder": ontology = project.ontology().normalized return cls.from_dict(ontology) From 2e33da5b660beacc2bd10b98cdba3fc35097c8f4 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 29 Oct 2024 22:08:20 -0500 Subject: [PATCH 3/4] fixed error --- libs/labelbox/src/labelbox/schema/ontology.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/labelbox/src/labelbox/schema/ontology.py b/libs/labelbox/src/labelbox/schema/ontology.py index 4a2f868c0..e74364d86 100644 --- a/libs/labelbox/src/labelbox/schema/ontology.py +++ b/libs/labelbox/src/labelbox/schema/ontology.py @@ -13,8 +13,11 @@ from labelbox.orm.db_object import DbObject from labelbox.orm.model import Field, Relationship from labelbox.schema.tool_building.step_reasoning_tool import StepReasoningTool +from typing import TYPE_CHECKING from labelbox.schema.tool_building.tool_type import ToolType -from labelbox import Project + +if TYPE_CHECKING: + from labelbox import Project FeatureSchemaId: Type[str] = Annotated[ str, StringConstraints(min_length=25, max_length=25) From a46db7120150c5d0b7f31ee8fc7a237df19bfea5 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:09:10 -0500 Subject: [PATCH 4/4] Fixed test --- libs/labelbox/tests/unit/schema/test_user_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/labelbox/tests/unit/schema/test_user_group.py b/libs/labelbox/tests/unit/schema/test_user_group.py index 0c7bc8861..e3fb62dc9 100644 --- a/libs/labelbox/tests/unit/schema/test_user_group.py +++ b/libs/labelbox/tests/unit/schema/test_user_group.py @@ -164,7 +164,7 @@ def test_update_with_exception_name(self): group = self.group group.name = "" - with pytest.raises(UnprocessableEntityError): + with pytest.raises(ValueError): group.update() def test_update_with_exception_id(self):