Skip to content

Refactor: move task env imports to tasks/__init__.py#212

Merged
yuecideng merged 1 commit intomainfrom
refactor/move-task-imports-to-tasks-init
Apr 1, 2026
Merged

Refactor: move task env imports to tasks/__init__.py#212
yuecideng merged 1 commit intomainfrom
refactor/move-task-imports-to-tasks-init

Conversation

@yuecideng
Copy link
Copy Markdown
Contributor

Description

Move explicit task environment imports from embodichain/lab/gym/envs/__init__.py into a newly created embodichain/lab/gym/envs/tasks/__init__.py.

The from .tasks import * wildcard import in envs/__init__.py now properly pulls in all task environments via the tasks package __init__.py, which:

  • Keeps the envs/__init__.py clean with only 4 wildcard imports
  • Centralizes all task environment registrations in the tasks/ package
  • Preserves @register_env decorator side effects (gym registration still fires at import time)
  • Defines an explicit __all__ in tasks/__init__.py for clear exports

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

Move explicit task environment imports from envs/__init__.py into the
newly created tasks/__init__.py. The `from .tasks import *` wildcard
import now properly pulls in all task environments via the tasks
package, keeping the envs package init clean while preserving the
@register_env decorator side effects.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 31, 2026 15:48
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

Refactors environment import/registration wiring by centralizing task-environment imports into the tasks package so envs/__init__.py can stay minimal while still triggering registration side effects on import.

Changes:

  • Added embodichain/lab/gym/envs/tasks/__init__.py to import and re-export task environments with an explicit __all__.
  • Removed explicit task-environment imports from embodichain/lab/gym/envs/__init__.py, relying on from .tasks import *.

Reviewed changes

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

File Description
embodichain/lab/gym/envs/tasks/__init__.py Centralizes task env imports/exports and defines __all__ for wildcard exports.
embodichain/lab/gym/envs/__init__.py Simplifies top-level env imports to wildcard-import the tasks package.

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

Comment on lines +19 to +23
# Tableware task environments
from embodichain.lab.gym.envs.tasks.tableware.pour_water.pour_water import (
PourWaterEnv,
PourWaterAgentEnv,
)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

Adding tasks/__init__.py turns embodichain.lab.gym.envs.tasks from a (previously implicit) namespace package into a regular package, so any import of a submodule like embodichain.lab.gym.envs.tasks.rl will first execute this file and eagerly import/register all task envs. This can significantly increase import time and introduces broad import-time side effects for code paths that only need RL utilities (e.g., agents/rl/train.py). Consider moving the eager env imports into a dedicated module that is imported only from envs/__init__.py (or a register_all_tasks() function called there), keeping tasks/__init__.py lightweight to avoid forcing all task imports on every tasks.* import.

Copilot uses AI. Check for mistakes.
Comment on lines +53 to +57
__all__ = [
"PourWaterEnv",
"PourWaterAgentEnv",
"ScoopIce",
"StackBlocksTwoEnv",
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

This refactor changes import/registration wiring but there’s no test ensuring task env registrations still occur via import embodichain.lab.gym.envs / from embodichain.lab.gym.envs import * (and that exports in __all__ resolve). Since the repo already has pytest coverage for lab/gym/envs, please add a lightweight test that imports embodichain.lab.gym.envs and asserts gymnasium.spec(...) (or the internal registry) contains a representative env id like SimpleTask-v1 / PushCubeRL.

Copilot uses AI. Check for mistakes.
@yuecideng yuecideng merged commit 6626282 into main Apr 1, 2026
9 checks passed
@yuecideng yuecideng deleted the refactor/move-task-imports-to-tasks-init branch April 1, 2026 02:44
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