Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#1665)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.12.1 → 24.3.0](psf/black@23.12.1...24.3.0)
- [github.com/psf/black: 23.12.1 → 24.3.0](psf/black@23.12.1...24.3.0)
- [github.com/PyCQA/flake8: 6.1.0 → 7.0.0](PyCQA/flake8@6.1.0...7.0.0)
- [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](pre-commit/mirrors-mypy@v1.8.0...v1.9.0)
- [github.com/asottile/pyupgrade: v3.15.0 → v3.15.2](asottile/pyupgrade@v3.15.0...v3.15.2)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update requirements.txt

Signed-off-by: SACHIDANAND ALLE <sachidanand.alle@gmail.com>

* Update setup.cfg

Signed-off-by: SACHIDANAND ALLE <sachidanand.alle@gmail.com>

---------

Signed-off-by: SACHIDANAND ALLE <sachidanand.alle@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: SACHIDANAND ALLE <sachidanand.alle@gmail.com>
  • Loading branch information
pre-commit-ci[bot] and SachidanandAlle authored Apr 1, 2024
1 parent 6e43aa4 commit ba98089
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 47 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,33 @@ repos:
args: ["--line-length=120", "--profile=black", "--check"]

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.3.0
hooks:
- id: black
args: ["--line-length=120"]

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.3.0
hooks:
- id: black
name: black (check)
args: ["--line-length=120", "--check"]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
args: ["--count", "--statistics", "--config=setup.cfg"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.9.0
hooks:
- id: mypy
exclude: (^tests/|^plugins/)
additional_dependencies: [types-PyYAML,types-filelock,types-requests,types-docutils,types-cachetools]

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py37-plus]
10 changes: 5 additions & 5 deletions monailabel/endpoints/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ async def proxy_dicom(request: Request, op: str, path: str):
prefix = (
settings.MONAI_LABEL_WADO_PREFIX
if op == "wado"
else settings.MONAI_LABEL_QIDO_PREFIX
if op == "qido"
else settings.MONAI_LABEL_STOW_PREFIX
if op == "stow"
else ""
else (
settings.MONAI_LABEL_QIDO_PREFIX
if op == "qido"
else settings.MONAI_LABEL_STOW_PREFIX if op == "stow" else ""
)
)

# some version of ohif requests metadata using qido so change it to wado
Expand Down
10 changes: 5 additions & 5 deletions monailabel/interfaces/utils/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def dump_data(data, level=logging.DEBUG):
level,
"Data key: {} = {}".format(
k,
v.shape
if hasattr(v, "shape")
else v
if type(v) in (int, float, bool, str, dict, tuple, list)
else type(v),
(
v.shape
if hasattr(v, "shape")
else v if type(v) in (int, float, bool, str, dict, tuple, list) else type(v)
),
),
)
logger.log(level, "******************************************************************************")
Expand Down
6 changes: 3 additions & 3 deletions monailabel/scribbles/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ def __call__(self, data):
cz = int((selected_roi[4] + selected_roi[5]) / 2)

# add scribbles at center of roi
scribbles[
:, cx - offset : cx + offset, cy - offset : cy + offset, cz - offset : cz + offset
] = self.scribbles_fg_label
scribbles[:, cx - offset : cx + offset, cy - offset : cy + offset, cz - offset : cz + offset] = (
self.scribbles_fg_label
)

