Skip to content

Commit a85da62

Browse files
authored
Remove all deprecated args, kwargs for v0.5.0 (#1396) (#1397)
* Remove all deprecated args, kwargs for v0.5.0 (#1396) * Improve deprecation message of setup_any_logging (#1396)
1 parent acd2982 commit a85da62

File tree

8 files changed

+8
-98
lines changed

8 files changed

+8
-98
lines changed

ignite/contrib/engines/common.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def setup_common_training_handlers(
4343
with_pbars: bool = True,
4444
with_pbar_on_iters: bool = True,
4545
log_every_iters: int = 100,
46-
device: Optional[Union[str, torch.device]] = None,
4746
stop_on_nan: bool = True,
4847
clear_cuda_cache: bool = True,
4948
save_handler: Optional[Union[Callable, BaseSaveHandler]] = None,
@@ -86,10 +85,7 @@ def setup_common_training_handlers(
8685
class to use to store ``to_save``. See :class:`~ignite.handlers.checkpoint.Checkpoint` for more details.
8786
Argument is mutually exclusive with ``output_path``.
8887
**kwargs: optional keyword args to be passed to construct :class:`~ignite.handlers.checkpoint.Checkpoint`.
89-
device (str of torch.device, optional): deprecated argument, it will be removed in v0.5.0.
9088
"""
91-
if device is not None:
92-
warnings.warn("Argument device is unused and deprecated. It will be removed in v0.5.0")
9389

9490
_kwargs = dict(
9591
to_save=to_save,
@@ -257,8 +253,8 @@ def empty_cuda_cache(_):
257253

258254
def setup_any_logging(logger, logger_module, trainer, optimizers, evaluators, log_every_iters):
259255
raise DeprecationWarning(
260-
"ignite.contrib.engines.common.setup_any_logging is deprecated since 0.4.0. "
261-
"Please use ignite.contrib.engines.common._setup_logging instead."
256+
"ignite.contrib.engines.common.setup_any_logging is deprecated since 0.4.0. and will be remove in 0.6.0. "
257+
"Please use instead: setup_tb_logging, setup_visdom_logging or setup_mlflow_logging etc."
262258
)
263259

264260

ignite/engine/engine.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def state_dict_user_keys(self) -> List:
473473
return self._state_dict_user_keys
474474

475475
def state_dict(self) -> OrderedDict:
476-
"""Returns a dictionary containing engine's state: "seed", "epoch_length", "max_epochs" and "iteration" and
476+
"""Returns a dictionary containing engine's state: "epoch_length", "max_epochs" and "iteration" and
477477
other state values defined by `engine.state_dict_user_keys`
478478
479479
.. code-block:: python
@@ -506,8 +506,8 @@ def save_engine(_):
506506
def load_state_dict(self, state_dict: Mapping) -> None:
507507
"""Setups engine from `state_dict`.
508508
509-
State dictionary should contain keys: `iteration` or `epoch` and `max_epochs`, `epoch_length` and
510-
`seed`. If `engine.state_dict_user_keys` contains keys, they should be also present in the state dictionary.
509+
State dictionary should contain keys: `iteration` or `epoch`, `max_epochs` and `epoch_length`.
510+
If `engine.state_dict_user_keys` contains keys, they should be also present in the state dictionary.
511511
Iteration and epoch values are 0-based: the first iteration or epoch is zero.
512512
513513
This method does not remove any custom attributs added by user.
@@ -595,18 +595,12 @@ def switch_dataloader():
595595
self.state.dataloader = data
596596
self._dataloader_iter = iter(self.state.dataloader)
597597

598-
def run(
599-
self,
600-
data: Iterable,
601-
max_epochs: Optional[int] = None,
602-
epoch_length: Optional[int] = None,
603-
seed: Optional[int] = None,
604-
) -> State:
598+
def run(self, data: Iterable, max_epochs: Optional[int] = None, epoch_length: Optional[int] = None,) -> State:
605599
"""Runs the `process_function` over the passed data.
606600
607601
Engine has a state and the following logic is applied in this function:
608602
609-
- At the first call, new state is defined by `max_epochs`, `epoch_length`, `seed` if provided. A timer for
603+
- At the first call, new state is defined by `max_epochs`, `epoch_length` if provided. A timer for
610604
total and per-epoch time is initialized when Events.STARTED is handled.
611605
- If state is already defined such that there are iterations to run until `max_epochs` and no input arguments
612606
provided, state is kept and used in the function.
@@ -623,8 +617,6 @@ def run(
623617
`len(data)`. If `data` is an iterator and `epoch_length` is not set, then it will be automatically
624618
determined as the iteration on which data iterator raises `StopIteration`.
625619
This argument should not change if run is resuming from a state.
626-
seed (int, optional): Deprecated argument. Please, use `torch.manual_seed` or
627-
:meth:`~ignite.utils.manual_seed`.
628620
629621
Returns:
630622
State: output state.
@@ -653,12 +645,6 @@ def switch_batch(engine):
653645
trainer.run(train_loader, max_epochs=2)
654646
655647
"""
656-
if seed is not None:
657-
warnings.warn(
658-
"Argument seed is deprecated. It will be removed in 0.5.0. "
659-
"Please, use torch.manual_seed or ignite.utils.manual_seed"
660-
)
661-
662648
if not isinstance(data, Iterable):
663649
raise TypeError("Argument data should be iterable")
664650

ignite/engine/events.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,6 @@ def __or__(self, other: Any) -> "EventsList":
135135
return EventsList() | self | other
136136

137137

138-
class CallableEvents(CallableEventWithFilter):
139-
# For backward compatibility
140-
def __init__(self, *args: Any, **kwargs: Any) -> None:
141-
super(CallableEvents, self).__init__(*args, **kwargs)
142-
warnings.warn(
143-
"Class ignite.engine.events.CallableEvents is deprecated. It will be removed in 0.5.0. "
144-
"Please, use ignite.engine.EventEnum instead",
145-
DeprecationWarning,
146-
)
147-
148-
149138
class EventEnum(CallableEventWithFilter, Enum): # type: ignore[misc]
150139
"""Base class for all :class:`~ignite.engine.events.Events`. User defined custom events should also inherit
151140
this class. For example, Custom events based on the loss calculation and backward pass can be created as follows:

ignite/handlers/checkpoint.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class Checkpoint(Serializable):
9393
Input of the function is ``(engine, event_name)``. Output of function should be an integer.
9494
Default is None, global_step based on attached engine. If provided, uses function output as global_step.
9595
To setup global step from another engine, please use :meth:`~ignite.handlers.global_step_from_engine`.
96-
archived (bool, optional): Deprecated argument as models saved by ``torch.save`` are already compressed.
9796
filename_pattern (str, optional): If ``filename_pattern`` is provided, this pattern will be used to render
9897
checkpoint filenames. If the pattern is not defined, the default pattern would be used. See Note for
9998
details.
@@ -246,7 +245,6 @@ def __init__(
246245
score_name: Optional[str] = None,
247246
n_saved: Optional[int] = 1,
248247
global_step_transform: Callable = None,
249-
archived: bool = False,
250248
filename_pattern: Optional[str] = None,
251249
include_self: bool = False,
252250
):
@@ -279,8 +277,6 @@ def __init__(
279277
raise TypeError(
280278
"global_step_transform should be a function, got {} instead.".format(type(global_step_transform))
281279
)
282-
if archived:
283-
warnings.warn("Argument archived is deprecated and will be removed in 0.5.0")
284280

285281
self.to_save = to_save
286282
self.filename_prefix = filename_prefix
@@ -626,11 +622,6 @@ class ModelCheckpoint(Checkpoint):
626622
627623
Behaviour of this class has been changed since v0.3.0.
628624
629-
Argument ``save_as_state_dict`` is deprecated and should not be used. It is considered as True.
630-
631-
Argument ``save_interval`` is deprecated and should not be used. Please, use events filtering instead, e.g.
632-
:attr:`~ignite.engine.events.Events.ITERATION_STARTED(every=1000)`
633-
634625
There is no more internal counter that has been used to indicate the number of save actions. User could
635626
see its value `step_number` in the filename, e.g. `{filename_prefix}_{name}_{step_number}.pt`. Actually,
636627
`step_number` is replaced by current engine's epoch if `score_function` is specified and current iteration
@@ -659,7 +650,6 @@ class ModelCheckpoint(Checkpoint):
659650
Input of the function is `(engine, event_name)`. Output of function should be an integer.
660651
Default is None, global_step based on attached engine. If provided, uses function output as global_step.
661652
To setup global step from another engine, please use :meth:`~ignite.handlers.global_step_from_engine`.
662-
archived (bool, optional): Deprecated argument as models saved by `torch.save` are already compressed.
663653
include_self (bool): Whether to include the `state_dict` of this object in the checkpoint. If `True`, then
664654
there must not be another object in ``to_save`` with key ``checkpointer``.
665655
**kwargs: Accepted keyword arguments for `torch.save` or `xm.save` in `DiskSaver`.
@@ -684,37 +674,17 @@ def __init__(
684674
self,
685675
dirname: str,
686676
filename_prefix: str,
687-
save_interval: Optional[Callable] = None,
688677
score_function: Optional[Callable] = None,
689678
score_name: Optional[str] = None,
690679
n_saved: Union[int, None] = 1,
691680
atomic: bool = True,
692681
require_empty: bool = True,
693682
create_dir: bool = True,
694-
save_as_state_dict: bool = True,
695683
global_step_transform: Optional[Callable] = None,
696-
archived: bool = False,
697684
include_self: bool = False,
698685
**kwargs
699686
):
700687

701-
if not save_as_state_dict:
702-
raise ValueError(
703-
"Argument save_as_state_dict is deprecated and should be True."
704-
"This argument will be removed in 0.5.0."
705-
)
706-
if save_interval is not None:
707-
msg = (
708-
"Argument save_interval is deprecated and should be None. This argument will be removed in 0.5.0."
709-
"Please, use events filtering instead, e.g. Events.ITERATION_STARTED(every=1000)"
710-
)
711-
if save_interval == 1:
712-
# Do not break for old version who used `save_interval=1`
713-
warnings.warn(msg)
714-
else:
715-
# No choice
716-
raise ValueError(msg)
717-
718688
disk_saver = DiskSaver(dirname, atomic=atomic, create_dir=create_dir, require_empty=require_empty, **kwargs)
719689

720690
super(ModelCheckpoint, self).__init__(
@@ -725,7 +695,6 @@ def __init__(
725695
score_name=score_name,
726696
n_saved=n_saved,
727697
global_step_transform=global_step_transform,
728-
archived=archived,
729698
include_self=include_self,
730699
)
731700

tests/ignite/contrib/engines/test_common.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ def test_asserts_setup_common_training_handlers():
140140
train_sampler = MagicMock(spec=DistributedSampler)
141141
setup_common_training_handlers(trainer, train_sampler=train_sampler)
142142

143-
with pytest.warns(UserWarning, match=r"Argument device is unused and deprecated"):
144-
setup_common_training_handlers(trainer, device="cpu")
145-
146143

147144
def test_no_warning_with_train_sampler(recwarn):
148145
from torch.utils.data import RandomSampler

tests/ignite/engine/test_custom_events.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,7 @@
66

77
import ignite.distributed as idist
88
from ignite.engine import Engine, Events
9-
from ignite.engine.events import CallableEvents, CallableEventWithFilter, EventEnum, EventsList
10-
11-
12-
def test_deprecated_callable_events_class():
13-
engine = Engine(lambda engine, batch: 0)
14-
15-
with pytest.warns(DeprecationWarning, match=r"Class ignite\.engine\.events\.CallableEvents is deprecated"):
16-
17-
class CustomEvents(CallableEvents, Enum):
18-
TEST_EVENT = "test_event"
19-
20-
with pytest.raises(TypeError, match=r"Value at \d of event_names should be a str or EventEnum"):
21-
engine.register_events(*CustomEvents)
9+
from ignite.engine.events import CallableEventWithFilter, EventEnum, EventsList
2210

2311

2412
def test_custom_events():

tests/ignite/engine/test_engine.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,6 @@ def test_run_asserts():
352352
with pytest.raises(ValueError, match=r"Input data has zero size. Please provide non-empty data"):
353353
engine.run([])
354354

355-
with pytest.warns(UserWarning, match="Argument seed is deprecated"):
356-
engine.run([0, 1, 2, 3, 4], seed=1234)
357-
358355

359356
def test_state_get_event_attrib_value():
360357
state = State()

tests/ignite/handlers/test_checkpoint.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ def test_checkpoint_wrong_input():
6262
with pytest.raises(TypeError, match=r"global_step_transform should be a function."):
6363
Checkpoint(to_save, lambda x: x, score_function=lambda e: 123, score_name="acc", global_step_transform=123)
6464

65-
with pytest.warns(UserWarning, match=r"Argument archived is deprecated"):
66-
Checkpoint(to_save, lambda x: x, score_function=lambda e: 123, score_name="acc", archived=True)
67-
6865
with pytest.raises(ValueError, match=r"Cannot have key 'checkpointer' if `include_self` is True"):
6966
Checkpoint({"checkpointer": model}, lambda x: x, include_self=True)
7067

@@ -494,24 +491,15 @@ def test_model_checkpoint_args_validation(dirname):
494491
with pytest.raises(ValueError, match=r"with extension '.pt' are already present "):
495492
ModelCheckpoint(nonempty, _PREFIX)
496493

497-
with pytest.raises(ValueError, match=r"Argument save_interval is deprecated and should be None"):
498-
ModelCheckpoint(existing, _PREFIX, save_interval=42)
499-
500494
with pytest.raises(ValueError, match=r"Directory path '\S+' is not found"):
501495
ModelCheckpoint(os.path.join(dirname, "non_existing_dir"), _PREFIX, create_dir=False)
502496

503-
with pytest.raises(ValueError, match=r"Argument save_as_state_dict is deprecated and should be True"):
504-
ModelCheckpoint(existing, _PREFIX, create_dir=False, save_as_state_dict=False)
505-
506497
with pytest.raises(ValueError, match=r"If `score_name` is provided, then `score_function` "):
507498
ModelCheckpoint(existing, _PREFIX, create_dir=False, score_name="test")
508499

509500
with pytest.raises(TypeError, match=r"global_step_transform should be a function"):
510501
ModelCheckpoint(existing, _PREFIX, create_dir=False, global_step_transform=1234)
511502

512-
with pytest.warns(UserWarning, match=r"Argument archived is deprecated"):
513-
ModelCheckpoint(existing, _PREFIX, create_dir=False, archived=True)
514-
515503
h = ModelCheckpoint(dirname, _PREFIX, create_dir=False)
516504
assert h.last_checkpoint is None
517505
with pytest.raises(RuntimeError, match=r"No objects to checkpoint found."):

0 commit comments

Comments
 (0)