huawei-noah / SMARTS

Scalable Multi-Agent RL Training School for Autonomous Driving
MIT License
954 stars 190 forks source link

[Bugfix] pycharm debug loading project modules as standard library modules #2126

Closed Gamenot closed 11 months ago

Gamenot commented 11 months ago

Pycharm debug loads certain modules as if they were the core python modules as noted here: https://stackoverflow.com/a/68985644

This fixes the problem and manually sets the original modules as compatibility. The following have changed:

Note that the original imports (e.g. import smarts.sstudio.types) will still work for now because of dynamic module assignment as shown below.

# smarts/core/utils/__init__.py
import sys
from . import core_math as math

# sys.modules["smarts.core.utils.math"] = math
sys.modules[f"{__name__}.{math=}".partition('=')[0]] = math

Closes #2125