Skip to content

Commit

Permalink
Remove deprecated args and class for v1.3 (#7019)
Browse files Browse the repository at this point in the history
Fixes #7018.

### Description
- Remove `compute_meaniou`
- Remove `AsChannelFirst`, `AddChannel` and `SplitChannel`
- Remove `create_multigpu_supervised_trainer` and
`create_multigpu_supervised_evaluator`
- deprecated `data_src_cfg_filename` in `AlgoEnsembleBuilder`
- deprecated `runner_id` in `run`
- deprecated `epoch_interval` and `iteration_interval` in
`TensorBoardStatsHandler`
- deprecated `get_validation_stats` in `Evaluator`
- deprecated `get_train_stats` in `Trainer`
- update the default value of `name` to `StatsHandler` in `StatsHandler`
- update the default value of `random_size` to `False` in
`RandSpatialCrop`, `RandScaleCrop`, `RandSpatialCropSamples`
- update the default value of `image_only` to `True` in `LoadImage` and
`SaveImage`
- update `MetaTenor` related deprecation

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: KumoLiu <[email protected]>
  • Loading branch information
KumoLiu authored Sep 22, 2023
1 parent 0d1337e commit 7dfa0b9
Show file tree
Hide file tree
Showing 54 changed files with 74 additions and 903 deletions.
6 changes: 0 additions & 6 deletions docs/source/engines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
Engines
=======

Multi-GPU data parallel
-----------------------

.. automodule:: monai.engines.multi_gpu_supervised_trainer
:members:

Workflows
---------

Expand Down
2 changes: 1 addition & 1 deletion docs/source/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Metrics

`Mean IoU`
----------
.. autofunction:: compute_meaniou
.. autofunction:: compute_iou

.. autoclass:: MeanIoU
:members:
Expand Down
36 changes: 0 additions & 36 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -996,24 +996,12 @@ Utility
:members:
:special-members: __call__

`AsChannelFirst`
""""""""""""""""
.. autoclass:: AsChannelFirst
:members:
:special-members: __call__

`AsChannelLast`
"""""""""""""""
.. autoclass:: AsChannelLast
:members:
:special-members: __call__

`AddChannel`
""""""""""""
.. autoclass:: AddChannel
:members:
:special-members: __call__

`EnsureChannelFirst`
""""""""""""""""""""
.. autoclass:: EnsureChannelFirst
Expand All @@ -1032,12 +1020,6 @@ Utility
:members:
:special-members: __call__

`SplitChannel`
""""""""""""""
.. autoclass:: SplitChannel
:members:
:special-members: __call__

`CastToType`
""""""""""""
.. autoclass:: CastToType
Expand Down Expand Up @@ -1983,24 +1965,12 @@ Utility (Dict)
:members:
:special-members: __call__

`AsChannelFirstd`
"""""""""""""""""
.. autoclass:: AsChannelFirstd
:members:
:special-members: __call__

`AsChannelLastd`
""""""""""""""""
.. autoclass:: AsChannelLastd
:members:
:special-members: __call__

`AddChanneld`
"""""""""""""
.. autoclass:: AddChanneld
:members:
:special-members: __call__

`EnsureChannelFirstd`
"""""""""""""""""""""
.. autoclass:: EnsureChannelFirstd
Expand All @@ -2019,12 +1989,6 @@ Utility (Dict)
:members:
:special-members: __call__

`SplitChanneld`
"""""""""""""""
.. autoclass:: SplitChanneld
:members:
:special-members: __call__

`CastToTyped`
"""""""""""""
.. autoclass:: CastToTyped
Expand Down
9 changes: 1 addition & 8 deletions monai/apps/auto3dseg/ensemble_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from monai.bundle import ConfigParser
from monai.data import partition_dataset
from monai.transforms import MeanEnsemble, SaveImage, VoteEnsemble
from monai.utils import RankFilter, deprecated_arg
from monai.utils import RankFilter
from monai.utils.enums import AlgoKeys
from monai.utils.misc import check_kwargs_exist_in_class_init, prob2class
from monai.utils.module import look_up_option, optional_import
Expand Down Expand Up @@ -332,13 +332,6 @@ class AlgoEnsembleBuilder:
"""

@deprecated_arg(
"data_src_cfg_filename",
since="1.2",
removed="1.3",
new_name="data_src_cfg_name",
msg_suffix="please use `data_src_cfg_name` instead.",
)
def __init__(self, history: Sequence[dict[str, Any]], data_src_cfg_name: str | None = None):
self.infer_algos: list[dict[AlgoKeys, Any]] = []
self.ensemble: AlgoEnsemble
Expand Down
7 changes: 2 additions & 5 deletions monai/apps/deepgrow/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ def __call__(self, data):

if np.all(np.less(current_size, self.spatial_size)):
cropper = SpatialCrop(roi_center=center, roi_size=self.spatial_size)
box_start = np.array([s.start for s in cropper.slices])
box_end = np.array([s.stop for s in cropper.slices])
box_start = np.array([s.start for s in cropper.slices]) # type: ignore[assignment]
box_end = np.array([s.stop for s in cropper.slices]) # type: ignore[assignment]
else:
cropper = SpatialCrop(roi_start=box_start, roi_end=box_end)

Expand Down Expand Up @@ -492,9 +492,6 @@ class AddGuidanceFromPointsd(Transform):
For example, to handle key `image`, read/write affine matrices from the
metadata `image_meta_dict` dictionary's `affine` field.
.. deprecated:: 0.6.0
``dimensions`` is deprecated, use ``spatial_dims`` instead.
"""

def __init__(
Expand Down
3 changes: 1 addition & 2 deletions monai/bundle/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ def get_bundle_info(
return bundle_info[version] # type: ignore[no-any-return]


@deprecated_arg("runner_id", since="1.1", removed="1.3", new_name="run_id", msg_suffix="please use `run_id` instead.")
def run(
run_id: str | None = None,
init_id: str | None = None,
Expand Down Expand Up @@ -766,7 +765,7 @@ def run(
will patch the target config content with `tracking handlers` and the top-level items of `configs`.
for detailed usage examples, please check the tutorial:
https://github.com/Project-MONAI/tutorials/blob/main/experiment_management/bundle_integrate_mlflow.ipynb.
args_file: a JSON or YAML file to provide default values for `runner_id`, `meta_file`,
args_file: a JSON or YAML file to provide default values for `run_id`, `meta_file`,
`config_file`, `logging`, and override pairs. so that the command line inputs can be simplified.
override: id-value pairs to override or add the corresponding config content.
e.g. ``--net#input_chns 42``, ``--net %/data/other.json#net_arg``.
Expand Down
3 changes: 0 additions & 3 deletions monai/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,9 +1482,6 @@ class CSVDataset(Dataset):
kwargs_read_csv: dictionary args to pass to pandas `read_csv` function.
kwargs: additional arguments for `pandas.merge()` API to join tables.
.. deprecated:: 0.8.0
``filename`` is deprecated, use ``src`` instead.
"""

def __init__(
Expand Down
6 changes: 0 additions & 6 deletions monai/data/grid_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ class GridPatchDataset(IterableDataset):
transform: a callable data transform operates on the patches.
with_coordinates: whether to yield the coordinates of each patch, default to `True`.
.. deprecated:: 0.8.0
``dataset`` is deprecated, use ``data`` instead.
"""

def __init__(
Expand Down Expand Up @@ -253,9 +250,6 @@ class PatchDataset(Dataset):
>>> torch.Size([2, 1, 3, 3])
.. deprecated:: 0.8.0
``dataset`` is deprecated, use ``data`` instead.
"""

def __init__(
Expand Down
7 changes: 2 additions & 5 deletions monai/data/image_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import numpy as np
from torch.utils.data._utils.collate import np_str_obj_array_pattern

from monai.config import DtypeLike, KeysCollection, PathLike
from monai.config import KeysCollection, PathLike
from monai.data.utils import (
affine_to_spacing,
correct_nifti_header_if_necessary,
is_no_channel,
is_supported_format,
orientation_ras_lps,
)
from monai.utils import MetaKeys, SpaceKeys, TraceKeys, deprecated_arg, ensure_tuple, optional_import, require_pkg
from monai.utils import MetaKeys, SpaceKeys, TraceKeys, ensure_tuple, optional_import, require_pkg

if TYPE_CHECKING:
import itk
Expand Down Expand Up @@ -861,20 +861,17 @@ class NibabelReader(ImageReader):
"""

@deprecated_arg("dtype", since="1.0", msg_suffix="please modify dtype of the returned by ``get_data`` instead.")
def __init__(
self,
channel_dim: str | int | None = None,
as_closest_canonical: bool = False,
squeeze_non_spatial_dims: bool = False,
dtype: DtypeLike = np.float32,
**kwargs,
):
super().__init__()
self.channel_dim = float("nan") if channel_dim == "no_channel" else channel_dim
self.as_closest_canonical = as_closest_canonical
self.squeeze_non_spatial_dims = squeeze_non_spatial_dims
self.dtype = dtype # deprecated
self.kwargs = kwargs

def verify_suffix(self, filename: Sequence[PathLike] | PathLike) -> bool:
Expand Down
5 changes: 0 additions & 5 deletions monai/data/iterable_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,6 @@ class CSVIterableDataset(IterableDataset):
kwargs_read_csv: dictionary args to pass to pandas `read_csv` function. Default to ``{"chunksize": chunksize}``.
kwargs: additional arguments for `pandas.merge()` API to join tables.
.. deprecated:: 0.8.0
``filename`` is deprecated, use ``src`` instead.
"""

def __init__(
Expand All @@ -223,8 +220,6 @@ def __init__(
self.shuffle = shuffle
self.seed = seed
self.kwargs_read_csv = kwargs_read_csv or {"chunksize": chunksize}
# in case treating deprecated arg `filename` as kwargs, remove it from `kwargs`
kwargs.pop("filename", None)
self.kwargs = kwargs

self.iters: list[Iterable] = self.reset()
Expand Down
1 change: 0 additions & 1 deletion monai/engines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from __future__ import annotations

from .evaluator import EnsembleEvaluator, Evaluator, SupervisedEvaluator
from .multi_gpu_supervised_trainer import create_multigpu_supervised_evaluator, create_multigpu_supervised_trainer
from .trainer import GanTrainer, SupervisedTrainer, Trainer
from .utils import (
IterationEvents,
Expand Down
6 changes: 1 addition & 5 deletions monai/engines/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from monai.inferers import Inferer, SimpleInferer
from monai.networks.utils import eval_mode, train_mode
from monai.transforms import Transform
from monai.utils import ForwardMode, deprecated, ensure_tuple, min_version, optional_import
from monai.utils import ForwardMode, ensure_tuple, min_version, optional_import
from monai.utils.enums import CommonKeys as Keys
from monai.utils.enums import EngineStatsKeys as ESKeys
from monai.utils.module import look_up_option
Expand Down Expand Up @@ -167,10 +167,6 @@ def get_stats(self, *vars):
stats[k] = getattr(self.state, k, None)
return stats

@deprecated(since="0.9", msg_suffix="please use the `get_stats()` API instead.")
def get_validation_stats(self):
return {"best_validation_metric": self.state.best_metric, "best_validation_epoch": self.state.best_metric_epoch}


class SupervisedEvaluator(Evaluator):
"""
Expand Down
Loading

0 comments on commit 7dfa0b9

Please sign in to comment.