Skip to content

Commit dfe97c2

Browse files
author
Val Brodsky
committed
Fix linting
1 parent ccba12c commit dfe97c2

21 files changed

+127
-93
lines changed

libs/labelbox/src/labelbox/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,8 @@ def delete_model_config(self, id: str) -> bool:
652652
params = {"id": id}
653653
result = self.execute(query, params)
654654
if not result:
655-
raise labelbox.exceptions.ResourceNotFoundError(Entity.ModelConfig, params)
655+
raise labelbox.exceptions.ResourceNotFoundError(
656+
Entity.ModelConfig, params)
656657
return result['deleteModelConfig']['success']
657658

658659
def create_dataset(self,

libs/labelbox/src/labelbox/data/annotation_types/data/raster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def __repr__(self) -> str:
186186
f"url={self.url}," \
187187
f"arr={symbol_or_none(self.arr)})"
188188

189-
model_config = ConfigDict(extra=Extra.forbid,)
189+
model_config = ConfigDict(extra='forbid',)
190190

191191

192192
class MaskData(RasterData):

libs/labelbox/src/labelbox/data/annotation_types/data/video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@ def __repr__(self) -> str:
168168
f"frames={'...' if self.frames is not None else None}," \
169169
f"url={self.url})"
170170

171-
model_config = ConfigDict(extra=Extra.forbid,)
171+
model_config = ConfigDict(extra='forbid',)

libs/labelbox/src/labelbox/data/serialization/labelbox_v1/feature.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ def dict(self, *args, **kwargs):
2727
res.pop('keyframe')
2828
return res
2929

30-
model_config = ConfigDict(allow_population_by_field_name=True,
31-
alias_generator=camel_case)
30+
model_config = ConfigDict(populate_by_name=True, alias_generator=camel_case)

libs/labelbox/src/labelbox/data/serialization/labelbox_v1/label.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def from_common(
101101

102102
return result
103103

104-
model_config = ConfigDict(allow_population_by_field_name=True)
104+
model_config = ConfigDict(populate_by_name=True)
105105

106106

107107
class Review(BaseModel):
@@ -244,4 +244,4 @@ def _is_url(self) -> bool:
244244
("http://", "https://", "gs://",
245245
"s3://")) or "tileLayerUrl" in self.row_data
246246

247-
model_config = ConfigDict(allow_population_by_field_name=True)
247+
model_config = ConfigDict(populate_by_name=True)

libs/labelbox/src/labelbox/data/serialization/ndjson/classification.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def dict(self, *args, **kwargs):
3939
]
4040
return res
4141

42-
model_config = ConfigDict(allow_population_by_field_name=True,
43-
alias_generator=camel_case)
42+
model_config = ConfigDict(populate_by_name=True, alias_generator=camel_case)
4443

4544

4645
class FrameLocation(BaseModel):

