Skip to content

Commit

Permalink
[BE] Add trailing spaces when necessary
Browse files Browse the repository at this point in the history
ghstack-source-id: 198b5b5668cce8336d44206c10dacb8a9b1a9785
Pull Request resolved: #2581
  • Loading branch information
vmoens committed Nov 18, 2024
1 parent 7829bd3 commit 600760f
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions torchrl/collectors/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def __init__(
warnings.warn(
f"frames_per_batch ({frames_per_batch}) is not exactly divisible by the number of batched environments ({self.n_env}), "
f" this results in more frames_per_batch per iteration that requested"
f" ({-(-frames_per_batch // self.n_env) * self.n_env})."
f" ({-(-frames_per_batch // self.n_env) * self.n_env}). "
"To silence this message, set the environment variable RL_WARNINGS to False."
)
self.requested_frames_per_batch = int(frames_per_batch)
Expand Down Expand Up @@ -1645,8 +1645,8 @@ def __init__(
remainder = total_frames % frames_per_batch
if remainder != 0 and RL_WARNINGS:
warnings.warn(
f"total_frames ({total_frames}) is not exactly divisible by frames_per_batch ({frames_per_batch})."
f"This means {frames_per_batch - remainder} additional frames will be collected."
f"total_frames ({total_frames}) is not exactly divisible by frames_per_batch ({frames_per_batch}). "
f"This means {frames_per_batch - remainder} additional frames will be collected. "
"To silence this message, set the environment variable RL_WARNINGS to False."
)
self.total_frames = (
Expand Down
2 changes: 1 addition & 1 deletion torchrl/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3202,7 +3202,7 @@ def __init__(
)
if len(args):
raise ValueError(
"`_EnvWrapper.__init__` received a non-empty args list of arguments."
"`_EnvWrapper.__init__` received a non-empty args list of arguments. "
"Make sure only keywords arguments are used when calling `super().__init__`."
)

Expand Down
2 changes: 1 addition & 1 deletion torchrl/envs/libs/gym.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ def _build_env(
)
if isinstance(env, PixelObservationWrapper):
raise TypeError(
"PixelObservationWrapper cannot be used to wrap an environment"
"PixelObservationWrapper cannot be used to wrap an environment "
"that is already a PixelObservationWrapper instance."
)
except ModuleNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion torchrl/envs/libs/meltingpot.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def _init_env(self):

def _set_seed(self, seed: int | None):
raise NotImplementedError(
"It is currently unclear how to set a seed in Meltingpot"
"It is currently unclear how to set a seed in Meltingpot. "
"see https://github.com/google-deepmind/meltingpot/issues/129 to track the issue."
)

Expand Down
2 changes: 1 addition & 1 deletion torchrl/modules/tensordict_module/actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ def __init__(
):
if isinstance(action_space, TensorSpec):
raise RuntimeError(
"Using specs in action_space is deprecated."
"Using specs in action_space is deprecated. "
"Please use the 'spec' argument if you want to provide an action spec"
)
action_space, spec = _process_action_space_spec(action_space, spec)
Expand Down
4 changes: 2 additions & 2 deletions torchrl/objectives/dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ def __init__(
)
if action_space is None:
warnings.warn(
"action_space was not specified. DQNLoss will default to 'one-hot'."
"This behavior will be deprecated soon and a space will have to be passed."
"action_space was not specified. DQNLoss will default to 'one-hot'. "
"This behavior will be deprecated soon and a space will have to be passed. "
"Check the DQNLoss documentation to see how to pass the action space. "
)
action_space = "one-hot"
Expand Down
4 changes: 2 additions & 2 deletions torchrl/objectives/iql.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,8 @@ def __init__(
)
if action_space is None:
warnings.warn(
"action_space was not specified. DiscreteIQLLoss will default to 'one-hot'."
"This behavior will be deprecated soon and a space will have to be passed."
"action_space was not specified. DiscreteIQLLoss will default to 'one-hot'. "
"This behavior will be deprecated soon and a space will have to be passed. "
"Check the DiscreteIQLLoss documentation to see how to pass the action space. "
)
action_space = "one-hot"
Expand Down
2 changes: 1 addition & 1 deletion torchrl/objectives/sac.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ def __init__(

if action_space is None:
warnings.warn(
"action_space was not specified. DiscreteSACLoss will default to 'one-hot'."
"action_space was not specified. DiscreteSACLoss will default to 'one-hot'. "
"This behavior will be deprecated soon and a space will have to be passed. "
"Check the DiscreteSACLoss documentation to see how to pass the action space. "
)
Expand Down
4 changes: 2 additions & 2 deletions torchrl/record/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _apply_transform(self, observation: torch.Tensor) -> torch.Tensor:
if self.center_crop:
if not _has_tv:
raise ImportError(
"Could not import torchvision, `center_crop` not available."
"Could not import torchvision, `center_crop` not available. "
"Make sure torchvision is installed in your environment."
)
from torchvision.transforms.functional import (
Expand All @@ -212,7 +212,7 @@ def _apply_transform(self, observation: torch.Tensor) -> torch.Tensor:
if self.make_grid and observation_trsf.ndimension() >= 4:
if not _has_tv:
raise ImportError(
"Could not import torchvision, `make_grid` not available."
"Could not import torchvision, `make_grid` not available. "
"Make sure torchvision is installed in your environment."
)
from torchvision.utils import make_grid
Expand Down
2 changes: 1 addition & 1 deletion torchrl/trainers/helpers/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def make_env_transforms(
if from_pixels:
if not cfg.catframes:
raise RuntimeError(
"this env builder currently only accepts positive catframes values"
"this env builder currently only accepts positive catframes values "
"when pixels are being used."
)
env.append_transform(ToTensorImage())
Expand Down

1 comment on commit 600760f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'CPU Benchmark Results'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 600760f Previous: 7bc84d1 Ratio
benchmarks/test_replaybuffer_benchmark.py::test_rb_sample[TensorDictReplayBuffer-LazyMemmapStorage-SamplerWithoutReplacement-10000] 803.4767921723902 iter/sec (stddev: 0.026603959292624074) 1992.2181202441213 iter/sec (stddev: 0.00007143089938128159) 2.48

This comment was automatically generated by workflow using github-action-benchmark.

CC: @vmoens

Please sign in to comment.