From 3529aad6a4796f752f55248f0c7cadf19f3255d2 Mon Sep 17 00:00:00 2001 From: mtrepte Date: Wed, 2 Dec 2026 23:02:56 +0000 Subject: [PATCH 1/6] Report the missing video extra when --video is used without moviepy Signed-off-by: mtrepte --- docs/source/how-to/record_video.rst | 10 ++++++++-- docs/source/how-to/train_g1_motion_tracking.rst | 2 +- .../changelog.d/nvbug-video-extra-message.fixed.rst | 1 + source/isaaclab/isaaclab/envs/utils/video_recorder.py | 7 +++++-- .../isaaclab/isaaclab/envs/utils/video_recorder_cfg.py | 6 ++++++ .../changelog.d/nvbug-video-extra-check.fixed.rst | 1 + source/isaaclab_rl/isaaclab_rl/entrypoints/common.py | 7 ++++++- 7 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 source/isaaclab/changelog.d/nvbug-video-extra-message.fixed.rst create mode 100644 source/isaaclab_rl/changelog.d/nvbug-video-extra-check.fixed.rst diff --git a/docs/source/how-to/record_video.rst b/docs/source/how-to/record_video.rst index 3d93433e9052..7190938ae1c3 100644 --- a/docs/source/how-to/record_video.rst +++ b/docs/source/how-to/record_video.rst @@ -49,7 +49,13 @@ adds a single recorder; to record several sources at once, list one ``VideoRecor .. code-block:: bash - uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --video + uv run --extra video isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --video + +.. note:: + + Recording needs ``moviepy``, which is in the optional ``video`` extra. Without it, ``--video`` stops at startup + with an error that names the extra. With uv, add ``--extra video`` to the command as shown; otherwise install it + with ``pip install "isaaclab[video]"``. ``--video`` records from the source it names, and ``--viz`` still decides which visualizers open a window. See :ref:`the --video sources ` for every command-line form, and `Sources`_ and `Clip control`_ @@ -195,7 +201,7 @@ Record a short clip at regular intervals while training, without opening a windo .. code-block:: bash - uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --video \ + uv run --extra video isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --video \ --video_length 200 --video_interval 2000 With no ``--viz``, ``--video`` records from a headless Newton visualizer. This writes a diff --git a/docs/source/how-to/train_g1_motion_tracking.rst b/docs/source/how-to/train_g1_motion_tracking.rst index c62d7e0d1335..c64c73227f8a 100644 --- a/docs/source/how-to/train_g1_motion_tracking.rst +++ b/docs/source/how-to/train_g1_motion_tracking.rst @@ -112,7 +112,7 @@ Record 500 control steps (10 seconds) without opening a viewer: .. code-block:: bash - uv run isaaclab play --rl_library rsl_rl --task Isaac-Motion-Tracking-G1 \ + uv run --extra video isaaclab play --rl_library rsl_rl --task Isaac-Motion-Tracking-G1 \ --num_envs 1 --checkpoint pretrained --video --video_length 500 The recording is saved under the checkpoint's run directory in ``videos/play/`` and may contain diff --git a/source/isaaclab/changelog.d/nvbug-video-extra-message.fixed.rst b/source/isaaclab/changelog.d/nvbug-video-extra-message.fixed.rst new file mode 100644 index 000000000000..481f1a032ef7 --- /dev/null +++ b/source/isaaclab/changelog.d/nvbug-video-extra-message.fixed.rst @@ -0,0 +1 @@ +* Fixed ``--video`` failing with a raw ``ModuleNotFoundError: moviepy`` when the ``video`` extra is not installed. :class:`~isaaclab.envs.utils.video_recorder.VideoRecorder` now raises an :class:`ImportError` that names the extra. diff --git a/source/isaaclab/isaaclab/envs/utils/video_recorder.py b/source/isaaclab/isaaclab/envs/utils/video_recorder.py index b619ad682529..ba992b01d534 100644 --- a/source/isaaclab/isaaclab/envs/utils/video_recorder.py +++ b/source/isaaclab/isaaclab/envs/utils/video_recorder.py @@ -20,7 +20,7 @@ import numpy as np from ...visualizers.visualizer_cfg import ImageViewCfg -from .video_recorder_cfg import CAPTURE_VISUALIZER_TYPES, VideoRecorderCfg, parse_video_source +from .video_recorder_cfg import CAPTURE_VISUALIZER_TYPES, VIDEO_EXTRA_MESSAGE, VideoRecorderCfg, parse_video_source logger = logging.getLogger(__name__) @@ -38,7 +38,10 @@ class VideoRecorder: """ def __init__(self, cfg: VideoRecorderCfg, env: object): - from moviepy.video.io.ImageSequenceClip import ImageSequenceClip + try: + from moviepy.video.io.ImageSequenceClip import ImageSequenceClip + except ImportError as exc: + raise ImportError(VIDEO_EXTRA_MESSAGE) from exc self._clip_class = ImageSequenceClip source = cfg.source diff --git a/source/isaaclab/isaaclab/envs/utils/video_recorder_cfg.py b/source/isaaclab/isaaclab/envs/utils/video_recorder_cfg.py index 75a67aa3d55e..2c64ee7f6a1a 100644 --- a/source/isaaclab/isaaclab/envs/utils/video_recorder_cfg.py +++ b/source/isaaclab/isaaclab/envs/utils/video_recorder_cfg.py @@ -13,6 +13,12 @@ CAPTURE_VISUALIZER_TYPES = ("kit", "newton") """Visualizer types a video can be recorded from; the streaming ``rerun`` and ``viser`` cannot.""" +VIDEO_EXTRA_MESSAGE = ( + "Video recording needs the optional 'moviepy' package, which ships in the 'video' extra. " + "Run with `uv run --extra video isaaclab ...` (or `pip install 'isaaclab[video]'`), or drop --video." +) +"""Error raised when a video is requested but ``moviepy`` is not installed.""" + SENSOR_CHANNELS = ("rgb", "depth", "segmentation", "normals") """Channels a ``sensor::`` source can record.""" diff --git a/source/isaaclab_rl/changelog.d/nvbug-video-extra-check.fixed.rst b/source/isaaclab_rl/changelog.d/nvbug-video-extra-check.fixed.rst new file mode 100644 index 000000000000..259980c491ad --- /dev/null +++ b/source/isaaclab_rl/changelog.d/nvbug-video-extra-check.fixed.rst @@ -0,0 +1 @@ +* Fixed ``--video`` in the ``train`` and ``play`` entrypoints failing deep into startup when ``moviepy`` is missing. The check now runs before the simulation launches and tells the user to install the ``video`` extra. diff --git a/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py b/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py index 95168d664610..b9413f707e78 100644 --- a/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py +++ b/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py @@ -9,6 +9,7 @@ import argparse import contextlib +import importlib.util import json import logging import os @@ -30,7 +31,7 @@ from isaaclab.app import LoadingScreen from isaaclab.envs import DirectMARLEnvCfg, DirectRLEnvCfg, ManagerBasedRLEnvCfg -from isaaclab.envs.utils.video_recorder_cfg import VideoRecorderCfg, parse_video_source +from isaaclab.envs.utils.video_recorder_cfg import VIDEO_EXTRA_MESSAGE, VideoRecorderCfg, parse_video_source from isaaclab.renderers.renderer_cfg import RendererCfg from isaaclab.utils.assets import retrieve_file_path from isaaclab.utils.dict import print_dict @@ -929,10 +930,14 @@ def pre_launch_video_config(env_cfg: Any, args_cli: argparse.Namespace) -> None: args_cli: Parsed command-line arguments. Raises: + ImportError: If recording is requested but ``moviepy`` (the ``video`` extra) is not installed. ValueError: If recording is requested with the warp frontend. """ if not getattr(args_cli, "video", None): return + # Fail before the simulation launches rather than deep inside environment creation. + if importlib.util.find_spec("moviepy") is None: + raise ImportError(VIDEO_EXTRA_MESSAGE) frontend = getattr(args_cli, "frontend", "torch") or "torch" if frontend != "torch": raise ValueError( From b2462697555dd25faefd3fcca66c12218ac80c40 Mon Sep 17 00:00:00 2001 From: mtrepte Date: Wed, 2 Dec 2026 23:02:57 +0000 Subject: [PATCH 2/6] Show deprecation warnings after a successful startup on an interactive console Signed-off-by: mtrepte --- ...bug-startup-deprecation-warnings.fixed.rst | 1 + .../isaaclab/isaaclab/app/loading_screen.py | 31 ++++++++++++++++++- .../isaaclab/test/app/test_loading_screen.py | 25 +++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 source/isaaclab/changelog.d/nvbug-startup-deprecation-warnings.fixed.rst diff --git a/source/isaaclab/changelog.d/nvbug-startup-deprecation-warnings.fixed.rst b/source/isaaclab/changelog.d/nvbug-startup-deprecation-warnings.fixed.rst new file mode 100644 index 000000000000..30d109914e2c --- /dev/null +++ b/source/isaaclab/changelog.d/nvbug-startup-deprecation-warnings.fixed.rst @@ -0,0 +1 @@ +* Fixed the loading screen hiding :class:`FutureWarning` and :class:`DeprecationWarning` messages raised during a successful startup on an interactive console. They now print when the screen closes, without needing ``--info``. diff --git a/source/isaaclab/isaaclab/app/loading_screen.py b/source/isaaclab/isaaclab/app/loading_screen.py index 2cab5d64908a..63bc635aa2d7 100644 --- a/source/isaaclab/isaaclab/app/loading_screen.py +++ b/source/isaaclab/isaaclab/app/loading_screen.py @@ -17,6 +17,7 @@ import tempfile import threading import time +import warnings from collections.abc import Callable from functools import wraps from typing import IO, Any @@ -294,7 +295,8 @@ class LoadingScreen: capture Python-level output. Alongside the bar the screen shows the step currently running, as reported by :func:`report_activity`, and a clock that keeps ticking through long silent steps. The spool is - replayed when startup fails and dropped when it succeeds. Closing the screen + replayed when startup fails and dropped when it succeeds, except for deprecation + warnings, which are printed once the screen closes. Closing the screen hands the console back, so whatever runs next (typically an RL library's training log) prints undisturbed. @@ -355,6 +357,9 @@ def __init__(self, num_stages: int, *, enabled: bool | None = None, logo: bool = self._saved_fds: tuple[int, int] | None = None self._saved_streams: tuple[IO[str], IO[str]] | None = None self._spooled_streams: tuple[IO[str], IO[str]] | None = None + self._deprecations: list[str] = [] + self._showwarning: Callable[..., None] | None = None + self._original_showwarning: Callable[..., None] | None = None self._original_input: Callable[..., str] | None = None self._input_wrapper: Callable[..., str] | None = None self._started = 0.0 @@ -514,6 +519,9 @@ def _shut_down(self, *, replay: bool) -> None: if replay: self._write(hidden) else: + # the spool is dropped on success, but a deprecation must not go unseen + for text in self._deprecations: + self._write(f"[WARNING]: {text}\n") elapsed = time.monotonic() - self._started lines = hidden.count("\n") self._write( @@ -607,6 +615,7 @@ def _redirect(self) -> None: self._saved_fds = (os.dup(1), os.dup(2)) os.dup2(self._spool.fileno(), 1) os.dup2(self._spool.fileno(), 2) + self._capture_deprecations() def _redirect_streams(self) -> None: """Spool Python output without replacing platform-specific console descriptors.""" @@ -615,9 +624,29 @@ def _redirect_streams(self) -> None: # a distinct stderr object lets _restore tell handlers bound to stderr from those bound to stdout self._spooled_streams = (self._spool, _StreamAlias(self._spool)) sys.stdout, sys.stderr = self._spooled_streams + self._capture_deprecations() + + def _capture_deprecations(self) -> None: + """Remember deprecation warnings raised while output is spooled, so a successful start can still show them.""" + original = warnings.showwarning + + def showwarning(message, category, filename, lineno, file=None, line=None): + if file is None and issubclass(category, (FutureWarning, DeprecationWarning)): + text = str(message) + if text not in self._deprecations: + self._deprecations.append(text) + original(message, category, filename, lineno, file, line) + + self._original_showwarning = original + self._showwarning = showwarning + warnings.showwarning = showwarning def _restore(self) -> str: """Restore redirected output and return the spooled text.""" + if self._showwarning is not None: + if warnings.showwarning is self._showwarning: + warnings.showwarning = self._original_showwarning + self._showwarning = self._original_showwarning = None if self._saved_fds is not None: sys.stdout.flush() sys.stderr.flush() diff --git a/source/isaaclab/test/app/test_loading_screen.py b/source/isaaclab/test/app/test_loading_screen.py index 723f203f2c33..a95900b7d2be 100644 --- a/source/isaaclab/test/app/test_loading_screen.py +++ b/source/isaaclab/test/app/test_loading_screen.py @@ -14,6 +14,7 @@ import sys import textwrap import time +import warnings from io import BytesIO, StringIO, TextIOWrapper from unittest.mock import Mock @@ -305,3 +306,27 @@ def test_redirect_uses_stream_swapping_on_platforms_without_descriptor_redirecti assert loading_screen.sys.stderr is original_stderr assert original_stdout.getvalue() == "after startup\n" assert original_stderr.getvalue() == "after startup\n" + + +def test_deprecation_warnings_survive_a_successful_start(monkeypatch: pytest.MonkeyPatch) -> None: + """A deprecation raised while startup output is spooled is printed when the screen closes.""" + console = _OpenStringIO() + monkeypatch.setattr(loading_screen.sys, "stdout", console) + monkeypatch.setattr(loading_screen.sys, "stderr", _OpenStringIO()) + screen = loading_screen.LoadingScreen(1, enabled=True, logo=False) + monkeypatch.setattr(screen, "_redirect", screen._redirect_streams) + original_showwarning = warnings.showwarning + + with warnings.catch_warnings(): + warnings.simplefilter("always") + with screen: + warnings.warn("old thing is deprecated", FutureWarning) + warnings.warn("old thing is deprecated", FutureWarning) # repeats are printed once + with pytest.warns(UserWarning): + warnings.warn("not a deprecation", UserWarning) + screen.close() + output = console.getvalue() + + assert output.count("[WARNING]: old thing is deprecated") == 1 + assert "not a deprecation" not in output + assert warnings.showwarning is original_showwarning From eb02eac561f8e9309a8130e08065d6a99729130a Mon Sep 17 00:00:00 2001 From: mtrepte Date: Wed, 2 Dec 2026 23:02:57 +0000 Subject: [PATCH 3/6] Correct the Rerun deprecation and removal versions Signed-off-by: mtrepte --- docs/source/concepts/visualization.rst | 4 ++-- docs/source/isaaclab/migrating.rst | 4 ++-- docs/source/isaaclab/quickstart.rst | 2 +- .../changelog.d/nvbug-rerun-deprecation-version.fixed.rst | 1 + .../isaaclab_visualizers/rerun/__init__.py | 4 ++-- .../isaaclab_visualizers/rerun/rerun_visualizer.py | 6 +++--- .../isaaclab_visualizers/rerun/rerun_visualizer_cfg.py | 4 ++-- 7 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 source/isaaclab_visualizers/changelog.d/nvbug-rerun-deprecation-version.fixed.rst diff --git a/docs/source/concepts/visualization.rst b/docs/source/concepts/visualization.rst index 20176ffa7117..9b7f90c50a60 100644 --- a/docs/source/concepts/visualization.rst +++ b/docs/source/concepts/visualization.rst @@ -402,9 +402,9 @@ Visualizer Overview .. tab-item:: Rerun - .. deprecated:: 3.2.0 + .. deprecated:: 3.1.0 - The Rerun visualizer is deprecated and will be removed in Isaac Lab 3.3. Use the Viser + The Rerun visualizer is deprecated and will be removed in Isaac Lab 3.2. Use the Viser visualizer (``--viz viser``) instead. Creating the visualizer at launch emits a :class:`FutureWarning`. Like Viser, `Rerun `_ streams simulation state to a local web server, for diff --git a/docs/source/isaaclab/migrating.rst b/docs/source/isaaclab/migrating.rst index 5baf0fb55a05..b4898dc6818e 100644 --- a/docs/source/isaaclab/migrating.rst +++ b/docs/source/isaaclab/migrating.rst @@ -2718,8 +2718,8 @@ plus the corresponding ``KitBackendCfg``, ``NewtonGLBackendCfg``, and translated once, preserving explicit per-view overrides. Both forms use the same runtime implementation. Deprecated declarations emit ``DeprecationWarning``; update the configuration at its declaration site. -The Rerun visualizer (``--viz rerun``, ``RerunBackendCfg``) is deprecated in Isaac Lab 3.2 and will be removed in -Isaac Lab 3.3. Creating it emits a ``FutureWarning``. Switch to the Viser visualizer, which is also web-based and +The Rerun visualizer (``--viz rerun``, ``RerunBackendCfg``) is deprecated in Isaac Lab 3.1 and will be removed in +Isaac Lab 3.2. Creating it emits a ``FutureWarning``. Switch to the Viser visualizer, which is also web-based and supports recording and replay: use ``--viz viser`` or ``VisualizerCfg(backend=ViserBackendCfg())``. Old Kit declarations retain their 1280-by-720 default. New shared declarations use diff --git a/docs/source/isaaclab/quickstart.rst b/docs/source/isaaclab/quickstart.rst index 28bf70e7d8bd..b458655079da 100644 --- a/docs/source/isaaclab/quickstart.rst +++ b/docs/source/isaaclab/quickstart.rst @@ -208,7 +208,7 @@ without spaces, such as ``--viz newton,viser``. - Open the web-based Viser visualizer, useful for remote connections. - ``viser`` * - ``--viz rerun`` - - Stream the task to the Rerun visualizer. Deprecated in Isaac Lab 3.2 and removed in 3.3; use ``--viz viser``. + - Stream the task to the Rerun visualizer. Deprecated in Isaac Lab 3.1 and removed in 3.2; use ``--viz viser``. - ``rerun`` * - ``--viz kit`` - Open the Kit visualizer when it is available in your environment. diff --git a/source/isaaclab_visualizers/changelog.d/nvbug-rerun-deprecation-version.fixed.rst b/source/isaaclab_visualizers/changelog.d/nvbug-rerun-deprecation-version.fixed.rst new file mode 100644 index 000000000000..33151edc544c --- /dev/null +++ b/source/isaaclab_visualizers/changelog.d/nvbug-rerun-deprecation-version.fixed.rst @@ -0,0 +1 @@ +* Fixed the Rerun deprecation versions. The Rerun visualizer is deprecated in Isaac Lab 3.1 and will be removed in Isaac Lab 3.2, matching the Kit visualizer. The warning, docstrings and docs previously said 3.2 and 3.3. diff --git a/source/isaaclab_visualizers/isaaclab_visualizers/rerun/__init__.py b/source/isaaclab_visualizers/isaaclab_visualizers/rerun/__init__.py index b0f19f617fab..7495227214b9 100644 --- a/source/isaaclab_visualizers/isaaclab_visualizers/rerun/__init__.py +++ b/source/isaaclab_visualizers/isaaclab_visualizers/rerun/__init__.py @@ -5,8 +5,8 @@ """Rerun visualizer backend. -.. deprecated:: 3.2.0 - The Rerun visualizer will be removed in Isaac Lab 3.3. Use the Viser visualizer +.. deprecated:: 3.1.0 + The Rerun visualizer will be removed in Isaac Lab 3.2. Use the Viser visualizer (:mod:`isaaclab_visualizers.viser`) instead. This package keeps imports lazy so configuration-only imports avoid pulling the diff --git a/source/isaaclab_visualizers/isaaclab_visualizers/rerun/rerun_visualizer.py b/source/isaaclab_visualizers/isaaclab_visualizers/rerun/rerun_visualizer.py index d46da6df1eb5..b2ce2f9329ad 100644 --- a/source/isaaclab_visualizers/isaaclab_visualizers/rerun/rerun_visualizer.py +++ b/source/isaaclab_visualizers/isaaclab_visualizers/rerun/rerun_visualizer.py @@ -207,8 +207,8 @@ def _first_instance_value(values: wp.array | np.ndarray | None) -> np.ndarray | class RerunVisualizer(BaseVisualizer): """Rerun visualizer for Isaac Lab. - .. deprecated:: 3.2.0 - The Rerun visualizer will be removed in Isaac Lab 3.3. Use the Viser visualizer (``--viz viser``) + .. deprecated:: 3.1.0 + The Rerun visualizer will be removed in Isaac Lab 3.2. Use the Viser visualizer (``--viz viser``) instead. """ @@ -219,7 +219,7 @@ def __init__(self, cfg: VisualizerCfg): cfg: Rerun visualizer configuration. """ warnings.warn( - "The Rerun visualizer is deprecated in Isaac Lab 3.2 and will be removed in Isaac Lab 3.3. " + "The Rerun visualizer is deprecated in Isaac Lab 3.1 and will be removed in Isaac Lab 3.2. " "Use the Viser visualizer instead (--viz viser, or VisualizerCfg(backend=ViserBackendCfg())).", FutureWarning, stacklevel=2, diff --git a/source/isaaclab_visualizers/isaaclab_visualizers/rerun/rerun_visualizer_cfg.py b/source/isaaclab_visualizers/isaaclab_visualizers/rerun/rerun_visualizer_cfg.py index 77fd6eacc9e6..4f946c573d8e 100644 --- a/source/isaaclab_visualizers/isaaclab_visualizers/rerun/rerun_visualizer_cfg.py +++ b/source/isaaclab_visualizers/isaaclab_visualizers/rerun/rerun_visualizer_cfg.py @@ -20,8 +20,8 @@ class RerunBackendCfg(VisualizerBackendCfg): """Configuration for Rerun visualizer (web-based visualization). - .. deprecated:: 3.2.0 - The Rerun visualizer will be removed in Isaac Lab 3.3. Use + .. deprecated:: 3.1.0 + The Rerun visualizer will be removed in Isaac Lab 3.2. Use :class:`~isaaclab_visualizers.viser.ViserBackendCfg` instead. """ From 97ab8df24b81d14cca881c58d23d01235c3e49f5 Mon Sep 17 00:00:00 2001 From: mtrepte Date: Wed, 2 Dec 2026 23:10:28 +0000 Subject: [PATCH 4/6] Note the Rerun corner distortion as a known limitation Signed-off-by: mtrepte --- docs/source/concepts/visualization.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/concepts/visualization.rst b/docs/source/concepts/visualization.rst index 9b7f90c50a60..256ae3c5e1dc 100644 --- a/docs/source/concepts/visualization.rst +++ b/docs/source/concepts/visualization.rst @@ -407,6 +407,11 @@ Visualizer Overview The Rerun visualizer is deprecated and will be removed in Isaac Lab 3.2. Use the Viser visualizer (``--viz viser``) instead. Creating the visualizer at launch emits a :class:`FutureWarning`. + .. note:: + + The Rerun viewer can show distortion in the corners of the view on some platforms, such as Windows. + Because Rerun is deprecated, this is a known limitation that will not be fixed. + Like Viser, `Rerun `_ streams simulation state to a local web server, for remote monitoring, timeline playback, and recording to ``.rrd`` files. From a48660cdbe7d2e401e334b5a9d365551ead0416e Mon Sep 17 00:00:00 2001 From: mtrepte Date: Wed, 2 Dec 2026 23:42:20 +0000 Subject: [PATCH 5/6] Address review feedback on the video extra check and startup warnings Signed-off-by: mtrepte --- docs/source/concepts/visualization.rst | 2 +- docs/source/how-to/record_video.rst | 2 +- docs/source/isaaclab/migrating.rst | 9 +- ...bug-startup-deprecation-warnings.fixed.rst | 2 +- .../nvbug-video-extra-message.fixed.rst | 2 +- .../isaaclab/isaaclab/app/loading_screen.py | 27 ++++-- .../isaaclab/envs/utils/video_recorder.py | 12 +-- .../isaaclab/envs/utils/video_recorder_cfg.py | 23 ++++- .../isaaclab/test/app/test_loading_screen.py | 83 ++++++++++++++++--- .../isaaclab_rl/entrypoints/common.py | 10 +-- .../test/test_apply_video_recording.py | 34 +++++++- 11 files changed, 165 insertions(+), 41 deletions(-) diff --git a/docs/source/concepts/visualization.rst b/docs/source/concepts/visualization.rst index 256ae3c5e1dc..e981ecb4c3fd 100644 --- a/docs/source/concepts/visualization.rst +++ b/docs/source/concepts/visualization.rst @@ -771,7 +771,7 @@ capture source, e.g. ``--video viz:kit``: .. code-block:: bash - uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --video + uv run --extra video isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --video See :doc:`/source/how-to/record_video` for clip length, interval, and multi-source options. diff --git a/docs/source/how-to/record_video.rst b/docs/source/how-to/record_video.rst index 7190938ae1c3..607e9685b411 100644 --- a/docs/source/how-to/record_video.rst +++ b/docs/source/how-to/record_video.rst @@ -234,7 +234,7 @@ recorded. Pair them with a capture-capable visualizer that runs headless next to .. code-block:: bash - uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --viz viser --video viz:newton + uv run --extra video isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --viz viser --video viz:newton Alternatively, record directly from a scene camera with ``source="sensor:"``, which needs no visualizer. diff --git a/docs/source/isaaclab/migrating.rst b/docs/source/isaaclab/migrating.rst index b4898dc6818e..13f6752205cd 100644 --- a/docs/source/isaaclab/migrating.rst +++ b/docs/source/isaaclab/migrating.rst @@ -2718,9 +2718,10 @@ plus the corresponding ``KitBackendCfg``, ``NewtonGLBackendCfg``, and translated once, preserving explicit per-view overrides. Both forms use the same runtime implementation. Deprecated declarations emit ``DeprecationWarning``; update the configuration at its declaration site. -The Rerun visualizer (``--viz rerun``, ``RerunBackendCfg``) is deprecated in Isaac Lab 3.1 and will be removed in -Isaac Lab 3.2. Creating it emits a ``FutureWarning``. Switch to the Viser visualizer, which is also web-based and -supports recording and replay: use ``--viz viser`` or ``VisualizerCfg(backend=ViserBackendCfg())``. +Separately from those adapters, the Rerun visualizer (``--viz rerun``, ``RerunBackendCfg``) is deprecated in +Isaac Lab 3.1 and will be removed in Isaac Lab 3.2. Creating it emits a ``FutureWarning``. Switch to the Viser +visualizer, which is also web-based and supports recording and replay: use ``--viz viser`` or +``VisualizerCfg(backend=ViserBackendCfg())``. Old Kit declarations retain their 1280-by-720 default. New shared declarations use ``WindowCfg(size=(1920, 1080))`` by default, independent of backend; specify ``window.size`` to @@ -2779,7 +2780,7 @@ if it lists one: .. code-block:: bash - uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole-Direct --video viz:kit + uv run --extra video isaaclab train --rl_library rsl_rl --task Isaac-Cartpole-Direct --video viz:kit See :ref:`the --video sources `. diff --git a/source/isaaclab/changelog.d/nvbug-startup-deprecation-warnings.fixed.rst b/source/isaaclab/changelog.d/nvbug-startup-deprecation-warnings.fixed.rst index 30d109914e2c..0cab2d5deea9 100644 --- a/source/isaaclab/changelog.d/nvbug-startup-deprecation-warnings.fixed.rst +++ b/source/isaaclab/changelog.d/nvbug-startup-deprecation-warnings.fixed.rst @@ -1 +1 @@ -* Fixed the loading screen hiding :class:`FutureWarning` and :class:`DeprecationWarning` messages raised during a successful startup on an interactive console. They now print when the screen closes, without needing ``--info``. +* Fixed the loading screen hiding :class:`FutureWarning` and :class:`DeprecationWarning` messages raised during a successful startup on an interactive console. They now print through the normal warning hook when the screen closes, without needing ``--info``. diff --git a/source/isaaclab/changelog.d/nvbug-video-extra-message.fixed.rst b/source/isaaclab/changelog.d/nvbug-video-extra-message.fixed.rst index 481f1a032ef7..591e0122f3f7 100644 --- a/source/isaaclab/changelog.d/nvbug-video-extra-message.fixed.rst +++ b/source/isaaclab/changelog.d/nvbug-video-extra-message.fixed.rst @@ -1 +1 @@ -* Fixed ``--video`` failing with a raw ``ModuleNotFoundError: moviepy`` when the ``video`` extra is not installed. :class:`~isaaclab.envs.utils.video_recorder.VideoRecorder` now raises an :class:`ImportError` that names the extra. +* Fixed ``--video`` failing with a raw ``ModuleNotFoundError: moviepy`` when the ``video`` extra is not installed. :class:`~isaaclab.envs.utils.video_recorder.VideoRecorder` now raises a :class:`ModuleNotFoundError` that names the extra. diff --git a/source/isaaclab/isaaclab/app/loading_screen.py b/source/isaaclab/isaaclab/app/loading_screen.py index 63bc635aa2d7..3b8c1ef46172 100644 --- a/source/isaaclab/isaaclab/app/loading_screen.py +++ b/source/isaaclab/isaaclab/app/loading_screen.py @@ -357,7 +357,7 @@ def __init__(self, num_stages: int, *, enabled: bool | None = None, logo: bool = self._saved_fds: tuple[int, int] | None = None self._saved_streams: tuple[IO[str], IO[str]] | None = None self._spooled_streams: tuple[IO[str], IO[str]] | None = None - self._deprecations: list[str] = [] + self._deprecations: list[tuple[str, type[Warning], str, int]] = [] self._showwarning: Callable[..., None] | None = None self._original_showwarning: Callable[..., None] | None = None self._original_input: Callable[..., str] | None = None @@ -518,10 +518,13 @@ def _shut_down(self, *, replay: bool) -> None: try: if replay: self._write(hidden) + self._deprecations.clear() else: - # the spool is dropped on success, but a deprecation must not go unseen - for text in self._deprecations: - self._write(f"[WARNING]: {text}\n") + # the spool is dropped on success, but a deprecation must not go unseen; the restored + # warning hook shows it as usual, with its category and location + for message, category, filename, lineno in self._deprecations: + warnings.showwarning(message, category, filename, lineno) + self._deprecations.clear() elapsed = time.monotonic() - self._started lines = hidden.count("\n") self._write( @@ -628,13 +631,20 @@ def _redirect_streams(self) -> None: def _capture_deprecations(self) -> None: """Remember deprecation warnings raised while output is spooled, so a successful start can still show them.""" + if self._showwarning is not None: + return original = warnings.showwarning def showwarning(message, category, filename, lineno, file=None, line=None): - if file is None and issubclass(category, (FutureWarning, DeprecationWarning)): - text = str(message) - if text not in self._deprecations: - self._deprecations.append(text) + # once the screen is closed a hook that could not be unhooked only passes warnings through + if ( + self._showwarning is showwarning + and file is None + and issubclass(category, (FutureWarning, DeprecationWarning)) + ): + record = (str(message), category, filename, lineno) + if record not in self._deprecations: + self._deprecations.append(record) original(message, category, filename, lineno, file, line) self._original_showwarning = original @@ -644,6 +654,7 @@ def showwarning(message, category, filename, lineno, file=None, line=None): def _restore(self) -> str: """Restore redirected output and return the spooled text.""" if self._showwarning is not None: + # leave a hook that something else installed on top of ours; it stops recording once unset below if warnings.showwarning is self._showwarning: warnings.showwarning = self._original_showwarning self._showwarning = self._original_showwarning = None diff --git a/source/isaaclab/isaaclab/envs/utils/video_recorder.py b/source/isaaclab/isaaclab/envs/utils/video_recorder.py index ba992b01d534..282bcfeb1938 100644 --- a/source/isaaclab/isaaclab/envs/utils/video_recorder.py +++ b/source/isaaclab/isaaclab/envs/utils/video_recorder.py @@ -20,7 +20,12 @@ import numpy as np from ...visualizers.visualizer_cfg import ImageViewCfg -from .video_recorder_cfg import CAPTURE_VISUALIZER_TYPES, VIDEO_EXTRA_MESSAGE, VideoRecorderCfg, parse_video_source +from .video_recorder_cfg import ( + CAPTURE_VISUALIZER_TYPES, + VideoRecorderCfg, + import_image_sequence_clip, + parse_video_source, +) logger = logging.getLogger(__name__) @@ -38,10 +43,7 @@ class VideoRecorder: """ def __init__(self, cfg: VideoRecorderCfg, env: object): - try: - from moviepy.video.io.ImageSequenceClip import ImageSequenceClip - except ImportError as exc: - raise ImportError(VIDEO_EXTRA_MESSAGE) from exc + ImageSequenceClip = import_image_sequence_clip() self._clip_class = ImageSequenceClip source = cfg.source diff --git a/source/isaaclab/isaaclab/envs/utils/video_recorder_cfg.py b/source/isaaclab/isaaclab/envs/utils/video_recorder_cfg.py index 2c64ee7f6a1a..bac11d6890ac 100644 --- a/source/isaaclab/isaaclab/envs/utils/video_recorder_cfg.py +++ b/source/isaaclab/isaaclab/envs/utils/video_recorder_cfg.py @@ -15,10 +15,31 @@ VIDEO_EXTRA_MESSAGE = ( "Video recording needs the optional 'moviepy' package, which ships in the 'video' extra. " - "Run with `uv run --extra video isaaclab ...` (or `pip install 'isaaclab[video]'`), or drop --video." + "Install it with `uv run --extra video isaaclab ...`, `pip install 'isaaclab[video]'` or `pip install moviepy`, " + "or drop --video." ) """Error raised when a video is requested but ``moviepy`` is not installed.""" + +def import_image_sequence_clip() -> type: + """Import the ``moviepy`` clip class the recorder writes with. + + Returns: + The ``ImageSequenceClip`` class. + + Raises: + ModuleNotFoundError: If ``moviepy`` is not installed. The message names the ``video`` extra. A missing + dependency of ``moviepy`` propagates unchanged. + """ + try: + from moviepy.video.io.ImageSequenceClip import ImageSequenceClip + except ModuleNotFoundError as exc: + if (exc.name or "").split(".")[0] != "moviepy": + raise + raise ModuleNotFoundError(VIDEO_EXTRA_MESSAGE, name="moviepy") from exc + return ImageSequenceClip + + SENSOR_CHANNELS = ("rgb", "depth", "segmentation", "normals") """Channels a ``sensor::`` source can record.""" diff --git a/source/isaaclab/test/app/test_loading_screen.py b/source/isaaclab/test/app/test_loading_screen.py index a95900b7d2be..864df07d7301 100644 --- a/source/isaaclab/test/app/test_loading_screen.py +++ b/source/isaaclab/test/app/test_loading_screen.py @@ -308,25 +308,84 @@ def test_redirect_uses_stream_swapping_on_platforms_without_descriptor_redirecti assert original_stderr.getvalue() == "after startup\n" +def _write_warnings_to_stderr(message, category, filename, lineno, file=None, line=None) -> None: + """Stand in for the default hook, which pytest replaces with a recorder.""" + sys.stderr.write(f"{filename}:{lineno}: {category.__name__}: {message}\n") + + def test_deprecation_warnings_survive_a_successful_start(monkeypatch: pytest.MonkeyPatch) -> None: - """A deprecation raised while startup output is spooled is printed when the screen closes.""" - console = _OpenStringIO() + """A deprecation raised while startup output is spooled is shown through the restored hook on close.""" + console, stderr = _OpenStringIO(), _OpenStringIO() monkeypatch.setattr(loading_screen.sys, "stdout", console) - monkeypatch.setattr(loading_screen.sys, "stderr", _OpenStringIO()) + monkeypatch.setattr(loading_screen.sys, "stderr", stderr) + screen = loading_screen.LoadingScreen(1, enabled=True, logo=False) + monkeypatch.setattr(screen, "_redirect", screen._redirect_streams) + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.showwarning = _write_warnings_to_stderr + hook = warnings.showwarning + with screen: + for _ in range(2): + warnings.warn("old thing is deprecated", FutureWarning) # repeats from one place are shown once + warnings.warn("not a deprecation", UserWarning) + screen.close() + assert warnings.showwarning is hook # restored before the block ends, which catch_warnings would mask + + assert stderr.getvalue().count("FutureWarning: old thing is deprecated") == 1 + assert "test_loading_screen.py" in stderr.getvalue() + assert "not a deprecation" not in stderr.getvalue() + assert "old thing is deprecated" not in console.getvalue() + + +def test_deprecation_warnings_survive_on_the_descriptor_redirect_path(capfd: pytest.CaptureFixture[str]) -> None: + """The Linux path spools through file descriptors; the deprecation still reaches the console on close.""" + screen = loading_screen.LoadingScreen(1, enabled=True, logo=False) + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.showwarning = _write_warnings_to_stderr + screen._redirect() + warnings.warn("old thing is deprecated", FutureWarning) + screen._shut_down(replay=False) + + assert "FutureWarning: old thing is deprecated" in capfd.readouterr().err + + +def test_failed_startup_replays_the_spool_without_a_second_deprecation_line(monkeypatch: pytest.MonkeyPatch) -> None: + console, stderr = _OpenStringIO(), _OpenStringIO() + monkeypatch.setattr(loading_screen.sys, "stdout", console) + monkeypatch.setattr(loading_screen.sys, "stderr", stderr) screen = loading_screen.LoadingScreen(1, enabled=True, logo=False) monkeypatch.setattr(screen, "_redirect", screen._redirect_streams) - original_showwarning = warnings.showwarning with warnings.catch_warnings(): warnings.simplefilter("always") + warnings.showwarning = _write_warnings_to_stderr + with pytest.raises(RuntimeError): + with screen: + warnings.warn("old thing is deprecated", FutureWarning) + raise RuntimeError("startup failed") + + shown = console.getvalue() + stderr.getvalue() + assert shown.count("old thing is deprecated") == 1 # replayed from the spool only + + +def test_a_hook_installed_over_ours_stops_recording_after_close(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(loading_screen.sys, "stdout", _OpenStringIO()) + monkeypatch.setattr(loading_screen.sys, "stderr", _OpenStringIO()) + screen = loading_screen.LoadingScreen(1, enabled=True, logo=False) + monkeypatch.setattr(screen, "_redirect", screen._redirect_streams) + + with warnings.catch_warnings(): + warnings.showwarning = _write_warnings_to_stderr with screen: - warnings.warn("old thing is deprecated", FutureWarning) - warnings.warn("old thing is deprecated", FutureWarning) # repeats are printed once - with pytest.warns(UserWarning): - warnings.warn("not a deprecation", UserWarning) + ours = warnings.showwarning + + def other(*args, **kwargs) -> None: + ours(*args, **kwargs) # something else wrapped the hook during startup + + warnings.showwarning = other screen.close() - output = console.getvalue() + other(FutureWarning("after close"), FutureWarning, "file.py", 1) - assert output.count("[WARNING]: old thing is deprecated") == 1 - assert "not a deprecation" not in output - assert warnings.showwarning is original_showwarning + assert screen._deprecations == [] diff --git a/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py b/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py index b9413f707e78..1040a0fc29cd 100644 --- a/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py +++ b/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py @@ -9,7 +9,6 @@ import argparse import contextlib -import importlib.util import json import logging import os @@ -31,7 +30,7 @@ from isaaclab.app import LoadingScreen from isaaclab.envs import DirectMARLEnvCfg, DirectRLEnvCfg, ManagerBasedRLEnvCfg -from isaaclab.envs.utils.video_recorder_cfg import VIDEO_EXTRA_MESSAGE, VideoRecorderCfg, parse_video_source +from isaaclab.envs.utils.video_recorder_cfg import VideoRecorderCfg, import_image_sequence_clip, parse_video_source from isaaclab.renderers.renderer_cfg import RendererCfg from isaaclab.utils.assets import retrieve_file_path from isaaclab.utils.dict import print_dict @@ -930,14 +929,11 @@ def pre_launch_video_config(env_cfg: Any, args_cli: argparse.Namespace) -> None: args_cli: Parsed command-line arguments. Raises: - ImportError: If recording is requested but ``moviepy`` (the ``video`` extra) is not installed. + ModuleNotFoundError: If recording is requested but ``moviepy`` (the ``video`` extra) is not installed. ValueError: If recording is requested with the warp frontend. """ if not getattr(args_cli, "video", None): return - # Fail before the simulation launches rather than deep inside environment creation. - if importlib.util.find_spec("moviepy") is None: - raise ImportError(VIDEO_EXTRA_MESSAGE) frontend = getattr(args_cli, "frontend", "torch") or "torch" if frontend != "torch": raise ValueError( @@ -945,6 +941,8 @@ def pre_launch_video_config(env_cfg: Any, args_cli: argparse.Namespace) -> None: "Video recording requires the standard torch frontend. " "Remove --video or switch to --frontend torch." ) + # Fail before the simulation launches rather than deep inside environment creation. + import_image_sequence_clip() if not env_cfg.video_recorders: env_cfg.video_recorders = [VideoRecorderCfg(source=args_cli.video, video_interval=2000)] diff --git a/source/isaaclab_rl/test/test_apply_video_recording.py b/source/isaaclab_rl/test/test_apply_video_recording.py index e20b760f2f0c..454d6c4ea8f2 100644 --- a/source/isaaclab_rl/test/test_apply_video_recording.py +++ b/source/isaaclab_rl/test/test_apply_video_recording.py @@ -20,9 +20,10 @@ import isaaclab.app.sim_launcher as sim_launcher from isaaclab.app import SimulationLauncher, add_launcher_args from isaaclab.envs import ManagerBasedRLEnvCfg -from isaaclab.envs.utils.video_recorder_cfg import VideoRecorderCfg +from isaaclab.envs.utils.video_recorder_cfg import VIDEO_EXTRA_MESSAGE, VideoRecorderCfg from isaaclab.visualizers import VisualizerCfg +import isaaclab_rl.entrypoints.common as common from isaaclab_rl.entrypoints.common import ( add_common_train_args, apply_video_recording, @@ -36,6 +37,12 @@ _KIT_LAUNCHER = "isaaclab_isaacsim.app:KitLauncher" +@pytest.fixture(autouse=True) +def _moviepy_available(monkeypatch: pytest.MonkeyPatch) -> None: + """Resolving a ``--video`` source must not depend on the optional recording package being installed.""" + monkeypatch.setattr(common, "import_image_sequence_clip", lambda: object) + + def _args(**kwargs: object) -> argparse.Namespace: defaults = dict(video="viz", video_length=None, video_interval=None, visualizer=None) return argparse.Namespace(**{**defaults, **kwargs}) @@ -284,3 +291,28 @@ def test_video_playback_steps(recorders: list[tuple[int, int]], cli_args: dict, apply_video_recording(env_cfg, "/tmp/logs", args) assert video_playback_steps(args, env_cfg) == expected_steps + + +def test_missing_moviepy_stops_a_video_run_before_launch(monkeypatch: pytest.MonkeyPatch): + """Without the ``video`` extra the run stops up front with a message that names it.""" + + def missing(): + raise ModuleNotFoundError(VIDEO_EXTRA_MESSAGE, name="moviepy") + + monkeypatch.setattr(common, "import_image_sequence_clip", missing) + + with pytest.raises(ModuleNotFoundError, match="'video' extra"): + pre_launch_video_config(ManagerBasedRLEnvCfg(), _args()) + pre_launch_video_config(ManagerBasedRLEnvCfg(), _args(video=None)) # no --video, nothing to install + + +def test_unsupported_frontend_is_reported_before_the_missing_extra(monkeypatch: pytest.MonkeyPatch): + """Installing the extra cannot fix an unsupported frontend, so that error comes first.""" + + def missing(): + raise ModuleNotFoundError(VIDEO_EXTRA_MESSAGE, name="moviepy") + + monkeypatch.setattr(common, "import_image_sequence_clip", missing) + + with pytest.raises(ValueError, match="--frontend 'warp'"): + pre_launch_video_config(ManagerBasedRLEnvCfg(), _args(frontend="warp")) From 5a678f751bea3d4b1f4e41b8c9dc7d676498d2f4 Mon Sep 17 00:00:00 2001 From: mtrepte Date: Wed, 2 Dec 2026 23:49:00 +0000 Subject: [PATCH 6/6] Annotate the warning hook and update the remaining recording commands Signed-off-by: mtrepte --- docs/source/how-to/record_video.rst | 6 +++--- source/isaaclab/isaaclab/app/loading_screen.py | 9 ++++++++- source/isaaclab_rl/isaaclab_rl/entrypoints/common.py | 1 - 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/source/how-to/record_video.rst b/docs/source/how-to/record_video.rst index 607e9685b411..0bef9cd9ae83 100644 --- a/docs/source/how-to/record_video.rst +++ b/docs/source/how-to/record_video.rst @@ -116,7 +116,7 @@ Example 1: Newton viewport .. code-block:: bash - uv run python scripts/tutorials/07_visualizers/run_video_recording.py \ + uv run --extra video python scripts/tutorials/07_visualizers/run_video_recording.py \ --example 1 --num_envs 4 --viz newton_rtx * Records the Newton interactive viewport using RTX @@ -138,7 +138,7 @@ Example 2: Scene sensor, headless .. code-block:: bash - uv run python scripts/tutorials/07_visualizers/run_video_recording.py \ + uv run --extra video python scripts/tutorials/07_visualizers/run_video_recording.py \ --example 2 --num_envs 16 .. raw:: html @@ -172,7 +172,7 @@ Example 3: All sources simultaneously .. code-block:: bash - uv run python scripts/tutorials/07_visualizers/run_video_recording.py \ + uv run --extra video python scripts/tutorials/07_visualizers/run_video_recording.py \ --example 3 --num_envs 4 --viz newton_rtx Three independent clips are written to ``videos/recording_tutorial/example_3/``: diff --git a/source/isaaclab/isaaclab/app/loading_screen.py b/source/isaaclab/isaaclab/app/loading_screen.py index 3b8c1ef46172..31fd114808c9 100644 --- a/source/isaaclab/isaaclab/app/loading_screen.py +++ b/source/isaaclab/isaaclab/app/loading_screen.py @@ -635,7 +635,14 @@ def _capture_deprecations(self) -> None: return original = warnings.showwarning - def showwarning(message, category, filename, lineno, file=None, line=None): + def showwarning( + message: Warning | str, + category: type[Warning], + filename: str, + lineno: int, + file: IO[str] | None = None, + line: str | None = None, + ) -> None: # once the screen is closed a hook that could not be unhooked only passes warnings through if ( self._showwarning is showwarning diff --git a/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py b/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py index 1040a0fc29cd..7eaed7060b00 100644 --- a/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py +++ b/source/isaaclab_rl/isaaclab_rl/entrypoints/common.py @@ -941,7 +941,6 @@ def pre_launch_video_config(env_cfg: Any, args_cli: argparse.Namespace) -> None: "Video recording requires the standard torch frontend. " "Remove --video or switch to --frontend torch." ) - # Fail before the simulation launches rather than deep inside environment creation. import_image_sequence_clip() if not env_cfg.video_recorders: env_cfg.video_recorders = [VideoRecorderCfg(source=args_cli.video, video_interval=2000)]