# return new scribbles
d = self._save_data(d, self.scribbles, scribbles)
Expand Down
22 changes: 13 additions & 9 deletions monailabel/tasks/infer/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,19 @@ def _get_type(self, name, type):
(
InferType.DEEPEDIT
if "deepedit" in name
else InferType.DEEPGROW
if "deepgrow" in name
else InferType.DETECTION
if "detection" in name
else InferType.SEGMENTATION
if "segmentation" in name
else InferType.CLASSIFICATION
if "classification" in name
else InferType.SEGMENTATION
else (
InferType.DEEPGROW
if "deepgrow" in name
else (
InferType.DETECTION
if "detection" in name
else (
InferType.SEGMENTATION
if "segmentation" in name
else InferType.CLASSIFICATION if "classification" in name else InferType.SEGMENTATION
)
)
)
)
if not type
else type
Expand Down
4 changes: 1 addition & 3 deletions monailabel/tasks/scoring/epistemic.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def infer_seg(self, data, model, roi_size, sw_batch_size):
pre_transforms = (
None
if not self.transforms
else self.transforms
if isinstance(self.transforms, Compose)
else Compose(self.transforms)
else self.transforms if isinstance(self.transforms, Compose) else Compose(self.transforms)
)
# data = run_transforms(data, pre_transforms, log_prefix="EPISTEMIC-PRE") if pre_transforms else data
if pre_transforms:
Expand Down
20 changes: 12 additions & 8 deletions monailabel/tasks/train/basic_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,15 @@ def _dataset(self, context, datalist, is_train, replace_rate=0.25):
dataset = (
CacheDataset(datalist, transforms)
if context.dataset_type == "CacheDataset"
else SmartCacheDataset(datalist, transforms, replace_rate)
if context.dataset_type == "SmartCacheDataset"
else PersistentDataset(datalist, transforms, cache_dir=os.path.join(context.cache_dir, "pds"))
if context.dataset_type == "PersistentDataset"
else Dataset(datalist, transforms)
else (
SmartCacheDataset(datalist, transforms, replace_rate)
if context.dataset_type == "SmartCacheDataset"
else (
PersistentDataset(datalist, transforms, cache_dir=os.path.join(context.cache_dir, "pds"))
if context.dataset_type == "PersistentDataset"
else Dataset(datalist, transforms)
)
)
)
return dataset, datalist

Expand Down Expand Up @@ -681,9 +685,9 @@ def _create_trainer(self, context: Context):
save_final=True,
final_filename=self._final_filename,
save_key_metric=True,
key_metric_filename=f"train_{self._key_metric_filename}"
if context.evaluator
else self._key_metric_filename,
key_metric_filename=(
f"train_{self._key_metric_filename}" if context.evaluator else self._key_metric_filename
),
n_saved=self._n_saved,
)
)
Expand Down
8 changes: 5 additions & 3 deletions monailabel/tasks/train/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ def config(self):
"val_split": 0.2, # VALIDATION SPLIT; -1 TO USE DEFAULT FROM BUNDLE
"multi_gpu": True, # USE MULTI-GPU
"gpus": "all", # COMMA SEPARATE DEVICE INDEX
"tracking": ["mlflow", "None"]
if self.enable_tracking and settings.MONAI_LABEL_TRACKING_ENABLED
else ["None", "mlflow"],
"tracking": (
["mlflow", "None"]
if self.enable_tracking and settings.MONAI_LABEL_TRACKING_ENABLED
else ["None", "mlflow"]
),
"tracking_uri": settings.MONAI_LABEL_TRACKING_URI,
"tracking_experiment_name": "",
"run_id": "", # bundle run id, if different from default
Expand Down
4 changes: 3 additions & 1 deletion plugins/slicer/MONAILabelReviewer/MONAILabelReviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,9 @@ def updateAfterEditingSegmentation(self):

elif setToOverwrite:
if (imageVersionTag == self.LABEL.FINAL) or (imageVersionTag == self.LABEL.ORIGINAL):
warningMessage: str = "Initial Segmentation with label 'final' or 'original' \ncannot be overwritten.\n Please save current edit as new version."
warningMessage: str = (
"Initial Segmentation with label 'final' or 'original' \ncannot be overwritten.\n Please save current edit as new version."
)
slicer.util.warningDisplay(warningMessage)
logging.warn(warningMessage)
return
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fastapi==0.95.0
python-multipart==0.0.6
httpx==0.23.3
schedule==1.1.0
dicomweb-client==0.59.1
dicomweb-client[gcp]==0.59.1
timeloop==1.0.2
expiringdict==1.2.2
expiring_dict==1.1.0
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ install_requires =
requests-toolbelt==0.10.1
httpx==0.23.3
schedule==1.1.0
dicomweb-client==0.59.1
dicomweb-client[gcp]==0.59.1
timeloop==1.0.2
expiringdict==1.2.2
expiring_dict==1.1.0
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/scribbles/test_transforms_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ def add_scribbles_from_roi(scribbles, roi, scribbles_fg_label, scribbles_bg_labe
cz = int((roi[4] + roi[5]) / 2)

# add scribbles at center of roi
scribbles[
:, cx - offset : cx + offset, cy - offset : cy + offset, cz - offset : cz + offset
] = scribbles_fg_label
scribbles[:, cx - offset : cx + offset, cy - offset : cy + offset, cz - offset : cz + offset] = (
scribbles_fg_label
)

return scribbles

Expand Down

0 comments on commit ba98089

Please sign in to comment.