Deleted long deprecated functionality, removed unused warning module

There's better ways to deal with deprecations that we shall use in the future
This commit is contained in:
Michael Panchenko 2024-04-26 14:29:16 +02:00
parent 49c750fb09
commit 829fd9c7a5
4 changed files with 2 additions and 40 deletions

View File

@ -6,7 +6,6 @@ import gymnasium as gym
import numpy as np
from tianshou.env.utils import gym_new_venv_step_type
from tianshou.utils import deprecation
class EnvWorker(ABC):
@ -27,6 +26,7 @@ class EnvWorker(ABC):
def set_env_attr(self, key: str, value: Any) -> None:
pass
@abstractmethod
def send(self, action: np.ndarray | None) -> None:
"""Send action signal to low-level worker.
@ -34,17 +34,6 @@ class EnvWorker(ABC):
it indicates "step" signal. The paired return value from "recv"
function is determined by such kind of different signal.
"""
if hasattr(self, "send_action"):
deprecation(
"send_action will soon be deprecated. "
"Please use send and recv for your own EnvWorker.",
)
if action is None:
self.is_reset = True
self.result = self.reset()
else:
self.is_reset = False
self.send_action(action)
def recv(self) -> gym_new_venv_step_type | tuple[np.ndarray, dict]:
"""Receive result from low-level worker.
@ -54,13 +43,6 @@ class EnvWorker(ABC):
info) or (obs, rew, terminated, truncated, info), based on whether
the environment is using the old step API or the new one.
"""
if hasattr(self, "get_result"):
deprecation(
"get_result will soon be deprecated. "
"Please use send and recv for your own EnvWorker.",
)
if not self.is_reset:
self.result = self.get_result()
return self.result
@abstractmethod

View File

@ -26,7 +26,6 @@ from tianshou.utils import (
DummyTqdm,
LazyLogger,
MovAvg,
deprecation,
tqdm_config,
)
from tianshou.utils.logging import set_numerical_fields_to_precision
@ -76,7 +75,7 @@ class BaseTrainer(ABC):
signature ``f(num_epoch: int, step_idx: int) -> None``.
:param save_best_fn: a hook called when the undiscounted average mean
reward in evaluation phase gets better, with the signature
``f(policy: BasePolicy) -> None``. It was ``save_fn`` previously.
``f(policy: BasePolicy) -> None``.
:param save_checkpoint_fn: a function to save training process and
return the saved checkpoint path, with the signature ``f(epoch: int,
env_step: int, gradient_step: int) -> str``; you can save whatever you want.
@ -173,16 +172,7 @@ class BaseTrainer(ABC):
verbose: bool = True,
show_progress: bool = True,
test_in_train: bool = True,
save_fn: Callable[[BasePolicy], None] | None = None,
):
if save_fn:
deprecation(
"save_fn in trainer is marked as deprecated and will be "
"removed in the future. Please use save_best_fn instead.",
)
assert save_best_fn is None
save_best_fn = save_fn
self.policy = policy
if buffer is not None:

View File

@ -6,7 +6,6 @@ from tianshou.utils.logger.wandb import WandbLogger
from tianshou.utils.lr_scheduler import MultipleLRSchedulers
from tianshou.utils.progress_bar import DummyTqdm, tqdm_config
from tianshou.utils.statistics import MovAvg, RunningMeanStd
from tianshou.utils.warning import deprecation
__all__ = [
"MovAvg",
@ -17,6 +16,5 @@ __all__ = [
"TensorboardLogger",
"LazyLogger",
"WandbLogger",
"deprecation",
"MultipleLRSchedulers",
]

View File

@ -1,8 +0,0 @@
import warnings
warnings.simplefilter("once", DeprecationWarning)
def deprecation(msg: str) -> None:
"""Deprecation warning wrapper."""
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)