Repository navigation
[Fix] Make generated template projects import without Kit (no eager omni.ext) - #5941
Conversation
There was a problem hiding this comment.
Review Summary
Well-structured fix PR that addresses two distinct but related template-generator issues. The approach is sound and the test coverage is excellent.
Overall assessment: ✅ Approve-worthy — clean, minimal, well-tested fixes with thorough regression coverage.
Architecture & Design
Import Safety Fix (NVBug 6251247)
The fix correctly separates the UI extension loading path from the package import path:
__init__ext— Removes the eagerfrom .ui_extension_example import *, replacing it with a clear comment explaining why.extension.toml— Adds[[python.module]] name = "{{ name }}.ui_extension_example"so Kit's extension manager still discovers and loads theIExtsubclass at runtime.ui_extension_example.py— Adds the previously-missingimport omni.ui.
This is the correct architectural choice over lazy-importing: the UI extension is only consumed by Kit's module scanner, so it should be declared in extension.toml rather than imported at package level.
Error Handling Fix
The generator.py change to raise FileNotFoundError instead of silently continuing when a template is missing is the right call — projects now fail at generation time rather than at train time with a cryptic missing-config error.
Test Coverage Analysis
The test suite is comprehensive with excellent regression guards:
| Test | What it validates |
|---|---|
test_generated_env_modules_have_no_forbidden_top_level_imports |
AST-based check for pxr/omni/carb/isaacsim/usdrt at module scope |
test_each_requested_agent_cfg_file_is_generated |
No silently-skipped agent configs |
test_generated_python_is_syntactically_valid |
AST + compile check on all generated .py |
test_extension_toml_registers_ui_extension_as_separate_module |
Both halves of the import-safety fix |
test_generated_package_import_is_omni_and_pxr_free |
Subprocess import with omni/pxr blocker |
The subprocess-based import-safety test (test_generated_package_import_is_omni_and_pxr_free) is particularly well-designed — it uses a custom sys.meta_path finder to block omni/pxr imports and verifies the package still loads cleanly.
🔄 Follow-up Review — 374d842 (2026-06-04)
✅ Previous Concern Resolved
The stray debug comment in __init__ext (#rj: what's the consequence of this change?...) has been removed. This was the only blocking issue from my previous review.
No New Issues Introduced
The new commit cleanly addresses the feedback with no regressions:
- All existing tests should continue to pass
- New test coverage is thorough and well-designed
- Changelog fragment is properly formatted
LGTM. Ready for merge.
🔄 Follow-up Review — 911435d6 (2026-06-04)
New Changes (NVBug 6251258/6257159 — Manager-Based pxr Fix)
The new commits add a second fix addressing eager pxr imports in manager-based template projects:
mdp/__init__.py— Replaced wildcard re-exports withlazy_export()fromisaaclab.utils.module, deferring heavy imports until actually accessed.mdp/__init__.pyi— Added type stub for IDE support without runtime cost.mdp/rewards.py— Movedfrom isaaclab.assets import ArticulationintoTYPE_CHECKINGguard to break thepxrimport chain.- New test —
test_generated_manager_based_env_cfg_resolution_is_omni_and_pxr_freevalidates env config instantiation in a subprocess withomni/pxrblocked. - Changelog — Updated with the additional fix description.
Assessment
✅ No issues found. The lazy_export() + TYPE_CHECKING pattern is the correct approach for keeping template projects importable before Kit launches. Test coverage mirrors the existing import-safety test with the same subprocess-blocker strategy.
LGTM. Still approve-worthy.
🔄 Follow-up Review — e03366b5 (2026-06-04)
Trivial Cleanup
Single commit removes redundant source/isaaclab_rl/changelog.d/template-generator-tests.skip — an empty changelog fragment from the chained test branch that's no longer needed since the single jichuanh-fix-template-generator.rst fragment already covers the isaaclab_rl change.
✅ No issues. No code changes. LGTM.
🔄 Follow-up Review — b5795e73 (2026-06-04)
New Fix: Internal Task Registration
Addresses a subtle issue where generated internal tasks failed to register because after the core/contrib split (#5891), isaaclab_tasks/{direct,manager_based}/ became namespace directories without __init__.py. Since import_packages uses pkgutil.iter_modules, which skips namespace packages, internal tasks were never discovered.
Changes:
generator.py— Moved workflow__init__.pycreation into_generate_tasks()(from the external-only code path), now shared by both internal and external generation. Creates the init file only when missing to avoid clobbering existing packages.- New test —
test_generated_internal_task_workflow_dirs_are_importable_packagesverifiespkgutil.iter_moduleslists the generated workflow dirs as packages. - Changelog — Added entry for the internal task registration fix.
Assessment
✅ No issues found. The fix is minimal and correct:
os.path.exists()check prevents clobbering existing packages- Moving the logic into
_generate_tasks()eliminates duplicate code in the external path - Test directly validates the
pkgutil.iter_modulesbehavior thatimport_packagesdepends on
LGTM. Continues to be approve-worthy.
Update (5c7cfb1): Reviewed incremental changes (e03366b → 5c7cfb1):
- generator.py: Moved per-workflow
__init__.pycreation from_external()into_generate_tasks()— now both internal and external tasks get the package init. Addedos.path.existsguard to avoid clobbering existing files. Clean refactor, no issues. - test_template_generator.py: Added two solid regression tests —
test_generated_internal_task_workflow_dirs_are_importable_packages(verifiespkgutil.iter_modulesdiscovers the workflow dirs) andtest_generated_external_project_registers_tasks_on_import(end-to-end import registration check). Good coverage. - changelog.d: Added entry for the new fix.
No new issues. Changes look good. ✅
Update (d95991f): Reviewed incremental changes (5c7cfb1 → d95991f):
- changelog.d/jichuanh-fix-template-generator.rst → Removed (replaced with .skip sentinel)
- changelog.d/jichuanh-fix-template-generator.skip → Added (empty file)
This swaps the detailed changelog fragment for a .skip sentinel, meaning the isaaclab_rl package changelog will not emit an entry for this branch. Likely done because the relevant changelog entries are being consolidated elsewhere (e.g., in the parent isaaclab package changelog) or the template-generator changes are considered internal tooling not warranting a user-facing release note.
✅ No issues. Housekeeping-only change. LGTM.
Update (aea97ea): Large release-prep commit landed. Key changes:
- Version bumps: isaaclab 6.3.0, isaaclab_newton 0.15.0, isaaclab_rl 0.6.0, isaaclab_tasks 2.0.2, isaaclab_contrib 0.4.2, isaaclab_experimental 0.1.1, isaaclab_ovphysx pin ovphysx==0.4.13
- Changelog consolidation: Moved all pending
changelog.d/fragments into their respectiveCHANGELOG.rstfiles and removed the fragments ls_paralleldeprecation (isaaclab_newton):MJWarpSolverCfg.ls_parallelnow emitsDeprecationWarningand is forced toFalsevia__post_init__. All test/task configs hadls_parallelreferences removed. Manager filters the field out before forwarding to solver constructor.- Removed
scripts/tools/wrap_warp_to_torch.py: Obsolete migration helper deleted; test exclusion for it also removed - CI: Pinned
ovphysx==0.4.13in workflow extra-pip-packages; license-check workflow migrated from pip touv - Docs: Updated MJWarp solver docs removing
ls_parallelreferences; improvedls_iterationsdescription; docs extension now respectssmv_current_version - Tasks: Newton Spot preset expanded with collision pipeline config and
use_mujoco_contacts=False; benchmark script wrapped step intorch.inference_mode(); camera demo subtitle fix - Tests: Updated test assertion message in
test_template_generator.pyfor clarity
No new issues introduced. This is a well-organized release commit consolidating prior work. ✅
| if self._newton_model.shape_count > 0 and self._newton_model.bvh_shapes is None: | ||
| newton.geometry.build_bvh_shape(self._newton_model, self._newton_model.state()) | ||
|
|
||
| if self.cfg.create_default_light: | ||
| self.newton_sensor.utils.create_default_light(enable_shadows=self.cfg.enable_shadows) | ||
| ======= | ||
| if newton_model.shape_count > 0 and newton_model.bvh_shapes is None: | ||
| newton.geometry.build_bvh_shape(newton_model, newton_model.state()) |
There was a problem hiding this comment.
🚨 Unresolved merge conflict markers — this file has <<<<<<< Updated upstream / ======= / >>>>>>> Stashed changes blocks that will cause a SyntaxError at import time. Looks like a git stash pop or merge left conflicts that were accidentally committed.
| @@ -41,6 +44,7 @@ | |||
|
|
|||
| from .preset_target import PresetTarget | |||
|
|
|||
| <<<<<<< Updated upstream | |||
There was a problem hiding this comment.
🚨 Unresolved merge conflict markers throughout this file — there are ~8 conflict blocks (<<<<<<< Updated upstream / >>>>>>> Stashed changes). This will not parse as valid Python. The refactoring here (removing deprecation helpers, renaming newton_mjwarp → newton) also seems like a significant scope expansion beyond the PR title — consider splitting into a separate PR once conflicts are resolved.
d19e140 to
7f56599
Compare
3a7aab3 to
a1477e0
Compare
The generated project package imported the example UI extension (ui_extension_example.py -> import omni.ext) from its __init__, so importing the project headless (e.g. Gym registration before SimulationApp) failed with "ModuleNotFoundError: No module named 'omni.ext'". Load the UI extension via its own config/extension.toml [[python.module]] entry instead, keeping the package root omni-free, and add the missing omni.ui import the example relies on. Also make the generator fail loudly when a requested agent config template is missing: it previously skipped silently, emitting a project whose Gym registration referenced a non-existent config file. Extend the template-generator tests with regression coverage: omni/pxr import-safety of the generated package, extension.toml UI-module registration, generated-code syntax validity, no top-level backend imports in generated env modules, and per-library agent-config completeness. NVBug 6251247
a1477e0 to
374d842
Compare
| @@ -10,5 +10,8 @@ Python module serving as a project/extension template. | |||
| # Register Gym environments. | |||
| from .tasks import * | |||
|
|
|||
There was a problem hiding this comment.
#rj: what's the consequence of this change? does it require all other scripts to import?) looks like an inline reviewer note that was accidentally committed. Should be removed before merge.
The skrl training scripts resolve the env config (resolve_task_config) before launch_simulation boots Kit, so the env config and the MDP terms it references must import without pxr. Generated manager-based projects loaded pxr eagerly two ways: the task mdp package re-exported isaaclab.envs.mdp with a star import, which force-resolves the whole lazy namespace, and mdp/rewards.py imported Articulation at module scope for a type-only annotation. Both pulled pxr before Kit, aborting startup with "TfNotice ... has not been created yet". Switch the generated mdp package to lazy_export() with a .pyi stub and guard the Articulation import under TYPE_CHECKING, matching the patterns used across isaaclab and PR isaac-sim#5916. Add a regression test that resolves the generated env config with omni and pxr import-blocked.
The template-generator CI tests land together with the import-safety fixes in this PR, so the single Fixed fragment (jichuanh-fix-template-generator.rst) already represents the isaaclab_rl change. Remove the empty template-generator-tests.skip carried from the chained test branch so one fragment per package remains.
After the core/contrib split (isaac-sim#5891), isaaclab_tasks/direct and isaaclab_tasks/manager_based became namespace dirs with no __init__.py. import_packages walks via pkgutil.iter_modules, which skips namespace packages, so a generated internal task placed under them was never discovered or registered. The generator now creates the per-workflow __init__.py (only when missing, so an existing package is never clobbered) in _generate_tasks, covering both internal and external paths; the duplicate loop in the external path is removed. Adds a regression test asserting pkgutil.iter_modules lists the generated workflow dirs as packages.
End-to-end guard for the generate-then-it-just-works promise: generate an external project and assert every workflow's task id lands in the Gym registry on a plain import, with no manual step.
isaaclab_rl is touched only by the generator tests; the actual fix lives in tools/template (not a versioned package). So isaaclab_rl warrants no changelog entry or version bump — use a .skip fragment instead of a Fixed entry.
Greptile SummaryThis PR fixes two independent bugs in the template-project generator: generated packages could not be imported headlessly because the package
Confidence Score: 4/5The changes are safe to merge; the core template and generator fixes are well-targeted and the 15 new tests verify both halves of the headless-import fix and the generator's new fail-loud behavior. All changed code paths are covered by the new regression tests, and the fixes are narrow and self-contained. The only issue found is a stale docstring in one test that describes the old silent-skip behavior this PR removes, which could mislead a developer investigating a future failure. source/isaaclab_rl/test/test_template_generator.py — the docstring on test_each_requested_agent_cfg_file_is_generated describes the removed continue behavior and should be updated. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["import project\n(headless / before SimulationApp)"] --> B["__init__.py\n(tasks registration only)"]
B --> C["Gym registry populated"]
B -.->|"NOT imported"| D["ui_extension_example.py\nomni.ext / omni.ui"]
E["Kit extension manager"] -->|"[[python.module]] name"| B
E -->|"[[python.module]] name.ui_extension_example"| D
F["generate()"] --> G{"agent template\nexists?"}
G -->|"Yes"| H["Write agent config file"]
G -->|"No"| I["raise FileNotFoundError\n(was: silent continue)"]
F --> J["_generate_tasks()"]
J --> K["Create workflow/__init__.py\nif missing\n(was: only in _external)"]
K --> L["Task importable by\npkgutil.iter_modules"]
Reviews (1): Last reviewed commit: "chore: make template-generator changelog..." | Re-trigger Greptile |
| {"name": "direct", "type": "multi-agent"}, | ||
| ] |
There was a problem hiding this comment.
Stale docstring describes the removed behaviour
The docstring says "A missing agent template is silently skipped (``generator.py`` ``continue``)", but this PR explicitly removes that continue path and replaces it with a loud FileNotFoundError. A future reader debugging a generator error will be confused, because the docstring points them at code that no longer exists. The test body itself (checking that every requested config file is present) accurately reflects the new contract — the docstring should too.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
The generator now raises on a missing agent template instead of silently skipping; update the test docstring to match (greptile P2).
|
pls also cherry pick to the release branch |
…mni.ext) (#5941) (#5993) Cherry-picks #5941 from develop to release/3.0.0-beta2. The generated template project pulled Kit/pxr eagerly, so importing it headless (Gym registration before SimulationApp) failed with `ModuleNotFoundError: No module named 'omni.ext'` and `TfNotice ... has not been created yet`. The fix loads the UI extension via its own `config/extension.toml` entry, switches the generated `mdp` package to `lazy_export()` with a `.pyi` stub, guards type-only imports under `TYPE_CHECKING`, creates the per-workflow `__init__.py` so internal tasks register after the core/contrib split, and makes the generator fail loudly on a missing agent template. Adds template-generator CI regression coverage. Validation: - ./isaaclab.sh -f Co-authored-by: Kelly Guo <kellyg@nvidia.com>
1. Summary
SimulationApp):import <project>failed withModuleNotFoundError: No module named 'omni.ext'. The package root no longer imports the example UI extension, so it stays omni-free. (NVBug 6251247)develop. Includes the template-generator test scaffolding (also proposed in Adds CI tests for template generator #5885, commit preserved) plus new regression coverage — 15 tests.2. Changes
2.1 Generator (
tools/template)templates/extension/__init__ext: drop the eagerfrom .ui_extension_example import *from the package root.templates/extension/config/extension.toml: register<name>.ui_extension_exampleas its own[[python.module]]so Kit still loads the UI extension (Kit imports eachpython.moduleby name and scans it foromni.ext.IExt).templates/extension/ui_extension_example.py: add the missingimport omni.ui.generator.py: raise (instead of silentlycontinue-ing) when anagents/<rl_library>_<algorithm>_cfgtemplate is missing.2.2 Tests
extension.tomlUI-module registration, generated-.pyast/compilevalidity, no top-level backend imports in generated env modules, per-library agent-config completeness.3. Design note: why not lazy-import
omni.extomni.ext/ExampleExtensionare consumed only by Kit's extension manager (via[[python.module]]), never on the headless path. The correct fix is to not import it at the package root, not to defer it.4. Out of scope / known limitations
MotionLoader+collect_reference_motions+ AMP observations) that a generic generated env cannot provide — seecontrib/humanoid_amp. PPO trains as-generated.free()/omni.UsdMdl TfNoticestartup crashes (NVBug 6257159, 6251258) are a separate core issue already fixed by deferring pxr ([Fix] Defer pxr loading in isaaclab.sim, .assets, .scene, and .sim/utils #5826) and cherry-picked torelease/3.0.0-beta2.5. Test plan
./isaaclab.sh -p -m pytest source/isaaclab_rl/test/test_template_generator.py→ 15 passed__init__ext/extension.tomlfix (verified by reverting)./isaaclab.sh -f(pre-commit) clean