Refactor: move task env imports to tasks/__init__.py#212
Conversation
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>
There was a problem hiding this comment.
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__.pyto import and re-export task environments with an explicit__all__. - Removed explicit task-environment imports from
embodichain/lab/gym/envs/__init__.py, relying onfrom .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.
| # Tableware task environments | ||
| from embodichain.lab.gym.envs.tasks.tableware.pour_water.pour_water import ( | ||
| PourWaterEnv, | ||
| PourWaterAgentEnv, | ||
| ) |
There was a problem hiding this comment.
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.
| __all__ = [ | ||
| "PourWaterEnv", | ||
| "PourWaterAgentEnv", | ||
| "ScoopIce", | ||
| "StackBlocksTwoEnv", |
There was a problem hiding this comment.
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.
Description
Move explicit task environment imports from
embodichain/lab/gym/envs/__init__.pyinto a newly createdembodichain/lab/gym/envs/tasks/__init__.py.The
from .tasks import *wildcard import inenvs/__init__.pynow properly pulls in all task environments via the tasks package__init__.py, which:envs/__init__.pyclean with only 4 wildcard importstasks/package@register_envdecorator side effects (gym registration still fires at import time)__all__intasks/__init__.pyfor clear exportsDependencies: None
Type of change
Screenshots
N/A
Checklist
black .command to format the code base.🤖 Generated with Claude Code