libs/labelbox/src/labelbox/schema/bulk_import_request.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def validate_instance(self, valid_feature_schemas_by_id,
658658
self.validate_feature_schemas(valid_feature_schemas_by_id,
659659
valid_feature_schemas_by_name)
660660

661-
model_config = ConfigDict(extra=Extra.forbid,)
661+
model_config = ConfigDict(extra='forbid',)
662662

663663
@staticmethod
664664
def determinants(parent_cls) -> List[str]:
@@ -674,13 +674,13 @@ def determinants(parent_cls) -> List[str]:
674674

675675
class NDText(NDBase):
676676
ontology_type: Literal["text"] = "text"
677-
answer: str = PydanticField(determinant=True)
677+
answer: str = PydanticField({"determinant": True})
678678
#No feature schema to check
679679

680680

681681
class NDChecklist(VideoSupported, NDBase):
682682
ontology_type: Literal["checklist"] = "checklist"
683-
answers: List[NDFeatureSchema] = PydanticField(determinant=True)
683+
answers: List[NDFeatureSchema] = PydanticField({"determinant": True})
684684

685685
@field_validator('answers', mode='before')
686686
def validate_answers(cls, value, field):
@@ -713,7 +713,7 @@ def validate_feature_schemas(self, valid_feature_schemas_by_id,
713713

714714
class NDRadio(VideoSupported, NDBase):
715715
ontology_type: Literal["radio"] = "radio"
716-
answer: NDFeatureSchema = PydanticField(determinant=True)
716+
answer: NDFeatureSchema = PydanticField({"determinant": True})
717717

718718
def validate_feature_schemas(self, valid_feature_schemas_by_id,
719719
valid_feature_schemas_by_name):
@@ -778,7 +778,7 @@ def validate_subclasses(cls, value, field):
778778

779779
class NDPolygon(NDBaseTool):
780780
ontology_type: Literal["polygon"] = "polygon"
781-
polygon: List[Point] = PydanticField(determinant=True)
781+
polygon: List[Point] = PydanticField({"determinant": True})
782782

783783
@field_validator('polygon')
784784
@classmethod
@@ -791,7 +791,7 @@ def is_geom_valid(cls, v):
791791

792792
class NDPolyline(NDBaseTool):
793793
ontology_type: Literal["line"] = "line"
794-
line: List[Point] = PydanticField(determinant=True)
794+
line: List[Point] = PydanticField({"determinant": True})
795795

796796
@field_validator('line')
797797
@classmethod
@@ -804,13 +804,13 @@ def is_geom_valid(cls, v):
804804

805805
class NDRectangle(NDBaseTool):
806806
ontology_type: Literal["rectangle"] = "rectangle"
807-
bbox: Bbox = PydanticField(determinant=True)
807+
bbox: Bbox = PydanticField({"determinant": True})
808808
#Could check if points are positive
809809

810810

811811
class NDPoint(NDBaseTool):
812812
ontology_type: Literal["point"] = "point"
813-
point: Point = PydanticField(determinant=True)
813+
point: Point = PydanticField({"determinant": True})
814814
#Could check if points are positive
815815

816816

@@ -821,7 +821,7 @@ class EntityLocation(BaseModel):
821821

822822
class NDTextEntity(NDBaseTool):
823823
ontology_type: Literal["named-entity"] = "named-entity"
824-
location: EntityLocation = PydanticField(determinant=True)
824+
location: EntityLocation = PydanticField({"determinant": True})
825825

826826
@field_validator('location')
827827
@classmethod
@@ -897,7 +897,7 @@ def validate_color(cls, colorRGB):
897897
class NDMask(NDBaseTool):
898898
ontology_type: Literal["superpixel"] = "superpixel"
899899
mask: Union[URIMaskFeatures, PNGMaskFeatures,
900-
RLEMaskFeatures] = PydanticField(determinant=True)
900+
RLEMaskFeatures] = PydanticField({"determinant": True})
901901

902902

903903
#A union with custom construction logic to improve error messages

libs/labelbox/src/labelbox/schema/project.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313

1414
from labelbox import parser
1515
from labelbox import utils
16-
from labelbox.exceptions import (
17-
InvalidQueryError,
18-
LabelboxError,
19-
ProcessingWaitTimeout,
20-
ResourceConflict,
21-
ResourceNotFoundError
22-
)
16+
from labelbox.exceptions import (InvalidQueryError, LabelboxError,
17+
ProcessingWaitTimeout, ResourceConflict,
18+
ResourceNotFoundError)
2319
from labelbox.orm import query
2420
from labelbox.orm.db_object import DbObject, Deletable, Updateable, experimental
2521
from labelbox.orm.model import Entity, Field, Relationship
@@ -895,8 +891,8 @@ def create_batch(
895891
dr_ids, global_keys, self._wait_processing_max_seconds)
896892

897893
if consensus_settings:
898-
consensus_settings = ConsensusSettings(**consensus_settings).dict(
899-
by_alias=True)
894+
consensus_settings = ConsensusSettings.model_validate(
895+
consensus_settings).dict(by_alias=True)
900896

901897
if row_count >= 1_000:
902898
return self._create_batch_async(name, dr_ids, global_keys, priority,
@@ -952,8 +948,8 @@ def create_batches(
952948
dr_ids, global_keys, self._wait_processing_max_seconds)
953949

954950
if consensus_settings:
955-
consensus_settings = ConsensusSettings(**consensus_settings).dict(
956-
by_alias=True)
951+
consensus_settings = ConsensusSettings.model_validate(
952+
consensus_settings).dict(by_alias=True)
957953

958954
method = 'createBatches'
959955
mutation_str = """mutation %sPyApi($projectId: ID!, $input: CreateBatchesInput!) {
@@ -1019,8 +1015,8 @@ def create_batches_from_dataset(
10191015
raise ValueError("Project must be in batch mode")
10201016

10211017
if consensus_settings:
1022-
consensus_settings = ConsensusSettings(**consensus_settings).dict(
1023-
by_alias=True)
1018+
consensus_settings = ConsensusSettings.model_validate(
1019+
consensus_settings).dict(by_alias=True)
10241020

10251021
method = 'createBatchesFromDataset'
10261022
mutation_str = """mutation %sPyApi($projectId: ID!, $input: CreateBatchesFromDatasetInput!) {
@@ -1751,7 +1747,9 @@ def __check_data_rows_have_been_processed(
17511747
return response["queryAllDataRowsHaveBeenProcessed"][
17521748
"allDataRowsHaveBeenProcessed"]
17531749

1754-
def get_overview(self, details=False) -> Union[ProjectOverview, ProjectOverviewDetailed]:
1750+
def get_overview(
1751+
self,
1752+
details=False) -> Union[ProjectOverview, ProjectOverviewDetailed]:
17551753
"""Return the overview of a project.
17561754
17571755
This method returns the number of data rows per task queue and issues of a project,
@@ -1791,7 +1789,7 @@ def get_overview(self, details=False) -> Union[ProjectOverview, ProjectOverviewD
17911789

17921790
# Must use experimental to access "issues"
17931791
result = self.client.execute(query, {"projectId": self.uid},
1794-
experimental=True)["project"]
1792+
experimental=True)["project"]
17951793

17961794
# Reformat category names
17971795
overview = {
@@ -1804,26 +1802,28 @@ def get_overview(self, details=False) -> Union[ProjectOverview, ProjectOverviewD
18041802

18051803
# Rename categories
18061804
overview["to_label"] = overview.pop("unlabeled")
1807-
overview["total_data_rows"] = overview.pop("all")
1805+
overview["total_data_rows"] = overview.pop("all")
18081806

18091807
if not details:
18101808
return ProjectOverview(**overview)
18111809
else:
18121810
# Build dictionary for queue details for review and rework queues
18131811
for category in ["rework", "review"]:
18141812
queues = [
1815-
{tq["name"]: tq.get("dataRowCount")}
1813+
{
1814+
tq["name"]: tq.get("dataRowCount")
1815+
}
18161816
for tq in result.get("taskQueues")
18171817
if tq.get("queueType") == f"MANUAL_{category.upper()}_QUEUE"
18181818
]
18191819

1820-
overview[f"in_{category}"] = {
1820+
overview[f"in_{category}"] = {
18211821
"data": queues,
18221822
"total": overview[f"in_{category}"]
18231823
}
1824-
1824+
18251825
return ProjectOverviewDetailed(**overview)
1826-
1826+
18271827
def clone(self) -> "Project":
18281828
"""
18291829
Clones the current project.

libs/labelbox/src/labelbox/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def is_valid_uri(uri):
5353

5454

5555
class _CamelCaseMixin(BaseModel):
56-
model_config = ConfigDict(allow_population_by_field_name=True,
57-
alias_generator=camel_case)
56+
model_config = ConfigDict(populate_by_name=True, alias_generator=camel_case)
5857

5958

6059
class _NoCoercionMixin:

libs/labelbox/tests/data/annotation_import/test_label_import.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def test_create_from_objects(client, configured_project, object_predictions,
6969
label_import.input_file_url, object_predictions)
7070

7171

72-
def test_create_with_path_arg(client, tmp_path, configured_project, object_predictions,
72+
def test_create_with_path_arg(client, tmp_path, configured_project,
73+
object_predictions,
7374
annotation_import_test_helpers):
7475
project = configured_project
7576
name = str(uuid.uuid4())
@@ -89,7 +90,8 @@ def test_create_with_path_arg(client, tmp_path, configured_project, object_predi
8990
label_import.input_file_url, object_predictions)
9091

9192

92-
def test_create_from_local_file(client, tmp_path, configured_project, object_predictions,
93+
def test_create_from_local_file(client, tmp_path, configured_project,
94+
object_predictions,
9395
annotation_import_test_helpers):
9496
project = configured_project
9597
name = str(uuid.uuid4())
@@ -99,9 +101,9 @@ def test_create_from_local_file(client, tmp_path, configured_project, object_pre
99101
parser.dump(object_predictions, f)
100102

101103
label_import = LabelImport.create_from_file(client=client,
102-
project_id=project.uid,
103-
name=name,
104-
path=str(file_path))
104+
project_id=project.uid,
105+
name=name,
106+
path=str(file_path))
105107

106108
assert label_import.parent_id == project.uid
107109
annotation_import_test_helpers.check_running_state(label_import, name)

libs/labelbox/tests/data/annotation_import/test_mal_prediction_import.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def test_create_with_labels_arg(client, configured_project, object_predictions,
3939
label_import.input_file_url, object_predictions)
4040

4141

42-
def test_create_with_path_arg(client, tmp_path, configured_project, object_predictions,
42+
def test_create_with_path_arg(client, tmp_path, configured_project,
43+
object_predictions,
4344
annotation_import_test_helpers):
4445
project = configured_project
4546
name = str(uuid.uuid4())

libs/labelbox/tests/data/annotation_import/test_send_to_annotate_mea.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_send_to_annotate_from_model(client, configured_project,
5555
# Check that the data row was sent to the new project
5656
destination_batches = list(destination_project.batches())
5757
assert len(destination_batches) == 1
58-
58+
5959
destination_data_rows = list(destination_batches[0].export_data_rows())
6060
assert len(destination_data_rows) == len(data_row_ids)
6161
assert all([dr.uid in data_row_ids for dr in destination_data_rows])

libs/labelbox/tests/data/export/streamable/test_export_data_rows_streamable.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def test_with_data_row_object(self, client, data_row,
2727
assert export_task.get_total_lines(stream_type=StreamType.RESULT) == 1
2828
assert (json.loads(list(export_task.get_stream())[0].json_str)
2929
["data_row"]["id"] == data_row.uid)
30-
30+
3131
def test_with_data_row_object_buffered(self, client, data_row,
32-
wait_for_data_row_processing):
32+
wait_for_data_row_processing):
3333
data_row = wait_for_data_row_processing(client, data_row)
3434
time.sleep(7) # temp fix for ES indexing delay
3535
export_task = DataRow.export(
@@ -45,7 +45,8 @@ def test_with_data_row_object_buffered(self, client, data_row,
4545
assert export_task.get_total_file_size(
4646
stream_type=StreamType.RESULT) > 0
4747
assert export_task.get_total_lines(stream_type=StreamType.RESULT) == 1
48-
assert list(export_task.get_buffered_stream())[0].json["data_row"]["id"] == data_row.uid
48+
assert list(export_task.get_buffered_stream()
49+
)[0].json["data_row"]["id"] == data_row.uid
4950

5051
def test_with_id(self, client, data_row, wait_for_data_row_processing):
5152
data_row = wait_for_data_row_processing(client, data_row)

libs/labelbox/tests/integration/test_batch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ def test_archive_batch(project: Project, small_dataset: Dataset):
121121
export_task.wait_till_done()
122122
stream = export_task.get_buffered_stream()
123123
data_rows = [dr.json["data_row"]["id"] for dr in stream]
124-
124+
125125
batch = project.create_batch("batch to archive", data_rows)
126126
batch.remove_queued_data_rows()
127127
overview = project.get_overview()
128-
128+
129129
assert overview.to_label == 0
130130

131131

0 commit comments

Comments
 (0)