Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/source/concepts/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,16 @@ 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`.

.. 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 <https://rerun.io/>`_ streams simulation state to a local web server, for
remote monitoring, timeline playback, and recording to ``.rrd`` files.

Expand Down Expand Up @@ -766,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.

Expand Down
18 changes: 12 additions & 6 deletions docs/source/how-to/record_video.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Warning · Style Consistency — Update the remaining recording commands

This note tells uv users to add --extra video, but the tutorial command at line 175 and the --video recipe at line 237 still omit it. Update both commands.

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 <record_video_cli>` for every command-line form, and `Sources`_ and `Clip control`_
Expand Down Expand Up @@ -110,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
Expand All @@ -132,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
Expand Down Expand Up @@ -166,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/``:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -228,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:<name>"``, which needs no
visualizer.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/how-to/train_g1_motion_tracking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions docs/source/isaaclab/migrating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.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
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
Expand Down Expand Up @@ -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 <record_video_cli>`.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/isaaclab/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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 through the normal warning hook when the screen closes, without needing ``--info``.
Original file line number Diff line number Diff line change
@@ -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 a :class:`ModuleNotFoundError` that names the extra.
49 changes: 48 additions & 1 deletion source/isaaclab/isaaclab/app/loading_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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[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
self._input_wrapper: Callable[..., str] | None = None
self._started = 0.0
Expand Down Expand Up @@ -513,7 +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; 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(
Expand Down Expand Up @@ -607,6 +618,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."""
Expand All @@ -615,9 +627,44 @@ 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."""
if self._showwarning is not None:
return
original = warnings.showwarning

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
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
self._showwarning = showwarning
warnings.showwarning = showwarning

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
if self._saved_fds is not None:
sys.stdout.flush()
sys.stderr.flush()
Expand Down
9 changes: 7 additions & 2 deletions source/isaaclab/isaaclab/envs/utils/video_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
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,
VideoRecorderCfg,
import_image_sequence_clip,
parse_video_source,
)

logger = logging.getLogger(__name__)

Expand All @@ -38,7 +43,7 @@ class VideoRecorder:
"""

def __init__(self, cfg: VideoRecorderCfg, env: object):
from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
ImageSequenceClip = import_image_sequence_clip()

self._clip_class = ImageSequenceClip
source = cfg.source
Expand Down
27 changes: 27 additions & 0 deletions source/isaaclab/isaaclab/envs/utils/video_recorder_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@
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. "
"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:<name>:<channel>`` source can record."""

Expand Down
84 changes: 84 additions & 0 deletions source/isaaclab/test/app/test_loading_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import sys
import textwrap
import time
import warnings
from io import BytesIO, StringIO, TextIOWrapper
from unittest.mock import Mock

Expand Down Expand Up @@ -305,3 +306,86 @@ 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 _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 shown through the restored hook on close."""
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)

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)

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:
ours = warnings.showwarning

def other(*args, **kwargs) -> None:
ours(*args, **kwargs) # something else wrapped the hook during startup

warnings.showwarning = other
screen.close()
other(FutureWarning("after close"), FutureWarning, "file.py", 1)

assert screen._deprecations == []
Original file line number Diff line number Diff line change
@@ -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.
Loading
Loading