Skip to content

Lazifies IsaacLab export system#4741

Merged
ooctipus merged 15 commits intoisaac-sim:developfrom
ooctipus:feature/develop/lazy_import
Mar 1, 2026
Merged

Lazifies IsaacLab export system#4741
ooctipus merged 15 commits intoisaac-sim:developfrom
ooctipus:feature/develop/lazy_import

Conversation

@ooctipus
Copy link
Collaborator

Description

This PR improves lazy-loading and config-only import behavior so environment config construction stays backend-free and deterministic.

  • Simplifies and tightens cascading namespace resolution in isaaclab.utils.module.attach_cascading with strict fail-fast imports.
  • Prevents eager callable resolution during deepcopy by adding __copy__ / __deepcopy__ behavior in ResolvableString.
  • Reorders isaaclab.sim.utils cascading lookup to prefer lightweight modules first.
  • Fixes locomanipulation pick-place MDP namespace/export boundaries (terminations) and removes a backend-heavy module-level import path in pick-place terminations.
  • Updates changelog for the lazy-loader/config-import cleanup.

Fixes # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)

Screenshots

Please attach before and after screenshots of the change if applicable.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@github-actions github-actions bot added enhancement New feature or request asset New asset feature or request isaac-mimic Related to Isaac Mimic team labels Feb 26, 2026
@ooctipus ooctipus changed the title Feature/develop/lazy import Lazifies IsaacLab import system Feb 26, 2026
Copy link
Collaborator

@AntoineRichard AntoineRichard left a comment

Choose a reason for hiding this comment

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

I'm a bit concerned about user friendlyness of this PR. This looks inelegant, and not very user friendly.

import lazy_loader as lazy

__getattr__, __dir__, __all__ = lazy.attach(
    __name__,
    submod_attrs={
        "actuator_base": ["ActuatorBase"],
        "actuator_base_cfg": ["ActuatorBaseCfg"],
        "actuator_net": ["ActuatorNetLSTM", "ActuatorNetMLP"],
        "actuator_net_cfg": ["ActuatorNetLSTMCfg", "ActuatorNetMLPCfg"],
        "actuator_pd": ["DCMotor", "DelayedPDActuator", "IdealPDActuator", "ImplicitActuator", "RemotizedPDActuator"],
        "actuator_pd_cfg": [
            "DCMotorCfg",
            "DelayedPDActuatorCfg",
            "IdealPDActuatorCfg",
            "ImplicitActuatorCfg",
            "RemotizedPDActuatorCfg",
        ],
    },
)

How about we do something like that:

# lazy_imports.py
from __future__ import annotations

from collections.abc import Iterable
import sys
import lazy_loader as lazy

def lazy_export(*imports: tuple[str, str | Iterable[str]]) -> None:
    """
    Usage in __init__.py:
        from .lazy_imports import lazy_export
        lazy_export(("foo", "A"), ("bar", ["B", "C"]))
    """
    caller_globals = sys._getframe(1).f_globals
    package_name = caller_globals["__name__"]

    submod_attrs: dict[str, list[str]] = {}
    for submod, names in imports:
        submod_attrs[submod] = [names] if isinstance(names, str) else list(names)

    __getattr__, __dir__, __all__ = lazy.attach(package_name, submod_attrs=submod_attrs)

    mod = sys.modules[package_name]
    mod.__getattr__ = __getattr__
    mod.__dir__ = __dir__
    mod.__all__ = __all__

This would simplify the code to:

from .lazy_imports import lazy_export

lazy_export(
    ("actuator_base", "ActuatorBase"),
    ("actuator_base_cfg", "ActuatorBaseCfg"),
    ("actuator_net", ["ActuatorNetLSTM", "ActuatorNetMLP"]),
    ("actuator_net_cfg", ["ActuatorNetLSTMCfg", "ActuatorNetMLPCfg"]),
    ("actuator_pd", ["DCMotor", "DelayedPDActuator", "IdealPDActuator", "ImplicitActuator", "RemotizedPDActuator"]),
    ("actuator_pd_cfg", ["DCMotorCfg", "DelayedPDActuatorCfg", "IdealPDActuatorCfg", "ImplicitActuatorCfg", "RemotizedPDActuatorCfg"]),
)

@AntoineRichard
Copy link
Collaborator

ooctipus#6 I have a PR that makes this a bit nicer.

@AntoineRichard
Copy link
Collaborator

This would likely solve #4742. But I'm wondering if we should have these imports inside our inits. What do we gain from these?

@ooctipus ooctipus force-pushed the feature/develop/lazy_import branch 4 times, most recently from 7f87abd to 56dc8ea Compare February 27, 2026 12:04
@ooctipus ooctipus marked this pull request as ready for review February 27, 2026 12:14
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 27, 2026

Too many files changed for review. (171 files found, 100 file limit)

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 27, 2026
@ooctipus ooctipus force-pushed the feature/develop/lazy_import branch 2 times, most recently from d48f4b0 to ea0aab5 Compare February 27, 2026 21:18
@ooctipus ooctipus force-pushed the feature/develop/lazy_import branch 2 times, most recently from 8293ff0 to 8826aff Compare February 28, 2026 01:01
@ooctipus ooctipus force-pushed the feature/develop/lazy_import branch from 8826aff to fd6cd9e Compare February 28, 2026 01:01
jacobian_in_frame = configuration.get_frame_jacobian(self.frame)
J = -pin.Jlog6(transform_frame_to_target) @ jacobian_in_frame
return J
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

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

are we aliasing to the new script?

Changelog
---------

4.4.0 (2026-02-26)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this could be 5.0. looks like a breaking change.

can we also document this in the 3.0 migration doc?

from pink.tasks import Task


if TYPE_CHECKING:
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate import

@ooctipus ooctipus force-pushed the feature/develop/lazy_import branch from 813bf30 to 63eeefd Compare February 28, 2026 07:52
@ooctipus ooctipus changed the title Lazifies IsaacLab import system Lazifies IsaacLab export system Feb 28, 2026
@ooctipus
Copy link
Collaborator Author

ooctipus commented Mar 1, 2026

test_imu seems to be only failing test in test_general. And that failure is from a known bug in physx replicate

@ooctipus ooctipus merged commit 5001364 into isaac-sim:develop Mar 1, 2026
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

asset New asset feature or request documentation Improvements or additions to documentation enhancement New feature or request infrastructure isaac-mimic Related to Isaac Mimic team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants