Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove warnings #111

Merged
merged 18 commits into from
Apr 28, 2024
Merged

Remove warnings #111

merged 18 commits into from
Apr 28, 2024

Conversation

aliberts
Copy link
Collaborator

@aliberts aliberts commented Apr 27, 2024

Remove warnings

Progress: Done ✅ (0 down from 117 warnings)

UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=ResNet18_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet18_Weights.DEFAULT` to get the most up-to-date weights.
  • Replace use_pretrained_backbone (bool) with pretrained_backbone_weights (str | None) in ACT and Diffusion configs in order to use the weights parameter instead of the deprecated pretrained parameter when initializing those backbones. Solves Handle torchvision deprecation warning #78.
/opt/homebrew/Caskroom/miniconda/base/envs/lerobot/lib/python3.10/site-packages/diffusers/utils/outputs.py:63: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  torch.utils._pytree._register_pytree_node(
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  • I've seen this one being triggered in different places. It's raised because some packages in our dependencies still use pkg_ressources. Therefore, we can only silent those until those libraries fix it themselves.
    • pygame in gym-pusht: I've pushed a fix to silent it Remove "pkg_resources deprecated" warning gym-pusht#7
    • imageio.mimsave: a fix has recently been pushed to imageio-ffmpeg but it hasn't made its way into a release yet so I guess we'll just have to wait. In the meantime, I've pushed a fix to silence it. This one doesn't appear in the CI for some reason but it does in my local tests.
UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
  • These warnings appear in multiple places where num_worker is hardcoded as e.g. 4, 8. After discussing this with @Cadene, since we don't want to change those values or set them dynamically in the code, I've added a -W ignore::UserWarning:torch.utils.data.dataloader:558 flag in the CI's pytest command.
UserWarning: WARN: A Box observation space minimum value is -/+infinity. This is probably too low/high.
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
UserWarning: WARN: For Box action spaces, we recommend using a symmetric and normalized space (range=[-1, 1] or [0, 1]). See https://stable-baselines3.readthedocs.io/en/master/guide/rl_tips.html for more information.
  • As discussed with @Cadene, we apply normalization in the policies rather than in the environments. As this is a deliberate design choice, we can safely disable those warnings.
    I've added a -W ignore::UserWarning:gymnasium.utils.env_checker:247 flag in the CI's pytest command.
UserWarning: 
  The version_base parameter is not specified.
  Please specify a compatability version level, or None.
  Will assume defaults for version 1.1
  • Set version_base="1.2" in Hydra initializations
/home/runner/work/lerobot/lerobot/.venv/lib/python3.10/site-packages/einops/einops.py:827: DeprecationWarning: invalid escape sequence '\s'
  • Upgraded min einops version from 0.7.0 -> 0.8.0

@aliberts aliberts self-assigned this Apr 27, 2024
@aliberts aliberts linked an issue Apr 27, 2024 that may be closed by this pull request
@aliberts aliberts added the refactor Code cleanup or restructuring without changing behavior label Apr 27, 2024
@aliberts aliberts force-pushed the user/aliberts/2024_04_27_remove_warnings branch from 1c89995 to 07264ce Compare April 28, 2024 17:05
@aliberts aliberts marked this pull request as ready for review April 28, 2024 17:40
Copy link
Collaborator

@Cadene Cadene left a comment

Choose a reason for hiding this comment

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

Thanks!!! LGTM. Left a few comments/suggestions. Feel free to ignore.

Comment on lines +1 to +12
import warnings

import imageio


def write_video(video_path, stacked_frames, fps):
# Filter out DeprecationWarnings raised from pkg_resources
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", "pkg_resources is deprecated as an API", category=DeprecationWarning
)
imageio.mimsave(video_path, stacked_frames, fps=fps)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we rename io_utils.py to io.py ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did this in a previous python project and it's okay until you need to import io from the standard library. It's confusing so I wouldn't recommend it.

Comment on lines +6 to +12
def write_video(video_path, stacked_frames, fps):
# Filter out DeprecationWarnings raised from pkg_resources
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", "pkg_resources is deprecated as an API", category=DeprecationWarning
)
imageio.mimsave(video_path, stacked_frames, fps=fps)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity, why cant we use imageio as an API without warning?

What are the alternatives to generate an mp4 from a numpy array?

Copy link
Collaborator Author

@aliberts aliberts Apr 28, 2024

Choose a reason for hiding this comment

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

I'm not sure to understand. To be clear, the problem here with imageio.mimsave is that it calls pkg_resources at some point down the line (in imageio-ffmpeg actually), which raises this warning. As mentioned before, a fix has been pushed on their main but it hasn't made its way to a release yet so we just have to handle it on our side until then.

@aliberts aliberts merged commit 791506d into main Apr 28, 2024
2 checks passed
@aliberts aliberts deleted the user/aliberts/2024_04_27_remove_warnings branch April 28, 2024 22:31
menhguin pushed a commit to menhguin/lerobot that referenced this pull request Feb 9, 2025
- Replace `use_pretrained_backbone` with `pretrained_backbone_weights`
- Bump diffusers' minimum version `0.26.3` -> `0.27.2`
- Add ignore flags in CI's pytest
- Change Box observation spaces in simulation environments
- Set `version_base="1.2"` in Hydra initializations
- Bump einops' minimum version `0.7.0` -> `0.8.0`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code cleanup or restructuring without changing behavior
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Handle torchvision deprecation warning
2 participants