Skip to content

feat(cli): add top-level CLI entry points for preview_asset and run_env#214

Merged
yuecideng merged 2 commits intomainfrom
feat/cli-entry-points
Apr 1, 2026
Merged

feat(cli): add top-level CLI entry points for preview_asset and run_env#214
yuecideng merged 2 commits intomainfrom
feat/cli-entry-points

Conversation

@yuecideng
Copy link
Copy Markdown
Contributor

Description

This PR adds top-level CLI entry points for preview_asset and run_env, allowing users to invoke them via:

python -m embodichain.preview_asset --asset_path /path/to/asset.usda --preview
python -m embodichain.run_env --gym_config config.json

This follows the same pattern as the existing python -m embodichain.data CLI.

Changes:

  • Extract if __name__ == "__main__" blocks into cli() functions in preview_asset.py and run_env.py
  • Add thin wrapper modules at embodichain/preview_asset.py and embodichain/run_env.py
  • Add CLI reference documentation (docs/source/guides/cli.md) covering all three CLI commands

Dependencies: None

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which improves an existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

Screenshots

N/A

Checklist

  • I have run the black . command to format the code base.
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Dependencies have been updated, if applicable.

🤖 Generated with Claude Code

Allow `python -m embodichain.preview_asset` and `python -m
embodichain.run_env` as shortcuts, following the same pattern as
`python -m embodichain.data`. Also adds CLI reference documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 1, 2026 12:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds user-facing python -m entry points for existing lab CLIs (preview_asset, run_env) and documents them alongside the existing embodichain.data CLI.

Changes:

  • Refactors embodichain/lab/scripts/preview_asset.py and embodichain/lab/scripts/run_env.py to expose a cli() entry point and keep __main__ behavior.
  • Introduces top-level modules embodichain/preview_asset.py and embodichain/run_env.py as thin entry points.
  • Adds CLI reference docs and links them from the guides index.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
embodichain/run_env.py New top-level CLI entry module for run_env (currently runs on import).
embodichain/preview_asset.py New top-level CLI entry module for preview_asset (currently runs on import).
embodichain/lab/scripts/run_env.py Extracts previous __main__ block into a reusable cli() function.
embodichain/lab/scripts/preview_asset.py Extracts previous __main__ block into a reusable cli() function.
docs/source/guides/index.rst Adds the new CLI guide to the guides toctree.
docs/source/guides/cli.md Documents usage and arguments for the three CLIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +21
from embodichain.lab.scripts.run_env import cli

cli()
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

This module executes cli() at import time. Importing embodichain.run_env from another Python module will immediately parse sys.argv and start the runner (likely raising SystemExit on argparse errors), which is an unsafe side effect for a normal importable module. Consider exposing a local cli() wrapper and only invoking it under if __name__ == "__main__": so python -m embodichain.run_env still works without import-time execution.

Suggested change
from embodichain.lab.scripts.run_env import cli
cli()
from embodichain.lab.scripts.run_env import cli as _cli
def cli() -> None:
"""Entry point for the environment runner CLI."""
_cli()
if __name__ == "__main__":
cli()

Copilot uses AI. Check for mistakes.

from embodichain.lab.scripts.preview_asset import cli

cli()
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

This module calls cli() unconditionally at import time. If any code imports embodichain.preview_asset (e.g., for programmatic access or module discovery), it will immediately run the CLI argument parsing and launch the preview workflow, which is a harmful side effect. Please guard execution with if __name__ == "__main__": and optionally re-export a cli() function so python -m embodichain.preview_asset continues to work.

Suggested change
cli()
def main() -> None:
"""Entry point for ``python -m embodichain.preview_asset``."""
cli()
if __name__ == "__main__":
main()

Copilot uses AI. Check for mistakes.
@yuecideng yuecideng merged commit cf8e924 into main Apr 1, 2026
5 checks passed
@yuecideng yuecideng deleted the feat/cli-entry-points branch April 1, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants