huawei-noah / SMARTS

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

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

Closed Gamenot closed 6 months ago

Gamenot commented 6 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