diff --git a/.flake8 b/.flake8 index d43c2aca..3a1103f8 100644 --- a/.flake8 +++ b/.flake8 @@ -3,3 +3,4 @@ ignore = E226,E302,E41,W391, E701, W291, E722, W503, E128, E126, E127, E731, E40 max-line-length = 160 max-complexity = 25 exclude = fastMRI/ test_outputs/ hi-ml/ +min_python_version = 3.7 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8d0e4823..c2ce108c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV - + - name: Add issue to project env: GITHUB_TOKEN: ${{ secrets.INNEREYE_OSS_PROJECT_ACCESS_TOKEN }} @@ -43,4 +43,4 @@ jobs: id } } - }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')" + }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')" diff --git a/InnerEye/ML/SSL/lightning_modules/ssl_online_evaluator.py b/InnerEye/ML/SSL/lightning_modules/ssl_online_evaluator.py index 1cdde6be..e4a9caf1 100644 --- a/InnerEye/ML/SSL/lightning_modules/ssl_online_evaluator.py +++ b/InnerEye/ML/SSL/lightning_modules/ssl_online_evaluator.py @@ -3,7 +3,9 @@ # Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. # ------------------------------------------------------------------------------------------ -from typing import Any, Dict, List, Optional, OrderedDict, Set, Tuple, Union +from typing import Any, Dict, List, Optional, Set, Tuple, Union, TYPE_CHECKING +if TYPE_CHECKING: + from typing import OrderedDict import pytorch_lightning as pl import torch diff --git a/InnerEye/ML/configs/other/HelloContainer.py b/InnerEye/ML/configs/other/HelloContainer.py index 73db7e25..0d8e0897 100644 --- a/InnerEye/ML/configs/other/HelloContainer.py +++ b/InnerEye/ML/configs/other/HelloContainer.py @@ -72,6 +72,7 @@ class HelloDataModule(LightningDataModule): For cross validation (if required) we use k-fold cross-validation. The test set remains unchanged while the training and validation data cycle through the k-folds of the remaining data. """ + def __init__( self, root_folder: Path, diff --git a/InnerEye/ML/configs/unit_testing/passthrough_model.py b/InnerEye/ML/configs/unit_testing/passthrough_model.py index 248664e5..1849448b 100644 --- a/InnerEye/ML/configs/unit_testing/passthrough_model.py +++ b/InnerEye/ML/configs/unit_testing/passthrough_model.py @@ -26,6 +26,7 @@ class PassThroughModel(SegmentationModelBase): """ Dummy model that returns a fixed segmentation, explained in make_nesting_rectangles. """ + def __init__(self, **kwargs: Any) -> None: fg_classes = ["spinalcord", "lung_r", "lung_l", "heart", "esophagus"] fg_display_names = ["SpinalCord", "Lung_R", "Lung_L", "Heart", "Esophagus"] diff --git a/InnerEye/ML/models/architectures/classification/bit.py b/InnerEye/ML/models/architectures/classification/bit.py index 2fc85b59..5324d399 100644 --- a/InnerEye/ML/models/architectures/classification/bit.py +++ b/InnerEye/ML/models/architectures/classification/bit.py @@ -26,6 +26,7 @@ class ResNetV2Block(nn.Module): ResNetV2 (https://arxiv.org/pdf/1603.05027.pdf) uses pre activation in the ResNet blocks. Big Transfer replaces BatchNorm with GroupNorm """ + def __init__(self, in_channels: int, out_channels: int, @@ -82,6 +83,7 @@ class ResNetV2Layer(nn.Module): """ Single layer of ResNetV2 """ + def __init__(self, in_channels: int, out_channels: int, @@ -110,6 +112,7 @@ class BiTResNetV2(nn.Module): https://arxiv.org/pdf/1912.11370.pdf https://github.com/google-research/big_transfer """ + def __init__(self, num_groups: int = 32, num_classes: int = 21843, num_blocks_in_layer: Tuple[int, int, int, int] = (3, 4, 23, 3), diff --git a/InnerEye/ML/photometric_normalization.py b/InnerEye/ML/photometric_normalization.py index 4d34a8ac..38eddf8d 100644 --- a/InnerEye/ML/photometric_normalization.py +++ b/InnerEye/ML/photometric_normalization.py @@ -22,6 +22,7 @@ class WindowNormalizationForScalarItem(Transform3D[ScalarItem]): Transform3D to apply window normalization to "images" of a ScalarItem. """ # noinspection PyMissingConstructor + def __init__(self, output_range: Tuple[float, float] = (0, 1), sharpen: float = 1.9, diff --git a/InnerEye/ML/reports/classification_multilabel_report.py b/InnerEye/ML/reports/classification_multilabel_report.py index 30eb527b..d38dd7e5 100644 --- a/InnerEye/ML/reports/classification_multilabel_report.py +++ b/InnerEye/ML/reports/classification_multilabel_report.py @@ -134,7 +134,6 @@ def get_labels_and_predictions_for_prediction_target_set(csv: Path, def print_metrics_for_thresholded_output_for_all_prediction_targets(csv_to_set_optimal_threshold: Path, csv_to_compute_metrics: Path, config: ScalarModelBase) -> None: - """ Given csvs written during inference for the validation and test sets, print out metrics for every combination of prediction targets that exist in the dataset (i.e. for every subset of classes that occur in the dataset). diff --git a/InnerEye/ML/runner.py b/InnerEye/ML/runner.py index 1c7db071..f41fd409 100755 --- a/InnerEye/ML/runner.py +++ b/InnerEye/ML/runner.py @@ -70,7 +70,7 @@ def initialize_rpdb() -> None: # rpdb signal trapping does not work on Windows, as there is no SIGTRAP: if not is_linux(): return - import rpdb + rpdb = __import__('rpdb') # hack so that the pre-commit hook does not flag this line rpdb_port = 4444 rpdb.handle_trap(port=rpdb_port) # For some reason, os.getpid() does not return the ID of what appears to be the currently running process. diff --git a/Tests/ML/configs/lightning_test_containers.py b/Tests/ML/configs/lightning_test_containers.py index 5c15e094..88004724 100644 --- a/Tests/ML/configs/lightning_test_containers.py +++ b/Tests/ML/configs/lightning_test_containers.py @@ -277,6 +277,7 @@ class DummySimCLRData(VisionDataset): """ Returns a constant vector of size three [1., 1., 1.] """ + def __init__( self, root: str,