Skip to content

Commit 8296a43

Browse files
authored
Add missing licenses (#4170)
* Enable copyright rule * Update licenses * Apply simplify rule * Add a notice on preview rules * Update license in utils file
1 parent 7fda29c commit 8296a43

File tree

31 files changed

+93
-12
lines changed

31 files changed

+93
-12
lines changed

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ select = [
212212
"B", # flake8-bugbear (`B`)
213213
"A", # flake8-builtins (`A`)
214214
"COM", # flake8-commas (`COM`)
215-
# "CPY", # flake8-copyright (`CPY`) -> Rules included in the preview version of RUFF. It may be added in the future, but for now, disable it.
216215
"C4", # flake8-comprehensions (`C4`)
217216
"DTZ", # flake8-datatimez (`DTZ`)
218217
"T10", # flake8-debugger (`T10`)
@@ -246,6 +245,11 @@ select = [
246245
"RUF", # Ruff-specific rules (`RUF`)
247246
]
248247

248+
# to be removed when updating to ruff>=2.0
249+
preview = true
250+
explicit-preview-rules = true
251+
extend-select = ["CPY001"]
252+
249253
ignore = [
250254
# pydocstyle
251255
# On top of the Google convention, disable `D417`, which requires
@@ -360,6 +364,12 @@ max-branches = 50
360364
max-statements = 150
361365
max-returns = 10
362366

367+
[tool.ruff.lint.flake8-copyright]
368+
notice-rgx = """
369+
# Copyright \\(C\\) (\\d{4}(-\\d{4})?) Intel Corporation
370+
# SPDX-License-Identifier: Apache-2\\.0
371+
"""
372+
363373
[tool.ruff.per-file-ignores]
364374
# Declare an additional exclude rule for test code
365375
"tests/**/*.py" = [

src/otx/algo/common/utils/assigners/hungarian_matcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def batch_preparation(
280280
"pred_masks": outputs["pred_masks"][i] if "pred_masks" in outputs else None,
281281
"target_boxes": targets[i]["boxes"],
282282
"target_labels": targets[i]["labels"].long(),
283-
"target_mask": targets[i]["masks"] if "masks" in targets[i] else None,
283+
"target_mask": targets[i].get("masks", None),
284284
}
285285
for i in range(batch_size)
286286
]

src/otx/algo/detection/losses/rtdetr_loss.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def __init__(
4141
super().__init__()
4242
self.num_classes = num_classes
4343
self.matcher = HungarianMatcher(cost_dict={"cost_class": 2, "cost_bbox": 5, "cost_giou": 2})
44-
loss_bbox_weight = weight_dict["loss_bbox"] if "loss_bbox" in weight_dict else 1.0
45-
loss_giou_weight = weight_dict["loss_giou"] if "loss_giou" in weight_dict else 1.0
46-
self.loss_vfl_weight = weight_dict["loss_vfl"] if "loss_vfl" in weight_dict else 1.0
44+
loss_bbox_weight = weight_dict.get("loss_bbox", 1.0)
45+
loss_giou_weight = weight_dict.get("loss_giou", 1.0)
46+
self.loss_vfl_weight = weight_dict.get("loss_vfl", 1.0)
4747
self.alpha = alpha
4848
self.gamma = gamma
4949
self.lossl1 = L1Loss(loss_weight=loss_bbox_weight)

src/otx/algo/instance_segmentation/losses/maskdino_loss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ def __init__(
198198
self.num_classes = num_classes
199199
self.matcher = matcher
200200
self.weight_dict = weight_dict
201-
loss_bbox_weight = weight_dict["loss_bbox"] if "loss_bbox" in weight_dict else 1.0
202-
loss_giou_weight = weight_dict["loss_giou"] if "loss_giou" in weight_dict else 1.0
201+
loss_bbox_weight = weight_dict.get("loss_bbox", 1.0)
202+
loss_giou_weight = weight_dict.get("loss_giou", 1.0)
203203
self.lossl1 = L1Loss(loss_weight=loss_bbox_weight)
204204
self.giou = GIoULoss(loss_weight=loss_giou_weight)
205205

src/otx/algo/keypoint_detection/heads/rtmcc_head.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (C) 2024 Intel Corporation
2-
# # SPDX-License-Identifier: Apache-2.0
2+
# SPDX-License-Identifier: Apache-2.0
3+
34
# Copyright (c) OpenMMLab. All rights reserved.
45
"""Implementation of RTMCCHead."""
56
from __future__ import annotations

src/otx/algo/utils/mmengine_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def load_checkpoint_to_model(
207207
state_dict = checkpoint["ema"]["module"] if "ema" in checkpoint else checkpoint.get("state_dict", checkpoint)
208208

209209
# TODO(Eugene): remove this when MaskDINO weights is updloaded to openvino storage.
210-
state_dict = state_dict["model"] if "model" in state_dict else state_dict
210+
state_dict = state_dict.get("model", state_dict)
211211

212212
# strip prefix of state_dict
213213
metadata = getattr(state_dict, "_metadata", OrderedDict())

src/otx/core/utils/pylogger.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# Copyright (C) 2023-2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
# MIT License
25

3-
# Copyright (c) 2023 Intel Corporation
46
# Copyright (c) 2021 ashleve
57

68
# Permission is hereby granted, free of charge, to any person obtaining a copy

src/otx/core/utils/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Copyright (c) 2024 Intel Corporation
1+
# Copyright (C) 2024-2025 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
3-
#
3+
44
"""Utility functions."""
55

66
from __future__ import annotations

tests/fuzzing/cli_fuzzing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!.tox/fuzzing/bin/python
22

3+
# Copyright (C) 2025 Intel Corporation
4+
# SPDX-License-Identifier: Apache-2.0
5+
36
import sys
47

58
import atheris

tests/fuzzing/eval_fuzzing_crash.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!.tox/fuzzing/bin/python
22

3+
# Copyright (C) 2025 Intel Corporation
4+
# SPDX-License-Identifier: Apache-2.0
5+
36
import sys
47
from pathlib import Path
58

0 commit comments

Comments
 (0)